Migration to JUnit 5 - avoid using AbstractMojoTestCase
it finishes migration
also:
- refactor MavenProjectResourcesStub - remove not needed additional stubs and not used methods
- remove not used test resources
diff --git a/pom.xml b/pom.xml
index ef908f7..a281da3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -105,11 +105,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.eclipse.sisu</groupId>
- <artifactId>org.eclipse.sisu.plexus</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<scope>test</scope>
@@ -142,29 +137,12 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.maven.resolver</groupId>
- <artifactId>maven-resolver-api</artifactId>
- <version>1.9.24</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
diff --git a/src/test/java/org/apache/maven/plugins/resources/ResourcesMojoTest.java b/src/test/java/org/apache/maven/plugins/resources/ResourcesMojoTest.java
index ba13678..65833fc 100644
--- a/src/test/java/org/apache/maven/plugins/resources/ResourcesMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/resources/ResourcesMojoTest.java
@@ -18,42 +18,66 @@
*/
package org.apache.maven.plugins.resources;
+import javax.inject.Inject;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
-import java.util.Collections;
import java.util.LinkedList;
-import java.util.List;
import java.util.Properties;
+import org.apache.maven.api.di.Provides;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoParameter;
+import org.apache.maven.api.plugin.testing.MojoTest;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.plugins.resources.stub.MavenProjectResourcesStub;
+import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
-public class ResourcesMojoTest extends AbstractMojoTestCase {
- private final String defaultPomFilePath = "/target/test-classes/unit/resources-test/plugin-config.xml";
+import static org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@MojoTest
+class ResourcesMojoTest {
+
+ @TempDir
+ private File testRootDir;
+
+ @Inject
+ private MavenProject projectStub;
+
+ @Inject
+ private MavenSession mavenSession;
+
+ @Provides
+ @SuppressWarnings("unused")
+ private MavenProject projectStub() {
+ return new MavenProjectResourcesStub(testRootDir.getAbsolutePath());
+ }
/**
* test mojo lookup, test harness should be working fine
*/
- public void testHarnessEnvironment() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
-
+ @Test
+ @InjectMojo(goal = "resources")
+ void testHarnessEnvironment(ResourcesMojo mojo) {
assertNotNull(mojo);
}
- public void testResourceDirectoryStructure() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("resourceDirectoryStructure");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ void testResourceDirectoryStructure(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
assertNotNull(mojo);
@@ -64,12 +88,6 @@
project.addFile("notpackage/test/file2.txt");
project.setupBuildEnvironment();
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
- setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
mojo.execute();
String resourcesDir = project.getOutputDirectory();
@@ -81,15 +99,14 @@
assertTrue(FileUtils.fileExists(resourcesDir + "/notpackage/test"));
}
- public void testResourceDirectoryStructureRelativePath() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("resourceDirectoryStructure_RelativePath");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ @MojoParameter(name = "outputDirectory", value = "../relative_dir")
+ void testResourceDirectoryStructureRelativePath(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
assertNotNull(mojo);
- project.setOutputDirectory("../relative_dir");
project.addFile("file4.txt");
project.addFile("package/file3.nottest");
project.addFile("notpackage/file1.include");
@@ -97,15 +114,9 @@
project.addFile("notpackage/test/file2.txt");
project.setupBuildEnvironment();
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
mojo.execute();
- String resourcesDir = project.getOutputDirectory();
+ String resourcesDir = mojo.getOutputDirectory().getAbsolutePath();
assertTrue(FileUtils.fileExists(resourcesDir + "/file4.txt"));
assertTrue(FileUtils.fileExists(resourcesDir + "/package/file3.nottest"));
@@ -114,11 +125,11 @@
assertTrue(FileUtils.fileExists(resourcesDir + "/notpackage/test"));
}
- public void testResourceEncoding() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("encoding");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ @MojoParameter(name = "encoding", value = "UTF-8")
+ void testResourceEncoding(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
assertNotNull(mojo);
@@ -126,13 +137,6 @@
project.setResourceFiltering(0, true);
project.setupBuildEnvironment();
- setVariableValueToObject(mojo, "encoding", "UTF-8");
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
- setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
mojo.execute();
String resourcesDir = project.getOutputDirectory();
@@ -140,11 +144,10 @@
assertTrue(FileUtils.fileExists(resourcesDir + "/file4.txt"));
}
- public void testResourceInclude() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("resourceInclude");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ void testResourceInclude(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
assertNotNull(mojo);
@@ -171,12 +174,6 @@
project.addInclude("**/test/file*");
project.addInclude("**/package/*.include");
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
mojo.execute();
String resourcesDir = project.getOutputDirectory();
@@ -188,11 +185,10 @@
assertFalse(FileUtils.fileExists(resourcesDir + "/notpackage/nottest/file.txt"));
}
- public void testResourceExclude() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("resourceExclude");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ void testResourceExclude(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
assertNotNull(mojo);
@@ -220,12 +216,6 @@
project.addExclude("**/notpackage*");
project.addExclude("**/notpackage*/**");
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
mojo.execute();
String resourcesDir = project.getOutputDirectory();
@@ -237,14 +227,10 @@
assertFalse(FileUtils.fileExists(resourcesDir + "/notpackage/nottest/file.txt"));
}
- /**
- * @throws Exception
- */
- public void testResourceTargetPath() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("resourceTargetPath");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ void testResourceTargetPath(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
assertNotNull(mojo);
@@ -257,12 +243,6 @@
project.addFile("notpackage/test/file2.txt");
project.setupBuildEnvironment();
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
mojo.execute();
String resourcesDir = project.getOutputDirectory();
@@ -274,14 +254,10 @@
assertTrue(FileUtils.fileExists(resourcesDir + "/org/apache/maven/plugin/test/notpackage/test"));
}
- /**
- * @throws Exception
- */
- public void testResourceSystemPropertiesFiltering() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("resourceSystemProperties_Filtering");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ void testResourceSystemPropertiesFiltering(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
assertNotNull(mojo);
@@ -289,20 +265,11 @@
project.setResourceFiltering(0, true);
project.setupBuildEnvironment();
- // setVariableValueToObject(mojo,"encoding","UTF-8");
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
- setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
- setVariableValueToObject(mojo, "escapeWindowsPaths", Boolean.TRUE);
-
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
request.setSystemProperties(System.getProperties());
- MavenSession mavenSession = new MavenSession(null, null, request, null);
- setVariableValueToObject(mojo, "session", mavenSession);
+ mavenSession.getSystemProperties().putAll(System.getProperties());
+
mojo.execute();
String resourcesDir = project.getOutputDirectory();
@@ -316,18 +283,14 @@
}
File fileFromFiltering = new File(props.getProperty("current-working-directory"));
- assertTrue(fileFromFiltering.getAbsolutePath() + " does not exist.", fileFromFiltering.exists());
+ assertTrue(fileFromFiltering.exists(), fileFromFiltering.getAbsolutePath() + " does not exist.");
assertEquals(userDir.getAbsolutePath(), fileFromFiltering.getAbsolutePath());
}
- /**
- * @throws Exception
- */
- public void testResourceProjectPropertiesFiltering() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("resourceProjectProperties_Filtering");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ void testResourceProjectPropertiesFiltering(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
assertNotNull(mojo);
@@ -336,13 +299,6 @@
project.addProperty("user.dir", "FPJ kami!!!");
project.setupBuildEnvironment();
- // setVariableValueToObject(mojo,"encoding","UTF-8");
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
- setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
mojo.execute();
String resourcesDir = project.getOutputDirectory();
@@ -351,15 +307,10 @@
assertContent(resourcesDir + "/file4.txt", checkString);
}
- /**
- * @throws Exception
- */
- public void testProjectPropertyFilteringPropertyDestination() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project =
- new MavenProjectResourcesStub("resourcePojectProperty_Filtering_PropertyDestination");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ void testProjectPropertyFilteringPropertyDestination(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
assertNotNull(mojo);
@@ -370,14 +321,6 @@
// setup dummy property
project.setDescription("c:\\\\org\\apache\\test");
- // setVariableValueToObject(mojo,"encoding","UTF-8");
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
- setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
- setVariableValueToObject(mojo, "escapeWindowsPaths", Boolean.TRUE);
mojo.execute();
String resourcesDir = project.getOutputDirectory();
@@ -386,14 +329,10 @@
assertContent(resourcesDir + "/file4.properties", checkString);
}
- /**
- * @throws Exception
- */
- public void testPropertyFilesFiltering() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("resourcePropertyFiles_Filtering");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ void testPropertyFilesFiltering(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
LinkedList<String> filterList = new LinkedList<>();
assertNotNull(mojo);
@@ -404,13 +343,8 @@
project.setupBuildEnvironment();
filterList.add(project.getResourcesDirectory() + "filter.properties");
- // setVariableValueToObject(mojo,"encoding","UTF-8");
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
setVariableValueToObject(mojo, "buildFilters", filterList);
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
+
mojo.execute();
String resourcesDir = project.getOutputDirectory();
@@ -419,14 +353,10 @@
assertContent(resourcesDir + "/file4.properties", checkString);
}
- /**
- * @throws Exception
- */
- public void testPropertyFilesExtra() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("resourcePropertyFiles_Extra");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ void testPropertyFilesExtra(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
LinkedList<String> filterList = new LinkedList<>();
assertNotNull(mojo);
@@ -437,13 +367,8 @@
project.setupBuildEnvironment();
filterList.add(project.getResourcesDirectory() + "filter.properties");
- // setVariableValueToObject(mojo,"encoding","UTF-8");
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
setVariableValueToObject(mojo, "filters", filterList);
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
+
mojo.execute();
String resourcesDir = project.getOutputDirectory();
@@ -452,14 +377,10 @@
assertContent(resourcesDir + "/extra.properties", checkString);
}
- /**
- * @throws Exception
- */
- public void testPropertyFilesMainAndExtra() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("resourcePropertyFiles_MainAndExtra");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ void testPropertyFilesMainAndExtra(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
LinkedList<String> filterList = new LinkedList<>();
LinkedList<String> extraFilterList = new LinkedList<>();
@@ -470,20 +391,14 @@
project.addFile("extra-filter.properties", "dir2:testdir2");
project.setResourceFiltering(0, true);
- project.cleanBuildEnvironment();
project.setupBuildEnvironment();
filterList.add(project.getResourcesDirectory() + "filter.properties");
extraFilterList.add(project.getResourcesDirectory() + "extra-filter.properties");
- // setVariableValueToObject(mojo,"encoding","UTF-8");
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
setVariableValueToObject(mojo, "buildFilters", filterList);
setVariableValueToObject(mojo, "filters", extraFilterList);
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
+
mojo.execute();
String resourcesDir = project.getOutputDirectory();
@@ -496,15 +411,11 @@
/**
* Validates that a Filter token containing a project property will be resolved before the Filter is applied to the
* resources.
- *
- * @throws Exception
*/
- public void testPropertyFilesFilteringTokensInFilters() throws Exception {
- final File testPom = new File(getBasedir(), defaultPomFilePath);
- final ResourcesMojo mojo = lookupMojo("resources", testPom);
- final MavenProjectResourcesStub project =
- new MavenProjectResourcesStub("resourcePropertyFiles_Filtering_TokensInFilters");
- final List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ void testPropertyFilesFilteringTokensInFilters(ResourcesMojo mojo) throws Exception {
+ final MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
final LinkedList<String> filterList = new LinkedList<>();
assertNotNull(mojo);
@@ -516,13 +427,8 @@
project.setupBuildEnvironment();
filterList.add(project.getResourcesDirectory() + "filter.properties");
- // setVariableValueToObject(mojo,"encoding","UTF-8");
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
setVariableValueToObject(mojo, "buildFilters", filterList);
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
+
mojo.execute();
final String resourcesDir = project.getOutputDirectory();
@@ -531,11 +437,11 @@
assertContent(resourcesDir + "/file4.properties", checkString);
}
- public void testWindowsPathEscapingDisabled() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("windows-paths");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ @MojoParameter(name = "escapeWindowsPaths", value = "false")
+ void testWindowsPathEscapingDisabled(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
assertNotNull(mojo);
@@ -545,17 +451,8 @@
project.addFile("path-listing.txt", "base path is ${basePath}\ndocuments path is ${docsPath}");
project.setResourceFiltering(0, true);
- project.cleanBuildEnvironment();
project.setupBuildEnvironment();
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
- setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
- setVariableValueToObject(mojo, "escapeWindowsPaths", Boolean.FALSE);
-
mojo.execute();
String resourcesDir = project.getOutputDirectory();
@@ -567,11 +464,11 @@
FileUtils.fileRead(new File(resourcesDir, "path-listing.txt")));
}
- public void testWindowsPathEscapingEnabled() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("resources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("windows-paths");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "resources")
+ @MojoParameter(name = "escapeWindowsPaths", value = "true")
+ void testWindowsPathEscapingEnabled(ResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
assertNotNull(mojo);
@@ -581,18 +478,8 @@
project.addFile("path-listing.txt", "base path is ${basePath}\ndocuments path is ${docsPath}");
project.setResourceFiltering(0, true);
- project.cleanBuildEnvironment();
project.setupBuildEnvironment();
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getOutputDirectory()));
- setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
-
- setVariableValueToObject(mojo, "escapeWindowsPaths", Boolean.TRUE);
-
mojo.execute();
String resourcesDir = project.getOutputDirectory();
diff --git a/src/test/java/org/apache/maven/plugins/resources/TestResourcesTest.java b/src/test/java/org/apache/maven/plugins/resources/TestResourcesTest.java
index 2647b14..4836376 100644
--- a/src/test/java/org/apache/maven/plugins/resources/TestResourcesTest.java
+++ b/src/test/java/org/apache/maven/plugins/resources/TestResourcesTest.java
@@ -18,33 +18,50 @@
*/
package org.apache.maven.plugins.resources;
+import javax.inject.Inject;
+
import java.io.File;
-import java.util.Collections;
-import java.util.List;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.api.di.Provides;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoTest;
import org.apache.maven.plugins.resources.stub.MavenProjectResourcesStub;
+import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
-public class TestResourcesTest extends AbstractMojoTestCase {
- private final String defaultPomFilePath = "/target/test-classes/unit/resources-test/plugin-config.xml";
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@MojoTest
+class TestResourcesTest {
+
+ @TempDir
+ private File testRootDir;
+
+ @Inject
+ private MavenProject projectStub;
+
+ @Provides
+ @SuppressWarnings("unused")
+ private MavenProject projectStub() throws Exception {
+ return new MavenProjectResourcesStub(testRootDir.getAbsolutePath());
+ }
/**
* test mojo lookup, test harness should be working fine
*/
- public void testHarnessEnvironment() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- ResourcesMojo mojo = lookupMojo("testResources", testPom);
-
+ @Test
+ @InjectMojo(goal = "testResources")
+ void testHarnessEnvironment(TestResourcesMojo mojo) {
assertNotNull(mojo);
}
- public void testTestResourceDirectoryCreation() throws Exception {
- File testPom = new File(getBasedir(), defaultPomFilePath);
- TestResourcesMojo mojo = lookupMojo("testResources", testPom);
- MavenProjectResourcesStub project = new MavenProjectResourcesStub("testResourceDirectoryStructure");
- List<Resource> resources = project.getBuild().getResources();
+ @Test
+ @InjectMojo(goal = "testResources")
+ void testTestResourceDirectoryCreation(TestResourcesMojo mojo) throws Exception {
+ MavenProjectResourcesStub project = (MavenProjectResourcesStub) this.projectStub;
assertNotNull(mojo);
@@ -55,20 +72,14 @@
project.addFile("notpackage/test/file2.txt");
project.setupBuildEnvironment();
- setVariableValueToObject(mojo, "project", project);
- setVariableValueToObject(mojo, "resources", resources);
- setVariableValueToObject(
- mojo, "outputDirectory", new File(project.getBuild().getTestOutputDirectory()));
- setVariableValueToObject(mojo, "buildFilters", Collections.emptyList());
- setVariableValueToObject(mojo, "useBuildFilters", Boolean.TRUE);
mojo.execute();
- String resorucesDir = project.getTestOutputDirectory();
+ String resourcesDir = project.getTestOutputDirectory();
- assertTrue(FileUtils.fileExists(resorucesDir + "/file4.txt"));
- assertTrue(FileUtils.fileExists(resorucesDir + "/package/file3.nottest"));
- assertTrue(FileUtils.fileExists(resorucesDir + "/notpackage/file1.include"));
- assertTrue(FileUtils.fileExists(resorucesDir + "/package/test"));
- assertTrue(FileUtils.fileExists(resorucesDir + "/notpackage/test"));
+ assertTrue(FileUtils.fileExists(resourcesDir + "/file4.txt"));
+ assertTrue(FileUtils.fileExists(resourcesDir + "/package/file3.nottest"));
+ assertTrue(FileUtils.fileExists(resourcesDir + "/notpackage/file1.include"));
+ assertTrue(FileUtils.fileExists(resourcesDir + "/package/test"));
+ assertTrue(FileUtils.fileExists(resourcesDir + "/notpackage/test"));
}
}
diff --git a/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectBasicStub.java b/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectBasicStub.java
deleted file mode 100644
index adb6d88..0000000
--- a/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectBasicStub.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.plugins.resources.stub;
-
-import java.io.File;
-import java.util.Properties;
-
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.util.FileUtils;
-
-public class MavenProjectBasicStub extends MavenProjectStub {
- protected String identifier;
-
- protected String testRootDir;
-
- protected Properties properties;
-
- protected String description;
-
- public MavenProjectBasicStub(String id) {
- properties = new Properties();
- identifier = id;
- testRootDir = PlexusTestCase.getBasedir() + "/target/unit/test-dir/" + identifier;
-
- if (!FileUtils.fileExists(testRootDir)) {
- FileUtils.mkdir(testRootDir);
- }
- }
-
- public String getName() {
- return "Test Project " + identifier;
- }
-
- public void setDescription(String desc) {
- description = desc;
- }
-
- public String getDescription() {
- if (description == null) {
- return "this is a test project";
- } else {
- return description;
- }
- }
-
- public File getBasedir() {
- // create an isolated environment
- // see setupTestEnvironment for details
- return new File(testRootDir);
- }
-
- public String getGroupId() {
- return "org.apache.maven.plugin.test";
- }
-
- public String getArtifactId() {
- return "maven-resource-plugin-test#" + identifier;
- }
-
- public String getPackaging() {
- return "org.apache.maven.plugin.test";
- }
-
- public String getVersion() {
- return identifier;
- }
-
- public void addProperty(String key, String value) {
- properties.put(key, value);
- }
-
- public Properties getProperties() {
- return properties;
- }
-}
diff --git a/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectBuildStub.java b/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectBuildStub.java
deleted file mode 100644
index fb8beff..0000000
--- a/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectBuildStub.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.plugins.resources.stub;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.apache.maven.model.Build;
-import org.codehaus.plexus.util.FileUtils;
-
-import static org.apache.commons.io.FileUtils.deleteDirectory;
-
-public class MavenProjectBuildStub extends MavenProjectBasicStub {
- protected Build build;
-
- protected String srcDirectory;
-
- protected String targetDirectory;
-
- protected String buildDirectory;
-
- protected String outputDirectory;
-
- protected String testOutputDirectory;
-
- protected String resourcesDirectory;
-
- protected String testResourcesDirectory;
-
- protected String targetResourceDirectory;
-
- protected String targetTestResourcesDirectory;
-
- protected ArrayList<String> fileList;
-
- protected ArrayList<String> directoryList;
-
- protected HashMap<String, String> dataMap;
-
- public MavenProjectBuildStub(String key) throws Exception {
- super(key);
-
- build = new Build();
- fileList = new ArrayList<>();
- directoryList = new ArrayList<>();
- dataMap = new HashMap<>();
- setupBuild();
- }
-
- public void addDirectory(String name) {
- if (isValidPath(name)) {
- directoryList.add(name);
- }
- }
-
- public void setOutputDirectory(String dir) {
- outputDirectory = buildDirectory + "/" + dir;
- build.setOutputDirectory(outputDirectory);
- }
-
- public void addFile(String name) {
- if (isValidPath(name)) {
- fileList.add(name);
- }
- }
-
- public void addFile(String name, String data) {
- File fileName = new File(name);
-
- addFile(name);
- dataMap.put(fileName.getName(), data);
- }
-
- public String getOutputDirectory() {
- return outputDirectory;
- }
-
- public String getTestOutputDirectory() {
- return testOutputDirectory;
- }
-
- public String getResourcesDirectory() {
- return resourcesDirectory;
- }
-
- public String getTestResourcesDirectory() {
- return testResourcesDirectory;
- }
-
- public Build getBuild() {
- return build;
- }
-
- /**
- * returns true if the path is relative
- * and false if absolute
- * also returns false if it is relative to
- * the parent
- *
- * @param path
- * @return
- */
- private boolean isValidPath(String path) {
- return !path.startsWith("c:") && !path.startsWith("..") && !path.startsWith("/") && !path.startsWith("\\");
- }
-
- private void setupBuild() {
- // check getBasedir method for the exact path
- // we need to recreate the dir structure in
- // an isolated environment
- srcDirectory = testRootDir + "/src";
- buildDirectory = testRootDir + "/target";
- outputDirectory = buildDirectory + "/classes";
- testOutputDirectory = buildDirectory + "/test-classes";
- resourcesDirectory = srcDirectory + "/main/resources/";
- testResourcesDirectory = srcDirectory + "/test/resources/";
-
- build.setDirectory(buildDirectory);
- build.setOutputDirectory(outputDirectory);
- build.setTestOutputDirectory(testOutputDirectory);
- }
-
- public void cleanBuildEnvironment() throws Exception {
- if (FileUtils.fileExists(resourcesDirectory)) {
- deleteDirectory(new File(resourcesDirectory));
- }
-
- if (FileUtils.fileExists(testResourcesDirectory)) {
- deleteDirectory(new File(testResourcesDirectory));
- }
-
- if (FileUtils.fileExists(outputDirectory)) {
- deleteDirectory(new File(outputDirectory));
- }
-
- if (FileUtils.fileExists(testOutputDirectory)) {
- deleteDirectory(new File(testOutputDirectory));
- }
- }
-
- public void setupBuildEnvironment() throws Exception {
- // populate dummy resources and dummy test resources
-
- // setup src dir
- if (!FileUtils.fileExists(resourcesDirectory)) {
- FileUtils.mkdir(resourcesDirectory);
- }
-
- if (!FileUtils.fileExists(testResourcesDirectory)) {
- FileUtils.mkdir(testResourcesDirectory);
- }
-
- createDirectories(resourcesDirectory, testResourcesDirectory);
- createFiles(resourcesDirectory, testResourcesDirectory);
-
- // setup target dir
- if (!FileUtils.fileExists(outputDirectory)) {
- FileUtils.mkdir(outputDirectory);
- }
-
- if (!FileUtils.fileExists(testOutputDirectory)) {
- FileUtils.mkdir(testOutputDirectory);
- }
- }
-
- private void createDirectories(String parent, String testparent) {
- File currentDirectory;
-
- for (String directory : directoryList) {
- currentDirectory = new File(parent, "/" + directory);
-
- if (!currentDirectory.exists()) {
- currentDirectory.mkdirs();
- }
-
- // duplicate dir structure in test resources
- currentDirectory = new File(testparent, "/" + directory);
-
- if (!currentDirectory.exists()) {
- currentDirectory.mkdirs();
- }
- }
- }
-
- private void createFiles(String parent, String testparent) throws IOException {
- File currentFile;
-
- for (String file : fileList) {
- currentFile = new File(parent, file);
-
- // create the necessary parent directories
- // before we create the files
- if (!currentFile.getParentFile().exists()) {
- currentFile.getParentFile().mkdirs();
- }
-
- if (!currentFile.exists()) {
- try {
- currentFile.createNewFile();
- populateFile(currentFile);
- } catch (IOException io) {
- // TODO: handle exception
- }
- }
-
- // duplicate file in test resources
- currentFile = new File(testparent, file);
-
- if (!currentFile.getParentFile().exists()) {
- currentFile.getParentFile().mkdirs();
- }
-
- if (!currentFile.exists()) {
- currentFile.createNewFile();
- populateFile(currentFile);
- }
- }
- }
-
- private void populateFile(File file) throws IOException {
- String data = dataMap.get(file.getName());
-
- if ((data != null) && file.exists()) {
- try (FileOutputStream outputStream = new FileOutputStream(file)) {
- outputStream.write(data.getBytes());
- }
- }
- }
-}
diff --git a/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectResourcesStub.java b/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectResourcesStub.java
index e0c5420..882bdd4 100644
--- a/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectResourcesStub.java
+++ b/src/test/java/org/apache/maven/plugins/resources/stub/MavenProjectResourcesStub.java
@@ -19,19 +19,145 @@
package org.apache.maven.plugins.resources.stub;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Properties;
+import org.apache.maven.model.Build;
import org.apache.maven.model.Resource;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.FileUtils;
-public class MavenProjectResourcesStub extends MavenProjectBuildStub {
+public class MavenProjectResourcesStub extends MavenProject {
+ private String testRootDir;
- private File baseDir;
+ private Properties properties;
- public MavenProjectResourcesStub(String id) throws Exception {
- super(id);
+ private String description;
+
+ private Build build;
+
+ private String srcDirectory;
+
+ private String buildDirectory;
+
+ private String outputDirectory;
+
+ private String testOutputDirectory;
+
+ private String resourcesDirectory;
+
+ private String testResourcesDirectory;
+
+ private ArrayList<String> fileList;
+
+ private ArrayList<String> directoryList;
+
+ private HashMap<String, String> dataMap;
+
+ public MavenProjectResourcesStub(String testRootDir) {
+ this.testRootDir = testRootDir;
+ properties = new Properties();
+ build = new Build();
+ fileList = new ArrayList<>();
+ directoryList = new ArrayList<>();
+ dataMap = new HashMap<>();
+
+ if (!FileUtils.fileExists(testRootDir)) {
+ FileUtils.mkdir(testRootDir);
+ }
+
+ setupBuild();
+
setupResources();
setupTestResources();
}
+ public void addProperty(String key, String value) {
+ properties.put(key, value);
+ }
+
+ public void addFile(String name) {
+ if (isValidPath(name)) {
+ fileList.add(name);
+ }
+ }
+
+ public void addFile(String name, String data) {
+ File fileName = new File(name);
+
+ addFile(name);
+ dataMap.put(fileName.getName(), data);
+ }
+
+ public String getOutputDirectory() {
+ return outputDirectory;
+ }
+
+ public String getTestOutputDirectory() {
+ return testOutputDirectory;
+ }
+
+ public String getResourcesDirectory() {
+ return resourcesDirectory;
+ }
+
+ /**
+ * returns true if the path is relative
+ * and false if absolute
+ * also returns false if it is relative to
+ * the parent
+ */
+ private boolean isValidPath(String path) {
+ return !path.startsWith("c:") && !path.startsWith("..") && !path.startsWith("/") && !path.startsWith("\\");
+ }
+
+ private void setupBuild() {
+ // check getBasedir method for the exact path
+ // we need to recreate the dir structure in
+ // an isolated environment
+ srcDirectory = testRootDir + "/src";
+ buildDirectory = testRootDir + "/target";
+ outputDirectory = buildDirectory + "/classes";
+ testOutputDirectory = buildDirectory + "/test-classes";
+ resourcesDirectory = srcDirectory + "/main/resources/";
+ testResourcesDirectory = srcDirectory + "/test/resources/";
+
+ build.setDirectory(buildDirectory);
+ build.setOutputDirectory(outputDirectory);
+ build.setTestOutputDirectory(testOutputDirectory);
+
+ properties.setProperty("project.build.sourceEncoding", "UTF-8");
+ }
+
+ public void setupBuildEnvironment() throws Exception {
+ // populate dummy resources and dummy test resources
+
+ // setup src dir
+ if (!FileUtils.fileExists(resourcesDirectory)) {
+ FileUtils.mkdir(resourcesDirectory);
+ }
+
+ if (!FileUtils.fileExists(testResourcesDirectory)) {
+ FileUtils.mkdir(testResourcesDirectory);
+ }
+
+ createDirectories(resourcesDirectory, testResourcesDirectory);
+ createFiles(resourcesDirectory, testResourcesDirectory);
+
+ // setup target dir
+ if (!FileUtils.fileExists(outputDirectory)) {
+ FileUtils.mkdir(outputDirectory);
+ }
+
+ if (!FileUtils.fileExists(testOutputDirectory)) {
+ FileUtils.mkdir(testOutputDirectory);
+ }
+ }
+
public void addInclude(String pattern) {
build.getResources().get(0).addInclude(pattern);
}
@@ -40,42 +166,79 @@
build.getResources().get(0).addExclude(pattern);
}
- public void addTestInclude(String pattern) {
- build.getTestResources().get(0).addInclude(pattern);
- }
-
- public void addTestExclude(String pattern) {
- build.getTestResources().get(0).addExclude(pattern);
- }
-
public void setTargetPath(String path) {
build.getResources().get(0).setTargetPath(path);
}
- public void setTestTargetPath(String path) {
- build.getTestResources().get(0).setTargetPath(path);
- }
-
- public void setDirectory(String dir) {
- build.getResources().get(0).setDirectory(dir);
- }
-
- public void setTestDirectory(String dir) {
- build.getTestResources().get(0).setDirectory(dir);
- }
-
public void setResourceFiltering(int nIndex, boolean filter) {
if (build.getResources().size() > nIndex) {
build.getResources().get(nIndex).setFiltering(filter);
}
}
+ private void createDirectories(String parent, String testparent) {
+ File currentDirectory;
+
+ for (String directory : directoryList) {
+ currentDirectory = new File(parent, "/" + directory);
+
+ if (!currentDirectory.exists()) {
+ currentDirectory.mkdirs();
+ }
+
+ // duplicate dir structure in test resources
+ currentDirectory = new File(testparent, "/" + directory);
+
+ if (!currentDirectory.exists()) {
+ currentDirectory.mkdirs();
+ }
+ }
+ }
+
+ private void createFiles(String parent, String testparent) throws IOException {
+ File currentFile;
+
+ for (String file : fileList) {
+ currentFile = new File(parent, file);
+
+ // create the necessary parent directories
+ // before we create the files
+ if (!currentFile.getParentFile().exists()) {
+ currentFile.getParentFile().mkdirs();
+ }
+
+ if (!currentFile.exists()) {
+ currentFile.createNewFile();
+ populateFile(currentFile);
+ }
+
+ // duplicate file in test resources
+ currentFile = new File(testparent, file);
+
+ if (!currentFile.getParentFile().exists()) {
+ currentFile.getParentFile().mkdirs();
+ }
+
+ if (!currentFile.exists()) {
+ currentFile.createNewFile();
+ populateFile(currentFile);
+ }
+ }
+ }
+
+ private void populateFile(File file) throws IOException {
+ String data = dataMap.get(file.getName());
+
+ if ((data != null) && file.exists()) {
+ try (FileOutputStream outputStream = new FileOutputStream(file)) {
+ outputStream.write(data.getBytes());
+ }
+ }
+ }
+
private void setupResources() {
Resource resource = new Resource();
- // see MavenProjectBasicStub for details
- // of getBasedir
-
// setup default resources
resource.setDirectory(getBasedir().getPath() + "/src/main/resources");
resource.setFiltering(false);
@@ -86,9 +249,6 @@
private void setupTestResources() {
Resource resource = new Resource();
- // see MavenProjectBasicStub for details
- // of getBasedir
-
// setup default test resources
resource.setDirectory(getBasedir().getPath() + "/src/test/resources");
resource.setFiltering(false);
@@ -96,11 +256,42 @@
build.addTestResource(resource);
}
- public File getBaseDir() {
- return baseDir == null ? super.getBasedir() : baseDir;
+ @Override
+ public File getBasedir() {
+ return new File(testRootDir);
}
- public void setBaseDir(File baseDir) {
- this.baseDir = baseDir;
+ @Override
+ public Build getBuild() {
+ return build;
+ }
+
+ @Override
+ public Properties getProperties() {
+ return properties;
+ }
+
+ @Override
+ public void setDescription(String desc) {
+ description = desc;
+ }
+
+ @Override
+ public String getDescription() {
+ if (description == null) {
+ return "this is a test project";
+ } else {
+ return description;
+ }
+ }
+
+ @Override
+ public List<Resource> getTestResources() {
+ return build.getTestResources();
+ }
+
+ @Override
+ public List<Resource> getResources() {
+ return build.getResources();
}
}
diff --git a/src/test/resources/unit/reflectionproperties-test/plugin-config.xml b/src/test/resources/unit/reflectionproperties-test/plugin-config.xml
deleted file mode 100644
index 5ba188f..0000000
--- a/src/test/resources/unit/reflectionproperties-test/plugin-config.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <description>c:\root\home\my_dir</description>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <configuration>
- <encoding>UTF-8</encoding>
- <outputDirectory>${basedir}\target\test-classes\unit\reflectionproperties-test</outputDirectory>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/src/test/resources/unit/reflectionproperties-test/validation.properties b/src/test/resources/unit/reflectionproperties-test/validation.properties
deleted file mode 100644
index eb901e2..0000000
--- a/src/test/resources/unit/reflectionproperties-test/validation.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-project_property:description
-description:c\:\\root\\home\\my_dir
-outputDirectory:\\target\\test-classes\\unit\\reflectionproperties-test
-encoding:UTF-8
diff --git a/src/test/resources/unit/reflectionproperties-test/validation_escapebackslashinpath.properties b/src/test/resources/unit/reflectionproperties-test/validation_escapebackslashinpath.properties
deleted file mode 100644
index 8506968..0000000
--- a/src/test/resources/unit/reflectionproperties-test/validation_escapebackslashinpath.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-project_property:description
-description:c\\:\\\\root\\\\home\\\\my_dir
-outputDirectory:\\target\\test-classes\\unit\\reflectionproperties-test
-encoding:UTF-8
diff --git a/src/test/resources/unit/resources-test/plugin-config-absolute-path.xml b/src/test/resources/unit/resources-test/plugin-config-absolute-path.xml
deleted file mode 100644
index 1c7a918..0000000
--- a/src/test/resources/unit/resources-test/plugin-config-absolute-path.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <name>test2</name>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <configuration>
- <outputDirectory>/test-classes/unit/result-dir</outputDirectory>
- </configuration>
- </plugin>
- </plugins>
- <resources>
- <resource>
- <filtering>false</filtering>
- <directory>/src/test/resources/unit/test-dir</directory>
- <includes>
- **/*.include
- **/*.test
- </includes>
- <excludes>
- **/*.exclude
- **/*.nottest
- </excludes>
- </resource>
- </resources>
- </build>
-</project>
diff --git a/src/test/resources/unit/resources-test/plugin-config-relative-path.xml b/src/test/resources/unit/resources-test/plugin-config-relative-path.xml
deleted file mode 100644
index c442565..0000000
--- a/src/test/resources/unit/resources-test/plugin-config-relative-path.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <name>test3</name>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <configuration>
- <outputDirectory>/test-classes/unit/result-dir</outputDirectory>
- </configuration>
- </plugin>
- </plugins>
- <resources>
- <resource>
- <filtering>false</filtering>
- <directory>../src/test/resources/unit/test-dir</directory>
- <includes>
- **/*.include
- **/*.test
- </includes>
- <excludes>
- **/*.exclude
- **/*.nottest
- </excludes>
- </resource>
- </resources>
- </build>
-</project>
diff --git a/src/test/resources/unit/resources-test/plugin-config.xml b/src/test/resources/unit/resources-test/plugin-config.xml
deleted file mode 100644
index 3f1dc4c..0000000
--- a/src/test/resources/unit/resources-test/plugin-config.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <name>test1</name>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <configuration>
- <outputDirectory>/test-classes/unit/resources-test</outputDirectory>
- <encoding>UTF-8</encoding>
- </configuration>
- </plugin>
- </plugins>
- <resources>
- <resource>
- <filtering>false</filtering>
- <directory>/test/resources/unit/test-dir</directory>
- <includes>
- **/*.include
- **/*.test
- </includes>
- <excludes>
- **/**.exclude
- **/*.nottest
- </excludes>
- </resource>
- </resources>
- </build>
-</project>
diff --git a/src/test/resources/unit/resources-test/validation.properties b/src/test/resources/unit/resources-test/validation.properties
deleted file mode 100644
index 682076b..0000000
--- a/src/test/resources/unit/resources-test/validation.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-test1 : C\:\\Source\\maven_core\\plugins\\maven-resources-plugin\\target\\test-classes\\unit\\test-dir\\package\test
-test2 :
-test3 :