1 package org.apache.maven.project.inheritance.t09;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.io.File;
22 import java.util.Map;
23
24 import org.apache.maven.project.MavenProject;
25 import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
26
27
28
29
30
31
32
33 public class ProjectInheritanceTest
34 extends AbstractProjectInheritanceTestCase
35 {
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 public void testDependencyManagementExclusionsExcludeTransitively()
60 throws Exception
61 {
62 File localRepo = getLocalRepositoryPath();
63
64 File pom0 = new File( localRepo, "p0/pom.xml" );
65 File pom0Basedir = pom0.getParentFile();
66 File pom1 = new File( pom0Basedir, "p1/pom.xml" );
67
68
69 MavenProject project0 = getProjectWithDependencies( pom0 );
70 MavenProject project1 = getProjectWithDependencies( pom1 );
71
72 assertNotNull("Parent is null", project1.getParent());
73 assertEquals( pom0Basedir, project1.getParent().getBasedir() );
74 Map map = project1.getArtifactMap();
75
76 assertNotNull("No artifacts", map);
77 assertTrue("No Artifacts", map.size() > 0);
78 assertTrue("Set size should be 2, is " + map.size(), map.size() == 2);
79
80 assertTrue("maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" ));
81 assertTrue("maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" ));
82 assertFalse("maven-test:t09-c is in the project", map.containsKey( "maven-test:t09-c" ));
83 }
84
85
86
87
88
89
90
91
92
93
94
95 public void testDependencyManagementExclusionDoesNotOverrideGloballyForTransitives()
96 throws Exception
97 {
98 File localRepo = getLocalRepositoryPath();
99
100 File pom0 = new File( localRepo, "p0/pom.xml" );
101 File pom0Basedir = pom0.getParentFile();
102 File pom2 = new File( pom0Basedir, "p2/pom.xml" );
103
104
105 MavenProject project0 = getProjectWithDependencies( pom0 );
106 MavenProject project2 = getProjectWithDependencies( pom2 );
107
108 assertEquals( pom0Basedir, project2.getParent().getBasedir() );
109 Map map = project2.getArtifactMap();
110 assertNotNull( "No artifacts", map );
111 assertTrue( "No Artifacts", map.size() > 0 );
112 assertTrue( "Set size should be 4, is " + map.size(), map.size() == 4 );
113
114 assertTrue( "maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" ) );
115 assertTrue( "maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" ) );
116 assertTrue( "maven-test:t09-c is not in the project", map.containsKey( "maven-test:t09-c" ) );
117 assertTrue( "maven-test:t09-d is not in the project", map.containsKey( "maven-test:t09-d" ) );
118 }
119 }