You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2025/11/25 01:59:48 UTC

(maven-doap-plugin) branch MDOAP-69 created (now 11f6686)

This is an automated email from the ASF dual-hosted git repository.

elharo pushed a change to branch MDOAP-69
in repository https://gitbox.apache.org/repos/asf/maven-doap-plugin.git


      at 11f6686  fix

This branch includes the following new commits:

     new 11f6686  fix

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(maven-doap-plugin) 01/01: fix

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch MDOAP-69
in repository https://gitbox.apache.org/repos/asf/maven-doap-plugin.git

commit 11f6686821d46b6bae0dc723ab2785ff9fba4e25
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Mon Nov 24 19:59:28 2025 -0600

    fix
---
 .../org/apache/maven/plugin/doap/DoapMojoTest.java | 55 +++++++++-------------
 1 file changed, 23 insertions(+), 32 deletions(-)

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 d359160..b10e463 100644
--- a/src/test/java/org/apache/maven/plugin/doap/DoapMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/doap/DoapMojoTest.java
@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 
+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;
@@ -29,21 +30,14 @@ import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
 
+import static org.junit.Assert.fail;
+
 /**
  * Test {@link DoapMojo} class.
  *
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
  */
 public class DoapMojoTest extends AbstractMojoTestCase {
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
 
     /**
      * Verify the generation of a pure DOAP file.
@@ -53,10 +47,10 @@ public class DoapMojoTest extends AbstractMojoTestCase {
     public void testGeneratedDoap() throws Exception {
         File pluginXmlFile = new File(
                 getBasedir(), "src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml");
-        DoapMojo mojo = (DoapMojo) lookupMojo("generate", pluginXmlFile);
+        DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
         assertNotNull("Mojo found.", mojo);
 
-        MavenProject mavenProject = (MavenProject) getVariableValueFromObject(mojo, "project");
+        MavenProject mavenProject = getVariableValueFromObject(mojo, "project");
         assertNotNull(mavenProject);
 
         // Set some Mojo parameters
@@ -133,20 +127,21 @@ public class DoapMojoTest extends AbstractMojoTestCase {
     public void testLangParameter() throws Exception {
         File pluginXmlFile = new File(
                 getBasedir(), "src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml");
-        DoapMojo mojo = (DoapMojo) lookupMojo("generate", pluginXmlFile);
+        DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
         assertNotNull("Mojo found.", mojo);
 
-        MavenProject mavenProject = (MavenProject) getVariableValueFromObject(mojo, "project");
+        MavenProject mavenProject = getVariableValueFromObject(mojo, "project");
         assertNotNull(mavenProject);
 
         // check invalid lang
         setVariableValueToObject(mojo, "remoteRepositories", mavenProject.getRemoteArtifactRepositories());
         setVariableValueToObject(mojo, "lang", "foo");
+
         try {
             mojo.execute();
-            assertTrue("No lang checked", false);
-        } catch (Exception e) {
-            assertTrue(true);
+            fail("No lang checked");
+        } catch (MojoExecutionException ex) {
+            assertNotNull(ex.getMessage());
         }
     }
 
@@ -156,20 +151,16 @@ public class DoapMojoTest extends AbstractMojoTestCase {
     public void testAboutParameter() throws Exception {
         File pluginXmlFile = new File(
                 getBasedir(), "src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml");
-        DoapMojo mojo = (DoapMojo) lookupMojo("generate", pluginXmlFile);
+        DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
         assertNotNull("Mojo found.", mojo);
 
-        MavenProject mavenProject = (MavenProject) getVariableValueFromObject(mojo, "project");
+        MavenProject mavenProject = getVariableValueFromObject(mojo, "project");
         assertNotNull(mavenProject);
 
-        // check invalid lang
         setVariableValueToObject(mojo, "remoteRepositories", mavenProject.getRemoteArtifactRepositories());
         setVariableValueToObject(mojo, "about", "foo");
-        try {
-            mojo.execute();
-        } catch (Exception e) {
-            assertTrue(true);
-        }
+
+        mojo.execute();
     }
 
     /**
@@ -180,10 +171,10 @@ public class DoapMojoTest extends AbstractMojoTestCase {
     public void testGeneratedDoapArtifact() throws Exception {
         File pluginXmlFile = new File(
                 getBasedir(), "src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml");
-        DoapMojo mojo = (DoapMojo) lookupMojo("generate", pluginXmlFile);
+        DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
         assertNotNull("Mojo found.", mojo);
 
-        MavenProject mavenProject = (MavenProject) getVariableValueFromObject(mojo, "project");
+        MavenProject mavenProject = getVariableValueFromObject(mojo, "project");
         assertNotNull(mavenProject);
 
         // Set some Mojo parameters
@@ -257,10 +248,10 @@ public class DoapMojoTest extends AbstractMojoTestCase {
     public void testGeneratedDoapArtifactMinimalist() throws Exception {
         File pluginXmlFile = new File(
                 getBasedir(), "src/test/resources/unit/doap-configuration/doap-configuration-plugin-config.xml");
-        DoapMojo mojo = (DoapMojo) lookupMojo("generate", pluginXmlFile);
+        DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
         assertNotNull("Mojo found.", mojo);
 
-        MavenProject mavenProject = (MavenProject) getVariableValueFromObject(mojo, "project");
+        MavenProject mavenProject = getVariableValueFromObject(mojo, "project");
         assertNotNull(mavenProject);
 
         // Set some Mojo parameters
@@ -336,10 +327,10 @@ public class DoapMojoTest extends AbstractMojoTestCase {
         File pluginXmlFile = new File(
                 getBasedir(),
                 "src/test/resources/unit/asf-doap-configuration/asf-doap-configuration-plugin-config.xml");
-        DoapMojo mojo = (DoapMojo) lookupMojo("generate", pluginXmlFile);
+        DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
         assertNotNull("Mojo found.", mojo);
 
-        MavenProject mavenProject = (MavenProject) getVariableValueFromObject(mojo, "project");
+        MavenProject mavenProject = getVariableValueFromObject(mojo, "project");
         assertNotNull(mavenProject);
 
         // Set some Mojo parameters
@@ -383,10 +374,10 @@ public class DoapMojoTest extends AbstractMojoTestCase {
     public void testGeneratedExtraDoap() throws Exception {
         File pluginXmlFile = new File(
                 getBasedir(), "src/test/resources/unit/doap-configuration/doap-extra-configuration-plugin-config.xml");
-        DoapMojo mojo = (DoapMojo) lookupMojo("generate", pluginXmlFile);
+        DoapMojo mojo = lookupMojo("generate", pluginXmlFile);
         assertNotNull("Mojo found.", mojo);
 
-        MavenProject mavenProject = (MavenProject) getVariableValueFromObject(mojo, "project");
+        MavenProject mavenProject = getVariableValueFromObject(mojo, "project");
         assertNotNull(mavenProject);
 
         // Set some Mojo parameters