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.List;
26
27
28
29
30
31
32
33
34 public class MavenITmng1412DependenciesOrderTest
35 extends AbstractMavenIntegrationTestCase
36 {
37
38 public MavenITmng1412DependenciesOrderTest()
39 {
40 super( "(2.0.8,)" );
41 }
42
43 public void testitMNG1412()
44 throws Exception
45 {
46 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-1412" );
47
48 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
49 verifier.setAutoclean( false );
50 verifier.deleteDirectory( "target" );
51 verifier.deleteArtifacts( "org.apache.maven.its.mng1412" );
52 verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
53 verifier.addCliOption( "--settings" );
54 verifier.addCliOption( "settings.xml" );
55 verifier.executeGoal( "validate" );
56 verifier.verifyErrorFreeLog();
57 verifier.resetStreams();
58
59 List<String> compileArtifacts = verifier.loadLines( "target/compile-artifacts.txt", "UTF-8" );
60 assertArtifactOrder( compileArtifacts );
61
62 List<String> compileClassPath = verifier.loadLines( "target/compile-classpath.txt", "UTF-8" );
63 assertClassPathOrder( compileClassPath.subList( 1, compileClassPath.size() ) );
64
65 List<String> runtimeArtifacts = verifier.loadLines( "target/runtime-artifacts.txt", "UTF-8" );
66 assertArtifactOrder( runtimeArtifacts );
67
68 List<String> runtimeClassPath = verifier.loadLines( "target/runtime-classpath.txt", "UTF-8" );
69 assertClassPathOrder( runtimeClassPath.subList( 1, runtimeClassPath.size() ) );
70
71 List<String> testArtifacts = verifier.loadLines( "target/test-artifacts.txt", "UTF-8" );
72 assertArtifactOrder( testArtifacts );
73
74 List<String> testClassPath = verifier.loadLines( "target/test-classpath.txt", "UTF-8" );
75 assertClassPathOrder( testClassPath.subList( 2, testClassPath.size() ) );
76 }
77
78 private void assertArtifactOrder( List<String> artifacts )
79 {
80 assertEquals( 4, artifacts.size() );
81 assertEquals( "org.apache.maven.its.mng1412:a:jar:0.1", artifacts.get( 0 ) );
82 assertEquals( "org.apache.maven.its.mng1412:c:jar:0.1", artifacts.get( 1 ) );
83 assertEquals( "org.apache.maven.its.mng1412:b:jar:0.1", artifacts.get( 2 ) );
84 assertEquals( "org.apache.maven.its.mng1412:d:jar:0.1", artifacts.get( 3 ) );
85 }
86
87 private void assertClassPathOrder( List<String> classpath )
88 {
89 assertEquals( 4, classpath.size() );
90 assertEquals( "a-0.1.jar", classpath.get( 0 ) );
91 assertEquals( "c-0.1.jar", classpath.get( 1 ) );
92 assertEquals( "b-0.1.jar", classpath.get( 2 ) );
93 assertEquals( "d-0.1.jar", classpath.get( 3 ) );
94 }
95
96 }