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
34 public class ProjectInheritanceTest
35 extends AbstractProjectInheritanceTestCase
36 {
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 public void testDependencyManagementExclusionsExcludeTransitively()
61 throws Exception
62 {
63 File localRepo = getLocalRepositoryPath();
64
65 File pom0 = new File( localRepo, "p0/pom.xml" );
66 File pom0Basedir = pom0.getParentFile();
67 File pom1 = new File( pom0Basedir, "p1/pom.xml" );
68
69
70 MavenProject project0 = getProjectWithDependencies( pom0 );
71 MavenProject project1 = getProjectWithDependencies( pom1 );
72
73 assertNotNull("Parent is null", project1.getParent());
74 assertEquals( pom0Basedir, project1.getParent().getBasedir() );
75 Map map = project1.getArtifactMap();
76
77 assertNotNull("No artifacts", map);
78 assertTrue("No Artifacts", map.size() > 0);
79 assertTrue("Set size should be 2, is " + map.size(), map.size() == 2);
80
81 assertTrue("maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" ));
82 assertTrue("maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" ));
83 assertFalse("maven-test:t09-c is in the project", map.containsKey( "maven-test:t09-c" ));
84 }
85
86
87
88
89
90
91
92
93
94
95
96 public void testDependencyManagementExclusionDoesNotOverrideGloballyForTransitives()
97 throws Exception
98 {
99 File localRepo = getLocalRepositoryPath();
100
101 File pom0 = new File( localRepo, "p0/pom.xml" );
102 File pom0Basedir = pom0.getParentFile();
103 File pom2 = new File( pom0Basedir, "p2/pom.xml" );
104
105
106 MavenProject project0 = getProjectWithDependencies( pom0 );
107 MavenProject project2 = getProjectWithDependencies( pom2 );
108
109 assertEquals( pom0Basedir, project2.getParent().getBasedir() );
110 Map map = project2.getArtifactMap();
111 assertNotNull( "No artifacts", map );
112 assertTrue( "No Artifacts", map.size() > 0 );
113 assertTrue( "Set size should be 4, is " + map.size(), map.size() == 4 );
114
115 assertTrue( "maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" ) );
116 assertTrue( "maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" ) );
117 assertTrue( "maven-test:t09-c is not in the project", map.containsKey( "maven-test:t09-c" ) );
118 assertTrue( "maven-test:t09-d is not in the project", map.containsKey( "maven-test:t09-d" ) );
119 }
120 }