1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.project.canonical;
20
21 import java.io.File;
22 import java.util.List;
23
24 import org.apache.maven.api.xml.XmlNode;
25 import org.apache.maven.model.Plugin;
26 import org.apache.maven.model.PluginExecution;
27 import org.apache.maven.project.AbstractMavenProjectTestCase;
28 import org.apache.maven.project.MavenProject;
29 import org.junit.jupiter.api.Test;
30
31 import static org.junit.jupiter.api.Assertions.assertEquals;
32 import static org.junit.jupiter.api.Assertions.assertNotNull;
33
34
35
36 class CanonicalProjectBuilderTest extends AbstractMavenProjectTestCase {
37 @Test
38 void testProjectBuilder() throws Exception {
39 File f = getFileForClasspathResource("canonical-pom.xml");
40
41 MavenProject project = getProject(f);
42
43
44
45
46
47 assertEquals("4.0.0", project.getModelVersion());
48
49
50
51
52
53 List<Plugin> plugins = project.getBuildPlugins();
54
55
56
57 String key = "org.apache.maven.plugins:maven-plexus-plugin";
58
59 Plugin plugin = null;
60 for (Plugin check : plugins) {
61 if (key.equals(check.getKey())) {
62 plugin = check;
63 break;
64 }
65 }
66
67 assertNotNull(plugin);
68
69 assertEquals("1.0", plugin.getVersion());
70
71 XmlNode configuration = plugin.getDelegate().getConfiguration();
72
73 assertEquals(
74 "src/conf/plexus.conf",
75 configuration.getChild("plexusConfiguration").getValue());
76
77 assertEquals(
78 "src/conf/plexus.properties",
79 configuration.getChild("plexusConfigurationPropertiesFile").getValue());
80
81 assertEquals(
82 "Continuum", configuration.getChild("plexusApplicationName").getValue());
83
84
85
86
87
88 List<PluginExecution> executions = plugin.getExecutions();
89
90 PluginExecution execution = executions.get(0);
91
92 String g0 = execution.getGoals().get(0);
93
94 assertEquals("plexus:runtime", g0);
95
96 configuration = execution.getDelegate().getConfiguration();
97
98 assertEquals(
99 "ContinuumPro", configuration.getChild("plexusApplicationName").getValue());
100
101
102 }
103 }