1 package org.apache.maven.surefire.its.jiras;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.surefire.its.fixture.OutputValidator;
23 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
24 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
25 import org.junit.Test;
26
27 import static org.fest.assertions.Assertions.assertThat;
28
29
30
31
32
33
34 public class Surefire1367AssumptionLogsIT
35 extends SurefireJUnit4IntegrationTestCase
36 {
37 private static final String NL = System.getProperty( "line.separator" );
38
39 @Test
40 public void shouldSeeLogsParallelForked()
41 {
42 OutputValidator outputValidator = unpack().setForkJvm()
43 .forkMode( "once" )
44 .parallelClassesAndMethods()
45 .disablePerCoreThreadCount()
46 .threadCountClasses( 2 )
47 .threadCountMethods( 2 )
48 .executeTest()
49 .assertTestSuiteResults( 2, 0, 0, 2 );
50
51 verifyReportA( outputValidator );
52 verifyReportB( outputValidator );
53 }
54
55 @Test
56 public void shouldSeeLogsParallelInPlugin()
57 {
58 OutputValidator outputValidator = unpack().setForkJvm()
59 .forkMode( "never" )
60 .parallelClassesAndMethods()
61 .disablePerCoreThreadCount()
62 .threadCountClasses( 2 )
63 .threadCountMethods( 2 )
64 .executeTest()
65 .assertTestSuiteResults( 2, 0, 0, 2 );
66
67 verifyReportA( outputValidator );
68 verifyReportB( outputValidator );
69 }
70
71 @Test
72 public void shouldSeeLogsForked()
73 {
74 OutputValidator outputValidator = unpack().setForkJvm()
75 .forkMode( "once" )
76 .executeTest()
77 .assertTestSuiteResults( 2, 0, 0, 2 );
78
79 verifyReportA( outputValidator );
80 verifyReportB( outputValidator );
81 }
82
83 @Test
84 public void shouldSeeLogsInPlugin()
85 {
86 OutputValidator outputValidator = unpack().setForkJvm()
87 .forkMode( "never" )
88 .executeTest()
89 .assertTestSuiteResults( 2, 0, 0, 2 );
90
91 verifyReportA( outputValidator );
92 verifyReportB( outputValidator );
93 }
94
95
96 private SurefireLauncher unpack()
97 {
98 return unpack( "/surefire-1367" );
99 }
100
101 private void verifyReportA( OutputValidator outputValidator )
102 {
103 String xmlReport = outputValidator.getSurefireReportsXmlFile( "TEST-ATest.xml" )
104 .readFileToString();
105
106 String outputCData = "<system-out><![CDATA[Hi" + NL +
107 NL +
108 "There!" + NL +
109 "]]></system-out>" + NL +
110 " <system-err><![CDATA[Hello" + NL +
111 NL +
112 "What's up!" + NL +
113 "]]></system-err>";
114
115 assertThat( xmlReport )
116 .contains( outputCData );
117
118
119 String output = outputValidator.getSurefireReportsFile( "ATest-output.txt" )
120 .readFileToString();
121
122 String outputExpected = "Hi" + NL +
123 NL +
124 "There!" + NL +
125 "Hello" + NL +
126 NL +
127 "What's up!" + NL;
128
129 assertThat( output )
130 .isEqualTo( outputExpected );
131 }
132
133 private void verifyReportB( OutputValidator outputValidator )
134 {
135 String xmlReport = outputValidator.getSurefireReportsXmlFile( "TEST-BTest.xml" )
136 .readFileToString();
137
138 String outputCData = "<system-out><![CDATA[Hey" + NL +
139 NL +
140 "you!" + NL +
141 "]]></system-out>";
142
143 assertThat( xmlReport )
144 .contains( outputCData );
145
146
147 String output = outputValidator.getSurefireReportsFile( "BTest-output.txt" )
148 .readFileToString();
149
150 String outputExpected = "Hey" + NL +
151 NL +
152 "you!" + NL;
153
154 assertThat( output )
155 .isEqualTo( outputExpected );
156 }
157 }