diff --git a/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java b/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java index aaec6b24..6e0be141 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java @@ -37,14 +37,14 @@ * @author Olivier Lamy * @since 22 nov. 07 */ -class InterpolationTest extends AbstractTestUtil { +class InterpolationTest { private MavenProject buildMavenProjectStub() { MavenProject project = new MavenProject(); project.setVersion("1.0-SNAPSHOT"); project.setArtifactId("foo"); project.setGroupId("bar"); - project.setFile(new File(getBasedir(), "pom.xml")); + project.setFile(new File(TestUtil.getBasedir(), "pom.xml")); Properties properties = new Properties(); properties.put("fooOnProject", "barOnProject"); project.getModel().setProperties(properties); @@ -56,7 +56,6 @@ private MavenProject buildMavenProjectStub() { @Test void testCompositeMap() { - Map properties = new HashMap<>(); properties.put("foo", "bar"); properties.put("version", "2.0-SNAPSHOT"); @@ -70,17 +69,17 @@ void testCompositeMap() { @Test void testPomInterpolation() throws Exception { - File interpolatedPomFile; InvokerMojo invokerMojo = new InvokerMojo(null, null, null, null); - setVariableValueToObject(invokerMojo, "project", buildMavenProjectStub()); - setVariableValueToObject(invokerMojo, "settings", new Settings()); + TestUtil.setVariableValueToObject(invokerMojo, "project", buildMavenProjectStub()); + TestUtil.setVariableValueToObject(invokerMojo, "settings", new Settings()); Properties properties = new Properties(); properties.put("foo", "bar"); properties.put("version", "2.0-SNAPSHOT"); - setVariableValueToObject(invokerMojo, "filterProperties", properties); - String dirPath = getBasedir() + File.separatorChar + "src" + File.separatorChar + "test" + File.separatorChar - + "resources" + File.separatorChar + "unit" + File.separatorChar + "interpolation"; - interpolatedPomFile = new File(getBasedir(), "target/interpolated-pom.xml"); + TestUtil.setVariableValueToObject(invokerMojo, "filterProperties", properties); + String dirPath = TestUtil.getBasedir() + File.separatorChar + "src" + File.separatorChar + "test" + + File.separatorChar + "resources" + File.separatorChar + "unit" + File.separatorChar + "interpolation"; + + File interpolatedPomFile = new File(TestUtil.getBasedir(), "target/interpolated-pom.xml"); invokerMojo.buildInterpolatedFile(new File(dirPath, "pom.xml"), interpolatedPomFile); try (Reader reader = new XmlStreamReader(interpolatedPomFile)) { String content = IOUtil.toString(reader); diff --git a/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java b/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java index 4a5d24d6..529e1f2e 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java @@ -27,13 +27,15 @@ import org.apache.maven.settings.Settings; import org.junit.jupiter.api.Test; +import static org.apache.maven.plugins.invoker.TestUtil.getBasedir; +import static org.apache.maven.plugins.invoker.TestUtil.setVariableValueToObject; import static org.assertj.core.api.Assertions.assertThat; /** * @author Olivier Lamy * @since 18 nov. 07 */ -class InvokerMojoTest extends AbstractTestUtil { +class InvokerMojoTest { private static final String DUMMY_PROJECT = "dummy" + File.separator + "pom.xml"; private static final String WITH_POM_DIR_PROJECT = "with-pom-project-dir" + File.separator + "pom.xml"; diff --git a/src/test/java/org/apache/maven/plugins/invoker/AbstractTestUtil.java b/src/test/java/org/apache/maven/plugins/invoker/TestUtil.java similarity index 80% rename from src/test/java/org/apache/maven/plugins/invoker/AbstractTestUtil.java rename to src/test/java/org/apache/maven/plugins/invoker/TestUtil.java index 2a2f791e..452b8ba9 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/AbstractTestUtil.java +++ b/src/test/java/org/apache/maven/plugins/invoker/TestUtil.java @@ -22,14 +22,16 @@ import org.codehaus.plexus.util.ReflectionUtils; -abstract class AbstractTestUtil { +class TestUtil { - protected String getBasedir() { + private TestUtil() {} + + static String getBasedir() { String path = System.getProperty("basedir"); return path != null ? path : new File("").getAbsolutePath(); } - protected void setVariableValueToObject(Object object, String filed, Object value) throws IllegalAccessException { - ReflectionUtils.setVariableValueInObject(object, filed, value); + static void setVariableValueToObject(Object object, String field, Object value) throws IllegalAccessException { + ReflectionUtils.setVariableValueInObject(object, field, value); } }