Skip to content

Commit 59fbc4c

Browse files
SajeerSajeer
authored andcommitted
New test added for maven surefire and failsafe
1 parent 4357886 commit 59fbc4c

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package net.wasdev.wlp.test.dev.it;
2+
3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertNotNull;
5+
import static org.junit.Assert.assertNull;
6+
7+
import org.apache.maven.model.Plugin;
8+
import org.apache.maven.plugin.logging.SystemStreamLog;
9+
import org.codehaus.plexus.util.xml.Xpp3Dom;
10+
import org.junit.Test;
11+
12+
import io.openliberty.tools.maven.utils.ExecuteMojoUtil;
13+
14+
public class ToolchainSurefireFailsafeConfigTest {
15+
16+
@Test
17+
public void jdkToolchainIsPreservedForMavenSurefirePluginTestGoal() {
18+
Plugin plugin = new Plugin();
19+
plugin.setGroupId("org.apache.maven.plugins");
20+
plugin.setArtifactId("maven-surefire-plugin");
21+
plugin.setVersion("3.1.2");
22+
23+
Xpp3Dom config = new Xpp3Dom("configuration");
24+
Xpp3Dom jdkToolchain = new Xpp3Dom("jdkToolchain");
25+
Xpp3Dom version = new Xpp3Dom("version");
26+
version.setValue("11");
27+
jdkToolchain.addChild(version);
28+
config.addChild(jdkToolchain);
29+
30+
plugin.setConfiguration(config);
31+
32+
Xpp3Dom goalConfig = ExecuteMojoUtil.getPluginGoalConfig(plugin, "test", new SystemStreamLog());
33+
Xpp3Dom jdkToolchainChild = goalConfig.getChild("jdkToolchain");
34+
Xpp3Dom versionChild = jdkToolchainChild.getChild("version");
35+
36+
assertNotNull("jdkToolchain element should be preserved for maven-surefire-plugin:test", jdkToolchainChild);
37+
assertNotNull("version child should be present under jdkToolchain", versionChild);
38+
assertEquals("11", versionChild.getValue());
39+
}
40+
41+
@Test
42+
public void jdkToolchainIsPreservedForMavenFailsafePluginIntegrationTestGoal() {
43+
Plugin plugin = new Plugin();
44+
plugin.setGroupId("org.apache.maven.plugins");
45+
plugin.setArtifactId("maven-failsafe-plugin");
46+
plugin.setVersion("3.1.2");
47+
48+
Xpp3Dom config = new Xpp3Dom("configuration");
49+
Xpp3Dom jdkToolchain = new Xpp3Dom("jdkToolchain");
50+
Xpp3Dom version = new Xpp3Dom("version");
51+
version.setValue("11");
52+
jdkToolchain.addChild(version);
53+
config.addChild(jdkToolchain);
54+
55+
plugin.setConfiguration(config);
56+
57+
Xpp3Dom goalConfig = ExecuteMojoUtil.getPluginGoalConfig(plugin, "integration-test", new SystemStreamLog());
58+
Xpp3Dom jdkToolchainChild = goalConfig.getChild("jdkToolchain");
59+
Xpp3Dom versionChild = jdkToolchainChild.getChild("version");
60+
61+
assertNotNull("jdkToolchain element should be preserved for maven-failsafe-plugin:integration-test", jdkToolchainChild);
62+
assertNotNull("version child should be present under jdkToolchain", versionChild);
63+
assertEquals("11", versionChild.getValue());
64+
}
65+
}

0 commit comments

Comments
 (0)