Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4736 rpuchmay 1
package test;
2
 
3
import static org.junit.Assert.*;
4
 
5
import java.io.ByteArrayOutputStream;
6
import java.io.PrintStream;
7
 
8
import org.junit.Before;
9
import org.junit.Test;
10
 
11
import releaseManager.TeamCity;
12
 
13
public class Test_TeamCity
14
{
15
	ByteArrayOutputStream buffer = new ByteArrayOutputStream();
16
	PrintStream output = new PrintStream(buffer);
17
 
18
	@Before
19
	public void setUp()
20
	{
21
		output.flush();
22
		buffer.reset();
23
	}
24
 
25
	@Test
26
	public void testStartSuite()
27
	{
28
		// Arrange
29
		TeamCity teamCity = new TeamCity(output);
30
 
31
		// Act
32
		teamCity.startSuite("abcdef");
33
 
34
		// Assert
35
		assertEquals("Should be the same", "##teamcity[testSuiteStarted name='abcdef']\n", buffer.toString());
36
	}
37
 
38
	@Test
39
	public void testStartTest()
40
	{
41
		// Arrange
42
		TeamCity teamCity = new TeamCity(output);
43
 
44
		// Act
45
		teamCity.startTest("abcdef");
46
 
47
		// Assert
48
		assertEquals("Should be the same", "##teamcity[testStarted name='abcdef']\n", buffer.toString());
49
	}
50
 
51
	@Test
52
	public void testFinishTest()
53
	{
54
		// Arrange
55
		TeamCity teamCity = new TeamCity(output);
56
 
57
		// Act
58
		teamCity.finishTest("abcdef");
59
 
60
		// Assert
61
		assertEquals("Should be the same", "##teamcity[testFinished name='abcdef']\n", buffer.toString());
62
	}
63
 
64
	@Test
65
	public void testFinishSuite()
66
	{
67
		// Arrange
68
		TeamCity teamCity = new TeamCity(output);
69
 
70
		// Act
71
		teamCity.finishSuite("abcdef");
72
 
73
		// Assert
74
		assertEquals("Should be the same", "##teamcity[testSuiteFinished name='abcdef']\n", buffer.toString());
75
	}
76
 
77
	@Test
78
	public void testError()
79
	{
80
		// Arrange
81
		TeamCity teamCity = new TeamCity(output);
82
 
83
		// Act
84
		teamCity.error("abcdef","qwerty");
85
 
86
		// Assert
87
		assertEquals("Should be the same", "##teamcity[message text='abcdef' errorDetails='qwerty' status='ERROR']\n", buffer.toString());
88
 
89
	}
90
 
91
	@Test
92
	public void testMultilineError()
93
	{
94
		// Arrange
95
		TeamCity teamCity = new TeamCity(output);
96
 
97
		// Act
98
		teamCity.error("abcdef","qwerty\nLine2");
99
 
100
		// Assert
101
		assertEquals("Should be the same", "##teamcity[message text='abcdef' errorDetails='qwerty|nLine2' status='ERROR']\n", buffer.toString());		
102
	}
103
 
104
 
105
	@Test
106
	public void testMessageEncoding()
107
	{
108
		// Arrange
109
		TeamCity teamCity = new TeamCity(output);
110
 
111
		// Act
112
		String actual = teamCity.encode("a\nb'c\rd|e[f]");
113
 
114
		// Assert
115
		assertEquals("Should be the same", "a|nb|'c|rd||e|[f|]", actual);
116
 
117
	}
118
}