1 package org.apache.maven.it;
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.it.util.ResourceExtractor;
23
24 import java.io.File;
25 import java.util.Arrays;
26 import java.util.LinkedList;
27 import java.util.List;
28
29
30
31
32
33
34
35
36
37
38 public class MavenITmng6391PrintVersionTest
39 extends AbstractMavenIntegrationTestCase
40 {
41
42 public MavenITmng6391PrintVersionTest()
43 {
44 super( "[3.6.0,)" );
45 }
46
47
48
49
50
51
52
53
54
55 public void testitShouldPrintVersionAtTopAndAtBottom()
56 throws Exception
57 {
58 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6391-print-version" );
59
60 Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
61 verifier.setMavenDebug( false );
62 verifier.setAutoclean( false );
63
64 verifier.setLogFileName( "version-log.txt" );
65 verifier.executeGoals( Arrays.asList( "clean" ) );
66 verifier.verifyErrorFreeLog();
67 verifier.resetStreams();
68
69 List<String> loadedLines = verifier.loadLines( "version-log.txt", "UTF-8" );
70 List<String> resultingLines = extractReactorBuildOrder( loadedLines );
71
72
73 assertEquals( 5, resultingLines.size() );
74
75
76 assertTrue( resultingLines.get( 0 ).startsWith( "[INFO] Reactor Summary for base-project 1.3.0-SNAPSHOT:" ) );
77 assertTrue( resultingLines.get( 1 ).startsWith( "[INFO] base-project ....................................... SUCCESS [" ) );
78 assertTrue( resultingLines.get( 2 ).startsWith( "[INFO] module-1 ........................................... SUCCESS [" ) );
79 assertTrue( resultingLines.get( 3 ).startsWith( "[INFO] module-2 ........................................... SUCCESS [" ) );
80 assertTrue( resultingLines.get( 4 ).startsWith( "[INFO] module-3 ........................................... SUCCESS [" ) );
81
82 }
83
84
85
86
87
88
89
90
91 public void testitShouldPrintVersionInAllLines()
92 throws Exception
93 {
94 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6391-print-version-aggregator" );
95
96 Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
97 verifier.setMavenDebug( false );
98 verifier.setAutoclean( false );
99
100 verifier.setLogFileName( "version-log.txt" );
101 verifier.executeGoals( Arrays.asList( "clean" ) );
102 verifier.verifyErrorFreeLog();
103 verifier.resetStreams();
104
105 List<String> loadedLines = verifier.loadLines( "version-log.txt", "UTF-8" );
106 List<String> resultingLines = extractReactorBuildOrder( loadedLines );
107
108
109 assertEquals( 5, resultingLines.size() );
110
111
112 assertTrue( resultingLines.get( 0 ).startsWith( "[INFO] Reactor Summary:" ) );
113 assertTrue( resultingLines.get( 1 ).startsWith( "[INFO] module-1 1.2.7.43.RELEASE .......................... SUCCESS [ " ) );
114 assertTrue( resultingLines.get( 2 ).startsWith( "[INFO] module-2 7.5-SNAPSHOT .............................. SUCCESS [ " ) );
115 assertTrue( resultingLines.get( 3 ).startsWith( "[INFO] module-3 1-RC1 ..................................... SUCCESS [ " ) );
116 assertTrue( resultingLines.get( 4 ).startsWith( "[INFO] base-project 1.0.0-SNAPSHOT ........................ SUCCESS [ " ) );
117
118 }
119
120
121
122
123
124
125
126
127
128
129
130
131 private List<String> extractReactorBuildOrder( List<String> loadedLines )
132 {
133 List<String> resultingLines = new LinkedList<String>();
134 boolean start = false;
135 for ( String line : loadedLines )
136 {
137 if ( start )
138 {
139 if ( line.startsWith( "[INFO] -------------" ) )
140 {
141 start = false;
142 }
143 else if ( !line.endsWith( "[INFO] " ) )
144 {
145 resultingLines.add( line );
146 }
147 }
148 else
149 {
150 if ( line.startsWith( "[INFO] Reactor Summary" ) )
151 {
152 start = true;
153 resultingLines.add( line );
154 }
155
156 }
157 }
158 return resultingLines;
159
160 }
161
162 }