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
37 class CanonicalProjectBuilderTest extends AbstractMavenProjectTestCase {
38 @Test
39 void testProjectBuilder() throws Exception {
40 File f = getFileForClasspathResource("canonical-pom.xml");
41
42 MavenProject project = getProject(f);
43
44
45
46
47
48 assertEquals("4.0.0", project.getModelVersion());
49
50
51
52
53
54 List<Plugin> plugins = project.getBuildPlugins();
55
56
57
58 String key = "org.apache.maven.plugins:maven-plexus-plugin";
59
60 Plugin plugin = null;
61 for (Plugin check : plugins) {
62 if (key.equals(check.getKey())) {
63 plugin = check;
64 break;
65 }
66 }
67
68 assertNotNull(plugin);
69
70 assertEquals("1.0", plugin.getVersion());
71
72 XmlNode configuration = plugin.getDelegate().getConfiguration();
73
74 assertEquals(
75 "src/conf/plexus.conf",
76 configuration.getChild("plexusConfiguration").getValue());
77
78 assertEquals(
79 "src/conf/plexus.properties",
80 configuration.getChild("plexusConfigurationPropertiesFile").getValue());
81
82 assertEquals(
83 "Continuum", configuration.getChild("plexusApplicationName").getValue());
84
85
86
87
88
89 List<PluginExecution> executions = plugin.getExecutions();
90
91 PluginExecution execution = executions.get(0);
92
93 String g0 = execution.getGoals().get(0);
94
95 assertEquals("plexus:runtime", g0);
96
97 configuration = execution.getDelegate().getConfiguration();
98
99 assertEquals(
100 "ContinuumPro", configuration.getChild("plexusApplicationName").getValue());
101
102
103 }
104 }