1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.repository.metadata;
20
21 import org.apache.maven.artifact.ArtifactScopeEnum;
22 import org.codehaus.plexus.PlexusTestCase;
23
24
25
26
27
28
29 public class DefaultClasspathTransformationTest extends PlexusTestCase {
30 ClasspathTransformation transform;
31
32 MetadataGraph graph;
33
34 MetadataGraphVertex v1;
35 MetadataGraphVertex v2;
36 MetadataGraphVertex v3;
37 MetadataGraphVertex v4;
38
39 @Override
40 protected void setUp() throws Exception {
41 super.setUp();
42 transform = (ClasspathTransformation) lookup(ClasspathTransformation.ROLE, "default");
43
44 graph = new MetadataGraph(4, 3);
45
46
47
48
49
50
51 v1 = graph.addVertex(new ArtifactMetadata("g", "a1", "1.0"));
52 graph.setEntry(v1);
53 v2 = graph.addVertex(new ArtifactMetadata("g", "a2", "1.0"));
54 v3 = graph.addVertex(new ArtifactMetadata("g", "a3", "1.0"));
55 v4 = graph.addVertex(new ArtifactMetadata("g", "a4", "1.0"));
56
57
58 graph.addEdge(v1, v2, new MetadataGraphEdge("1.1", true, null, null, 2, 1));
59 graph.addEdge(v1, v2, new MetadataGraphEdge("1.2", true, null, null, 2, 2));
60
61
62 graph.addEdge(v1, v3, new MetadataGraphEdge("1.1", true, null, null, 2, 1));
63 graph.addEdge(v1, v3, new MetadataGraphEdge("1.2", true, null, null, 4, 2));
64
65
66 graph.addEdge(v3, v4, new MetadataGraphEdge("1.1", true, ArtifactScopeEnum.runtime, null, 2, 2));
67 graph.addEdge(v3, v4, new MetadataGraphEdge("1.2", true, ArtifactScopeEnum.test, null, 2, 2));
68 }
69
70 public void testCompileClasspathTransform() throws Exception {
71 ClasspathContainer res;
72
73 res = transform.transform(graph, ArtifactScopeEnum.compile, false);
74
75 assertNotNull("null classpath container after compile transform", res);
76 assertNotNull("null classpath after compile transform", res.getClasspath());
77 assertEquals(
78 "compile classpath should have 3 entries", 3, res.getClasspath().size());
79 }
80
81 public void testRuntimeClasspathTransform() throws Exception {
82 ClasspathContainer res;
83
84 res = transform.transform(graph, ArtifactScopeEnum.runtime, false);
85
86 assertNotNull("null classpath container after runtime transform", res);
87 assertNotNull("null classpath after runtime transform", res.getClasspath());
88 assertEquals(
89 "runtime classpath should have 4 entries", 4, res.getClasspath().size());
90
91 ArtifactMetadata md = res.getClasspath().get(3);
92 assertEquals("runtime artifact version should be 1.1", "1.1", md.getVersion());
93 }
94
95 public void testTestClasspathTransform() throws Exception {
96 ClasspathContainer res;
97
98 res = transform.transform(graph, ArtifactScopeEnum.test, false);
99
100 assertNotNull("null classpath container after runtime transform", res);
101 assertNotNull("null classpath after runtime transform", res.getClasspath());
102 assertEquals(
103 "runtime classpath should have 4 entries", 4, res.getClasspath().size());
104
105 ArtifactMetadata md = res.getClasspath().get(3);
106 assertEquals("test artifact version should be 1.2", "1.2", md.getVersion());
107 }
108
109
110 }