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.Verifier;
23 import org.apache.maven.it.util.ResourceExtractor;
24
25 import java.io.File;
26 import java.util.List;
27
28
29
30
31
32
33 public class MavenITmng3043BestEffortReactorResolutionTest
34 extends AbstractMavenIntegrationTestCase
35 {
36
37 public MavenITmng3043BestEffortReactorResolutionTest()
38 {
39 super( "[3.0-alpha-3,)" );
40 }
41
42
43
44
45
46
47 public void testitTestPhase()
48 throws Exception
49 {
50 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3043" );
51
52 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
53 verifier.setAutoclean( false );
54 verifier.deleteDirectory( "consumer-a/target" );
55 verifier.deleteDirectory( "consumer-b/target" );
56 verifier.deleteDirectory( "consumer-c/target" );
57 verifier.deleteArtifacts( "org.apache.maven.its.mng3043" );
58 verifier.setLogFileName( "log-test.txt" );
59 verifier.executeGoal( "test" );
60 verifier.verifyErrorFreeLog();
61 verifier.resetStreams();
62
63 List classpath;
64
65 classpath = verifier.loadLines( "consumer-a/target/compile.txt", "UTF-8" );
66 assertContains( classpath, new String[] { "classes-test" } );
67 assertNotContains( classpath, new String[] { "classes-main" } );
68 classpath = verifier.loadLines( "consumer-a/target/runtime.txt", "UTF-8" );
69 assertContains( classpath, new String[] { "classes-test" } );
70 assertNotContains( classpath, new String[] { "classes-main" } );
71 classpath = verifier.loadLines( "consumer-a/target/test.txt", "UTF-8" );
72 assertContains( classpath, new String[] { "classes-test" } );
73 assertNotContains( classpath, new String[] { "classes-main" } );
74
75 classpath = verifier.loadLines( "consumer-b/target/compile.txt", "UTF-8" );
76 assertContains( classpath, new String[] { "classes-main" } );
77 assertNotContains( classpath, new String[] { "classes-test" } );
78 classpath = verifier.loadLines( "consumer-b/target/runtime.txt", "UTF-8" );
79 assertContains( classpath, new String[] { "classes-main" } );
80 assertNotContains( classpath, new String[] { "classes-test" } );
81 classpath = verifier.loadLines( "consumer-b/target/test.txt", "UTF-8" );
82 assertContains( classpath, new String[] { "classes-main" } );
83 assertNotContains( classpath, new String[] { "classes-test" } );
84
85 classpath = verifier.loadLines( "consumer-c/target/compile.txt", "UTF-8" );
86 assertContains( classpath, new String[] { "classes-main" } );
87 assertContains( classpath, new String[] { "classes-test" } );
88 classpath = verifier.loadLines( "consumer-c/target/runtime.txt", "UTF-8" );
89 assertContains( classpath, new String[] { "classes-main" } );
90 assertContains( classpath, new String[] { "classes-test" } );
91 classpath = verifier.loadLines( "consumer-c/target/test.txt", "UTF-8" );
92 assertContains( classpath, new String[] { "classes-main" } );
93 assertContains( classpath, new String[] { "classes-test" } );
94 }
95
96
97
98
99
100
101 public void testitPackagePhase()
102 throws Exception
103 {
104 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3043" );
105
106 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
107 verifier.setAutoclean( false );
108 verifier.deleteDirectory( "consumer-a/target" );
109 verifier.deleteDirectory( "consumer-b/target" );
110 verifier.deleteDirectory( "consumer-c/target" );
111 verifier.deleteArtifacts( "org.apache.maven.its.mng3043" );
112 verifier.setLogFileName( "log-package.txt" );
113 verifier.executeGoal( "package" );
114 verifier.verifyErrorFreeLog();
115 verifier.resetStreams();
116
117 List classpath;
118
119 classpath = verifier.loadLines( "consumer-a/target/compile.txt", "UTF-8" );
120 assertContains( classpath, new String[] { "tests.jar" } );
121 assertNotContains( classpath, new String[] { "client.jar" } );
122 classpath = verifier.loadLines( "consumer-a/target/runtime.txt", "UTF-8" );
123 assertContains( classpath, new String[] { "tests.jar" } );
124 assertNotContains( classpath, new String[] { "client.jar" } );
125 classpath = verifier.loadLines( "consumer-a/target/test.txt", "UTF-8" );
126 assertContains( classpath, new String[] { "tests.jar" } );
127 assertNotContains( classpath, new String[] { "client.jar" } );
128
129 classpath = verifier.loadLines( "consumer-b/target/compile.txt", "UTF-8" );
130 assertContains( classpath, new String[] { "client.jar" } );
131 assertNotContains( classpath, new String[] { "tests.jar" } );
132 classpath = verifier.loadLines( "consumer-b/target/runtime.txt", "UTF-8" );
133 assertContains( classpath, new String[] { "client.jar" } );
134 assertNotContains( classpath, new String[] { "tests.jar" } );
135 classpath = verifier.loadLines( "consumer-b/target/test.txt", "UTF-8" );
136 assertContains( classpath, new String[] { "client.jar" } );
137 assertNotContains( classpath, new String[] { "tests.jar" } );
138
139 classpath = verifier.loadLines( "consumer-c/target/compile.txt", "UTF-8" );
140 assertContains( classpath, new String[] { "client.jar" } );
141 assertContains( classpath, new String[] { "tests.jar" } );
142 classpath = verifier.loadLines( "consumer-c/target/runtime.txt", "UTF-8" );
143 assertContains( classpath, new String[] { "client.jar" } );
144 assertContains( classpath, new String[] { "tests.jar" } );
145 classpath = verifier.loadLines( "consumer-c/target/test.txt", "UTF-8" );
146 assertContains( classpath, new String[] { "client.jar" } );
147 assertContains( classpath, new String[] { "tests.jar" } );
148 }
149
150 private void assertContains( List collection, Object[] items )
151 {
152 for ( int i = 0; i < items.length; i++ )
153 {
154 assertContains( collection, items[i] );
155 }
156 }
157
158 private void assertContains( List collection, Object item )
159 {
160 assertTrue( item + " missing in " + collection, collection.contains( item ) );
161 }
162
163 private void assertNotContains( List collection, Object[] items )
164 {
165 for ( int i = 0; i < items.length; i++ )
166 {
167 assertNotContains( collection, items[i] );
168 }
169 }
170
171 private void assertNotContains( List collection, Object item )
172 {
173 assertFalse( item + " present in " + collection, collection.contains( item ) );
174 }
175
176 }