This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-doap-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new c3dc1a1 Migrate tests to JUnit5 - avoid using AbstractMojoTestCase,
PlexusTestCase
c3dc1a1 is described below
commit c3dc1a12ad5639c8121a0bc8e8aca33d67c1807d
Author: Slawomir Jaranowski <[email protected]>
AuthorDate: Fri Feb 13 19:49:07 2026 +0100
Migrate tests to JUnit5 - avoid using AbstractMojoTestCase, PlexusTestCase
---
pom.xml | 23 ++-
.../org/apache/maven/plugin/doap/DoapMojo.java | 6 +
.../org/apache/maven/plugin/doap/DoapMojoTest.java | 190 +++++++++------------
.../org/apache/maven/plugin/doap/DoapUtilTest.java | 82 ++++-----
.../plugin/doap/stubs/AsfDoapProjectStub.java | 116 -------------
.../maven/plugin/doap/stubs/DoapProjectStub.java | 119 -------------
.../asf-doap-configuration-plugin-config.xml | 6 +-
.../doap-configuration-plugin-config.xml | 6 +-
.../doap-extra-configuration-plugin-config.xml | 6 +-
9 files changed, 152 insertions(+), 402 deletions(-)
diff --git a/pom.xml b/pom.xml
index 5c5e34f..d70f123 100644
--- a/pom.xml
+++ b/pom.xml
@@ -167,11 +167,6 @@ under the License.
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.sisu</groupId>
- <artifactId>org.eclipse.sisu.plexus</artifactId>
- <version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -200,9 +195,8 @@ under the License.
<!-- test -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.2</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -211,6 +205,12 @@ under the License.
<version>3.5.1</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ <version>2.1.0</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-connector-basic</artifactId>
@@ -224,9 +224,9 @@ under the License.
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.maven.resolver</groupId>
- <artifactId>maven-resolver-transport-http</artifactId>
- <version>${resolverVersion}</version>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-http-lightweight</artifactId>
+ <version>3.5.3</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -289,7 +289,6 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
- <version>3.9.1</version>
<configuration>
<goals>
<goal>clean</goal>
diff --git a/src/main/java/org/apache/maven/plugin/doap/DoapMojo.java
b/src/main/java/org/apache/maven/plugin/doap/DoapMojo.java
index 2ef6883..b11c07f 100644
--- a/src/main/java/org/apache/maven/plugin/doap/DoapMojo.java
+++ b/src/main/java/org/apache/maven/plugin/doap/DoapMojo.java
@@ -1374,6 +1374,12 @@ public class DoapMojo extends AbstractMojo {
DoapUtil.writeElement(writer, doapOptions.getXmlnsPrefix(),
"file-release", fileRelease);
Date releaseDate = null;
+
+ // If the last updated date is not available, skip it
+ if (metadata.getMetadata().getVersioning().getLastUpdated() ==
null) {
+ continue;
+ }
+
try {
releaseDate = REPOSITORY_DATE_FORMAT.parse(
metadata.getMetadata().getVersioning().getLastUpdated());
diff --git a/src/test/java/org/apache/maven/plugin/doap/DoapMojoTest.java
b/src/test/java/org/apache/maven/plugin/doap/DoapMojoTest.java
index b10e463..6edbe8c 100644
--- a/src/test/java/org/apache/maven/plugin/doap/DoapMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/doap/DoapMojoTest.java
@@ -18,49 +18,66 @@
*/
package org.apache.maven.plugin.doap;
+import javax.inject.Inject;
+
import java.io.File;
-import java.io.FileReader;
import java.io.IOException;
-
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+
+import org.apache.maven.api.plugin.testing.Basedir;
+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.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.doap.options.DoapArtifact;
import org.apache.maven.plugin.doap.options.DoapOptions;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.fail;
+import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir;
+import static org.apache.maven.api.plugin.testing.MojoExtension.getTestFile;
+import static
org.apache.maven.api.plugin.testing.MojoExtension.getVariableValueFromObject;
+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.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Test {@link DoapMojo} class.
*
* @author <a href="mailto:[email protected]">Vincent Siveton</a>
*/
-public class DoapMojoTest extends AbstractMojoTestCase {
+@MojoTest(realRepositorySession = true)
+class DoapMojoTest {
+
+ @Inject
+ private MavenProject mavenProject;
/**
* Verify the generation of a pure DOAP file.
*
* @throws Exception if any
*/
- public void testGeneratedDoap() throws Exception {
- File pluginXmlFile = new File(
- getBasedir(),
"src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml");
- DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
- assertNotNull("Mojo found.", mojo);
-
- MavenProject mavenProject = getVariableValueFromObject(mojo,
"project");
- assertNotNull(mavenProject);
-
- // Set some Mojo parameters
- setVariableValueToObject(mojo, "remoteRepositories",
mavenProject.getRemoteArtifactRepositories());
+ @Test
+ @InjectMojo(goal = "generate", pom =
"doap-configuration-plugin-config.xml")
+ @Basedir("/unit/doap-configuration/")
+ void testGeneratedDoap(DoapMojo mojo) throws Exception {
+ MavenXpp3Reader pomReader = new MavenXpp3Reader();
+ try (InputStream in = Files.newInputStream(
+ getTestFile("doap-configuration-plugin-config.xml").toPath()))
{
+ mavenProject.setModel(pomReader.read(in));
+ }
setVariableValueToObject(mojo, "about", mavenProject.getUrl());
mojo.execute();
- File doapFile = new File(getBasedir(),
"target/test/unit/doap-configuration/doap-configuration.rdf");
- assertTrue("Doap File was not generated!", doapFile.exists());
+ File doapFile = new File(getBasedir(),
"target/doap-configuration.rdf");
+ assertTrue(doapFile.exists(), "Doap File was not generated!");
String readed = readFile(doapFile);
@@ -124,43 +141,37 @@ public class DoapMojoTest extends AbstractMojoTestCase {
/**
* @throws Exception if any
*/
- public void testLangParameter() throws Exception {
- File pluginXmlFile = new File(
- getBasedir(),
"src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml");
- DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
- assertNotNull("Mojo found.", mojo);
-
- MavenProject mavenProject = getVariableValueFromObject(mojo,
"project");
- assertNotNull(mavenProject);
-
- // check invalid lang
- setVariableValueToObject(mojo, "remoteRepositories",
mavenProject.getRemoteArtifactRepositories());
- setVariableValueToObject(mojo, "lang", "foo");
-
+ @Test
+ @InjectMojo(goal = "generate", pom =
"doap-configuration-plugin-config.xml")
+ @MojoParameter(name = "lang", value = "foo")
+ @Basedir("/unit/doap-configuration/")
+ void testLangParameter(DoapMojo mojo) throws Exception {
try {
mojo.execute();
fail("No lang checked");
} catch (MojoExecutionException ex) {
- assertNotNull(ex.getMessage());
+ assertEquals(
+ "The <doapOptions><lang>foo</lang></doapOptions> parameter
is not a valid ISO language.",
+ ex.getMessage());
}
}
/**
* @throws Exception if any
*/
- public void testAboutParameter() throws Exception {
- File pluginXmlFile = new File(
- getBasedir(),
"src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml");
- DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
- assertNotNull("Mojo found.", mojo);
+ @Test
+ @InjectMojo(goal = "generate", pom =
"doap-configuration-plugin-config.xml")
+ @MojoParameter(name = "about", value = "http://foo/about")
+ @Basedir("/unit/doap-configuration/")
+ void testAboutParameter(DoapMojo mojo) throws Exception {
- MavenProject mavenProject = getVariableValueFromObject(mojo,
"project");
- assertNotNull(mavenProject);
+ mojo.execute();
- setVariableValueToObject(mojo, "remoteRepositories",
mavenProject.getRemoteArtifactRepositories());
- setVariableValueToObject(mojo, "about", "foo");
+ File doapFile = new File(getBasedir(),
"target/doap-configuration.rdf");
+ assertTrue(doapFile.exists(), "Doap File was not generated!");
- mojo.execute();
+ String readed = readFile(doapFile);
+ assertTrue(readed.contains("<Project
rdf:about=\"http://foo/about\">"));
}
/**
@@ -168,19 +179,11 @@ public class DoapMojoTest extends AbstractMojoTestCase {
*
* @throws Exception if any
*/
- public void testGeneratedDoapArtifact() throws Exception {
- File pluginXmlFile = new File(
- getBasedir(),
"src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml");
- DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
- assertNotNull("Mojo found.", mojo);
-
- MavenProject mavenProject = getVariableValueFromObject(mojo,
"project");
- assertNotNull(mavenProject);
-
- // Set some Mojo parameters
- setVariableValueToObject(mojo, "remoteRepositories",
mavenProject.getRemoteArtifactRepositories());
- setVariableValueToObject(mojo, "about", mavenProject.getUrl());
- DoapOptions doapOptions = (DoapOptions)
getVariableValueFromObject(mojo, "doapOptions");
+ @Test
+ @InjectMojo(goal = "generate", pom =
"doap-configuration-plugin-config.xml")
+ @Basedir("/unit/doap-configuration/")
+ void testGeneratedDoapArtifact(DoapMojo mojo) throws Exception {
+ DoapOptions doapOptions = getVariableValueFromObject(mojo,
"doapOptions");
doapOptions.setDescription("Common Utilities");
doapOptions.setShortdesc("Common Utilities");
doapOptions.setDownloadPage("http://plexus.codehaus.org/download-binaries.html");
@@ -191,12 +194,11 @@ public class DoapMojoTest extends AbstractMojoTestCase {
artifact.setArtifactId("plexus-utils");
artifact.setVersion("1.5.5");
setVariableValueToObject(mojo, "artifact", artifact);
- setVariableValueToObject(mojo, "outputDirectory",
"target/test/unit/doap-configuration/");
mojo.execute();
- File doapFile = new File(getBasedir(),
"target/test/unit/doap-configuration/doap_plexus-utils.rdf");
- assertTrue("Doap File was not generated!", doapFile.exists());
+ File doapFile = new File(getBasedir(), "target/doap_plexus-utils.rdf");
+ assertTrue(doapFile.exists(), "Doap File was not generated!");
String readed = readFile(doapFile);
@@ -245,18 +247,10 @@ public class DoapMojoTest extends AbstractMojoTestCase {
*
* @throws Exception if any
*/
- public void testGeneratedDoapArtifactMinimalist() throws Exception {
- File pluginXmlFile = new File(
- getBasedir(),
"src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml");
- DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
- assertNotNull("Mojo found.", mojo);
-
- MavenProject mavenProject = getVariableValueFromObject(mojo,
"project");
- assertNotNull(mavenProject);
-
- // Set some Mojo parameters
- setVariableValueToObject(mojo, "remoteRepositories",
mavenProject.getRemoteArtifactRepositories());
- setVariableValueToObject(mojo, "about", "foo");
+ @Test
+ @InjectMojo(goal = "generate", pom =
"doap-configuration-plugin-config.xml")
+ @Basedir("/unit/doap-configuration/")
+ void testGeneratedDoapArtifactMinimalist(DoapMojo mojo) throws Exception {
DoapOptions doapOptions = new DoapOptions();
doapOptions.setName("XStream");
doapOptions.setDescription("XStream is a simple library to serialize
objects to XML and back again.");
@@ -275,12 +269,11 @@ public class DoapMojoTest extends AbstractMojoTestCase {
artifact.setArtifactId("xstream");
artifact.setVersion("1.1");
setVariableValueToObject(mojo, "artifact", artifact);
- setVariableValueToObject(mojo, "outputDirectory",
"target/test/unit/doap-configuration/");
mojo.execute();
- File doapFile = new File(getBasedir(),
"target/test/unit/doap-configuration/doap_xstream.rdf");
- assertTrue("Doap File was not generated!", doapFile.exists());
+ File doapFile = new File(getBasedir(), "target/doap_xstream.rdf");
+ assertTrue(doapFile.exists(), "Doap File was not generated!");
String readed = readFile(doapFile);
@@ -323,24 +316,21 @@ public class DoapMojoTest extends AbstractMojoTestCase {
*
* @throws Exception if any
*/
- public void testGeneratedDoapForASF() throws Exception {
- File pluginXmlFile = new File(
- getBasedir(),
-
"src/test/resources/unit/asf-doap-configuration/asf-doap-configuration-plugin-config.xml");
- DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
- assertNotNull("Mojo found.", mojo);
-
- MavenProject mavenProject = getVariableValueFromObject(mojo,
"project");
- assertNotNull(mavenProject);
-
- // Set some Mojo parameters
- setVariableValueToObject(mojo, "remoteRepositories",
mavenProject.getRemoteArtifactRepositories());
+ @Test
+ @InjectMojo(goal = "generate", pom =
"asf-doap-configuration-plugin-config.xml")
+ @Basedir("/unit/asf-doap-configuration/")
+ void testGeneratedDoapForASF(DoapMojo mojo) throws Exception {
+ MavenXpp3Reader pomReader = new MavenXpp3Reader();
+ try (InputStream in = Files.newInputStream(
+
getTestFile("asf-doap-configuration-plugin-config.xml").toPath())) {
+ mavenProject.setModel(pomReader.read(in));
+ }
setVariableValueToObject(mojo, "about", mavenProject.getUrl());
mojo.execute();
- File doapFile = new File(getBasedir(),
"target/test/unit/asf-doap-configuration/asf-doap-configuration.rdf");
- assertTrue("Doap File was not generated!", doapFile.exists());
+ File doapFile = new File(getBasedir(),
"target/asf-doap-configuration.rdf");
+ assertTrue(doapFile.exists(), "Doap File was not generated!");
String readed = readFile(doapFile);
@@ -371,23 +361,15 @@ public class DoapMojoTest extends AbstractMojoTestCase {
*
* @throws Exception if any
*/
- public void testGeneratedExtraDoap() throws Exception {
- File pluginXmlFile = new File(
- getBasedir(),
"src/test/resources/unit/doap-configuration/doap-extra-configuration-plugin-config.xml");
- DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
- assertNotNull("Mojo found.", mojo);
-
- MavenProject mavenProject = getVariableValueFromObject(mojo,
"project");
- assertNotNull(mavenProject);
-
- // Set some Mojo parameters
- setVariableValueToObject(mojo, "remoteRepositories",
mavenProject.getRemoteArtifactRepositories());
- setVariableValueToObject(mojo, "about", mavenProject.getUrl());
+ @Test
+ @InjectMojo(goal = "generate", pom =
"doap-extra-configuration-plugin-config.xml")
+ @Basedir("/unit/doap-configuration/")
+ void testGeneratedExtraDoap(DoapMojo mojo) throws Exception {
mojo.execute();
- File doapFile = new File(getBasedir(),
"target/test/unit/doap-configuration/doap-extra-configuration.rdf");
- assertTrue("Doap File was not generated!", doapFile.exists());
+ File doapFile = new File(getBasedir(),
"target/doap-extra-configuration.rdf");
+ assertTrue(doapFile.exists(), "Doap File was not generated!");
String readed = readFile(doapFile);
@@ -397,8 +379,6 @@ public class DoapMojoTest extends AbstractMojoTestCase {
}
private String readFile(File file) throws IOException {
- try (FileReader reader = new FileReader(file)) {
- return IOUtil.toString(reader);
- }
+ return new String(Files.readAllBytes(file.toPath()),
StandardCharsets.UTF_8);
}
}
diff --git a/src/test/java/org/apache/maven/plugin/doap/DoapUtilTest.java
b/src/test/java/org/apache/maven/plugin/doap/DoapUtilTest.java
index 34a946a..ef9257d 100644
--- a/src/test/java/org/apache/maven/plugin/doap/DoapUtilTest.java
+++ b/src/test/java/org/apache/maven/plugin/doap/DoapUtilTest.java
@@ -18,6 +18,8 @@
*/
package org.apache.maven.plugin.doap;
+import javax.inject.Inject;
+
import java.io.File;
import java.io.StringWriter;
import java.util.ArrayList;
@@ -28,46 +30,51 @@ import org.apache.maven.model.Contributor;
import org.apache.maven.model.Developer;
import org.apache.maven.model.License;
import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.i18n.I18N;
+import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
+import org.junit.jupiter.api.Test;
+
+import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
+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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Test {@link DoapUtil} class.
*
* @author <a href="mailto:[email protected]">Vincent Siveton</a>
*/
-public class DoapUtilTest extends PlexusTestCase {
- /** {@inheritDoc} */
- protected void setUp() throws Exception {
- super.setUp();
- }
+@PlexusTest
+class DoapUtilTest {
- /** {@inheritDoc} */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+ @Inject
+ private I18N i18n;
/**
* Test method for {@link DoapUtil#writeElement(XMLWriter, String, String,
String)}.
*
* @throws Exception if any
*/
- public void testWriteElement() throws Exception {
+ @Test
+ void testWriteElement() throws Exception {
StringWriter w = new StringWriter();
XMLWriter writer = new PrettyPrintXMLWriter(w);
DoapUtil.writeElement(writer, null, "name", "value");
w.close();
- assertEquals(w.toString(), "<name>value</name>");
+ assertEquals("<name>value</name>", w.toString());
w = new StringWriter();
writer = new PrettyPrintXMLWriter(w);
try {
DoapUtil.writeElement(writer, null, null, null);
- assertTrue("Null not catched", false);
+ fail("Null not catched");
} catch (IllegalArgumentException e) {
- assertTrue("IllegalArgumentException catched", true);
+ assertTrue(true, "IllegalArgumentException catched");
} finally {
w.close();
}
@@ -78,20 +85,21 @@ public class DoapUtilTest extends PlexusTestCase {
*
* @throws Exception if any
*/
- public void testWriteRdfResourceElement() throws Exception {
+ @Test
+ void testWriteRdfResourceElement() throws Exception {
StringWriter w = new StringWriter();
XMLWriter writer = new PrettyPrintXMLWriter(w);
DoapUtil.writeRdfResourceElement(writer, null, "name", "value");
w.close();
- assertEquals(w.toString(), "<name " + DoapUtil.RDF_RESOURCE +
"=\"value\"/>");
+ assertEquals("<name " + DoapUtil.RDF_RESOURCE + "=\"value\"/>",
w.toString());
w = new StringWriter();
writer = new PrettyPrintXMLWriter(w);
try {
DoapUtil.writeRdfResourceElement(writer, null, null, null);
- assertTrue("Null not catched", false);
+ fail("Null not catched");
} catch (IllegalArgumentException e) {
- assertTrue("IllegalArgumentException catched", true);
+ assertTrue(true, "IllegalArgumentException catched");
} finally {
w.close();
}
@@ -107,12 +115,9 @@ public class DoapUtilTest extends PlexusTestCase {
* {@link DoapUtil#getContributorsWithTranslatorRole(I18N, List)}
* {@link DoapUtil#getContributorsWithUnknownRole(I18N, List)}
*
- * @throws Exception if any
*/
- public void testDevelopersOrContributorsByDoapRoles() throws Exception {
- I18N i18n = (I18N) getContainer().lookup(I18N.ROLE);
- assertNotNull(i18n);
- assertNotNull(i18n.getBundle());
+ @Test
+ void testDevelopersOrContributorsByDoapRoles() {
List<Contributor> developersOrContributors = new ArrayList<>();
@@ -179,18 +184,19 @@ public class DoapUtilTest extends PlexusTestCase {
.size();
dev.addRole(" Emeritus");
- assertTrue(DoapUtil.getContributorsWithUnknownRole(i18n,
developersOrContributors)
- .size()
- == sizeBeforeEmeritus);
+ assertEquals(
+ DoapUtil.getContributorsWithUnknownRole(i18n,
developersOrContributors)
+ .size(),
+ sizeBeforeEmeritus);
}
/**
* Test method for:
* {@link DoapUtil#validate(java.io.File)}
*
- * @throws Exception if any
*/
- public void testValidate() throws Exception {
+ @Test
+ void testValidate() {
File doapFile = new File(getBasedir(),
"src/test/resources/generated-doap-1.0.rdf");
assertFalse(DoapUtil.validate(doapFile).isEmpty());
}
@@ -199,9 +205,9 @@ public class DoapUtilTest extends PlexusTestCase {
* Test method for:
* {@link DoapUtil#interpolate(String, MavenProject,
org.apache.maven.settings.Settings)}
*
- * @throws Exception if any
*/
- public void testInterpolate() throws Exception {
+ @Test
+ void testInterpolate() {
License license = new License();
license.setName("licenseName");
license.setUrl("licenseUrl");
@@ -223,17 +229,17 @@ public class DoapUtilTest extends PlexusTestCase {
project.setDevelopers(developers);
project.getProperties().put("myKey", "myValue");
- assertEquals(DoapUtil.interpolate("${project.name}", project, null),
"projectName");
- assertEquals(DoapUtil.interpolate("my name is ${project.name}",
project, null), "my name is projectName");
+ assertEquals("projectName", DoapUtil.interpolate("${project.name}",
project, null));
+ assertEquals("my name is projectName", DoapUtil.interpolate("my name
is ${project.name}", project, null));
assertEquals(
- DoapUtil.interpolate("my name is ${project.invalid}", project,
null), "my name is ${project.invalid}");
- assertEquals(DoapUtil.interpolate("${pom.description}", project,
null), "projectDescription");
+ "my name is ${project.invalid}", DoapUtil.interpolate("my name
is ${project.invalid}", project, null));
+ assertEquals("projectDescription",
DoapUtil.interpolate("${pom.description}", project, null));
assertNull(DoapUtil.interpolate("${project.licenses.name}", project,
null));
- assertEquals(DoapUtil.interpolate("${project.licenses[0].name}",
project, null), "licenseName");
+ assertEquals("licenseName",
DoapUtil.interpolate("${project.licenses[0].name}", project, null));
assertNull(DoapUtil.interpolate("${project.licenses[1].name}",
project, null));
assertNotNull(DoapUtil.interpolate("${project.developers}", project,
null));
- assertEquals(DoapUtil.interpolate("${project.developers[0].name}",
project, null), "developerName1");
- assertEquals(DoapUtil.interpolate("${project.developers[1].name}",
project, null), "developerName2");
- assertEquals(DoapUtil.interpolate("${myKey}", project, null),
"myValue");
+ assertEquals("developerName1",
DoapUtil.interpolate("${project.developers[0].name}", project, null));
+ assertEquals("developerName2",
DoapUtil.interpolate("${project.developers[1].name}", project, null));
+ assertEquals("myValue", DoapUtil.interpolate("${myKey}", project,
null));
}
}
diff --git
a/src/test/java/org/apache/maven/plugin/doap/stubs/AsfDoapProjectStub.java
b/src/test/java/org/apache/maven/plugin/doap/stubs/AsfDoapProjectStub.java
deleted file mode 100644
index 0d7495c..0000000
--- a/src/test/java/org/apache/maven/plugin/doap/stubs/AsfDoapProjectStub.java
+++ /dev/null
@@ -1,116 +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.plugin.doap.stubs;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
-import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
-import org.apache.maven.model.Developer;
-import org.apache.maven.model.DistributionManagement;
-import org.apache.maven.model.IssueManagement;
-import org.apache.maven.model.License;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Organization;
-import org.apache.maven.model.Scm;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.codehaus.plexus.util.ReaderFactory;
-
-/**
- * @author <a href="mailto:[email protected]">Vincent Siveton</a>
- */
-public class AsfDoapProjectStub extends MavenProjectStub {
- private Model model;
-
- /**
- * Default constructor
- */
- public AsfDoapProjectStub() {
- MavenXpp3Reader pomReader = new MavenXpp3Reader();
- try {
- model = pomReader.read(ReaderFactory.newXmlReader(new File(
- new File(super.getBasedir(),
"/src/test/resources/unit/asf-doap-configuration/"),
- "asf-doap-configuration-plugin-config.xml")));
- setModel(model);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- setGroupId(model.getGroupId());
- setArtifactId(model.getArtifactId());
- setVersion(model.getVersion());
- setName(model.getName());
- setDescription(model.getDescription());
- setUrl(model.getUrl());
- setPackaging(model.getPackaging());
- setDevelopers(model.getDevelopers());
- }
-
- @Override
- public List<Developer> getDevelopers() {
- return model.getDevelopers();
- }
-
- @Override
- public List<License> getLicenses() {
- return model.getLicenses();
- }
-
- @Override
- public Organization getOrganization() {
- return model.getOrganization();
- }
-
- @Override
- public Scm getScm() {
- return model.getScm();
- }
-
- @Override
- public IssueManagement getIssueManagement() {
- return model.getIssueManagement();
- }
-
- @Override
- public String getDescription() {
- return model.getDescription();
- }
-
- @Override
- public String getInceptionYear() {
- return model.getInceptionYear();
- }
-
- @Override
- public DistributionManagement getDistributionManagement() {
- return model.getDistributionManagement();
- }
-
- @Override
- public List<ArtifactRepository> getRemoteArtifactRepositories() {
- ArtifactRepository repository = new DefaultArtifactRepository(
- "central", "https://repo.maven.apache.org/maven2", new
DefaultRepositoryLayout());
-
- return Collections.singletonList(repository);
- }
-}
diff --git
a/src/test/java/org/apache/maven/plugin/doap/stubs/DoapProjectStub.java
b/src/test/java/org/apache/maven/plugin/doap/stubs/DoapProjectStub.java
deleted file mode 100644
index b799fd2..0000000
--- a/src/test/java/org/apache/maven/plugin/doap/stubs/DoapProjectStub.java
+++ /dev/null
@@ -1,119 +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.plugin.doap.stubs;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
-import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
-import org.apache.maven.model.Developer;
-import org.apache.maven.model.DistributionManagement;
-import org.apache.maven.model.IssueManagement;
-import org.apache.maven.model.License;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Organization;
-import org.apache.maven.model.Scm;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.codehaus.plexus.util.ReaderFactory;
-import org.codehaus.plexus.util.xml.XmlStreamReader;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-/**
- * @author <a href="mailto:[email protected]">Vincent Siveton</a>
- */
-public class DoapProjectStub extends MavenProjectStub {
- private Model model;
-
- /**
- * Default constructor
- */
- public DoapProjectStub() {
- MavenXpp3Reader pomReader = new MavenXpp3Reader();
- try (XmlStreamReader reader = ReaderFactory.newXmlReader(new File(
- new File(super.getBasedir(),
"/src/test/resources/unit/doap-configuration/"),
- "doap-configuration-plugin-config.xml"))) {
- model = pomReader.read(reader);
- setModel(model);
- } catch (IOException | XmlPullParserException e) {
- throw new RuntimeException(e);
- }
-
- setGroupId(model.getGroupId());
- setArtifactId(model.getArtifactId());
- setVersion(model.getVersion());
- setName(model.getName());
- setDescription(model.getDescription());
- setUrl(model.getUrl());
- setPackaging(model.getPackaging());
- setDevelopers(model.getDevelopers());
- }
-
- @Override
- public List<Developer> getDevelopers() {
- return model.getDevelopers();
- }
-
- @Override
- public String getDescription() {
- return model.getDescription();
- }
-
- @Override
- public String getInceptionYear() {
- return model.getInceptionYear();
- }
-
- @Override
- public List<License> getLicenses() {
- return model.getLicenses();
- }
-
- @Override
- public Scm getScm() {
- return model.getScm();
- }
-
- @Override
- public IssueManagement getIssueManagement() {
- return model.getIssueManagement();
- }
-
- @Override
- public DistributionManagement getDistributionManagement() {
- return model.getDistributionManagement();
- }
-
- @Override
- public Organization getOrganization() {
- return model.getOrganization();
- }
-
- @Override
- public List<ArtifactRepository> getRemoteArtifactRepositories() {
- ArtifactRepository repository = new DefaultArtifactRepository(
- "central", "https://repo.maven.apache.org/maven2", new
DefaultRepositoryLayout());
-
- return Collections.singletonList(repository);
- }
-}
diff --git
a/src/test/resources/unit/asf-doap-configuration/asf-doap-configuration-plugin-config.xml
b/src/test/resources/unit/asf-doap-configuration/asf-doap-configuration-plugin-config.xml
index c511172..1e40d2e 100644
---
a/src/test/resources/unit/asf-doap-configuration/asf-doap-configuration-plugin-config.xml
+++
b/src/test/resources/unit/asf-doap-configuration/asf-doap-configuration-plugin-config.xml
@@ -81,10 +81,8 @@ under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-doap-plugin</artifactId>
<configuration>
- <project
implementation="org.apache.maven.plugin.doap.stubs.AsfDoapProjectStub"/>
- <localRepository>${localRepository}</localRepository>
-
<doapFile>target/test/unit/asf-doap-configuration/asf-doap-configuration.rdf</doapFile>
-
<outputDirectory>target/test/unit/asf-doap-configuration</outputDirectory>
+ <doapFile>target/asf-doap-configuration.rdf</doapFile>
+ <outputDirectory>target</outputDirectory>
<lang>en</lang>
<validate>true</validate>
diff --git
a/src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml
b/src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml
index 59cac7a..575ff94 100644
---
a/src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml
+++
b/src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml
@@ -82,10 +82,8 @@ under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-doap-plugin</artifactId>
<configuration>
- <project
implementation="org.apache.maven.plugin.doap.stubs.DoapProjectStub"/>
- <localRepository>${localRepository}</localRepository>
-
<doapFile>target/test/unit/doap-configuration/doap-configuration.rdf</doapFile>
-
<outputDirectory>target/test/unit/doap-configuration</outputDirectory>
+ <doapFile>target/doap-configuration.rdf</doapFile>
+ <outputDirectory>target</outputDirectory>
<lang>en</lang>
<validate>true</validate>
diff --git
a/src/test/resources/unit/doap-configuration/doap-extra-configuration-plugin-config.xml
b/src/test/resources/unit/doap-configuration/doap-extra-configuration-plugin-config.xml
index 9eb978c..23e1199 100644
---
a/src/test/resources/unit/doap-configuration/doap-extra-configuration-plugin-config.xml
+++
b/src/test/resources/unit/doap-configuration/doap-extra-configuration-plugin-config.xml
@@ -31,10 +31,8 @@ under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-doap-plugin</artifactId>
<configuration>
- <project
implementation="org.apache.maven.plugin.doap.stubs.DoapProjectStub"/>
- <localRepository>${localRepository}</localRepository>
-
<doapFile>target/test/unit/doap-configuration/doap-extra-configuration.rdf</doapFile>
-
<outputDirectory>target/test/unit/doap-configuration</outputDirectory>
+ <doapFile>target/doap-extra-configuration.rdf</doapFile>
+ <outputDirectory>target</outputDirectory>
<lang>en</lang>
<validate>true</validate>