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

slachiewicz 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 2ccc146  Move the doapfile, minimal and MDOAP-38 integration tests to 
unit tests
2ccc146 is described below

commit 2ccc146b4ca81728d96b978b478b92de891baa77
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sat Nov 14 10:11:36 2026 +0100

    Move the doapfile, minimal and MDOAP-38 integration tests to unit tests
---
 src/it/MDOAP-38/invoker.properties                 |  18 ----
 src/it/MDOAP-38/pom.xml                            | 116 ---------------------
 src/it/MDOAP-38/verify.groovy                      |  24 -----
 src/it/basic/verify.groovy                         |   9 ++
 src/it/doapfile/pom.xml                            | 116 ---------------------
 src/it/doapfile/verify.groovy                      |  21 ----
 src/it/minimal/verify.groovy                       |  21 ----
 .../org/apache/maven/plugin/doap/DoapMojoTest.java |  59 +++++++++++
 .../unit/minimal/minimal-plugin-config.xml}        |  22 ++--
 9 files changed, 81 insertions(+), 325 deletions(-)

diff --git a/src/it/MDOAP-38/invoker.properties 
b/src/it/MDOAP-38/invoker.properties
deleted file mode 100644
index f2a7dfb..0000000
--- a/src/it/MDOAP-38/invoker.properties
+++ /dev/null
@@ -1,18 +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.
-
-invoker.buildResult = failure
diff --git a/src/it/MDOAP-38/pom.xml b/src/it/MDOAP-38/pom.xml
deleted file mode 100644
index ee845bc..0000000
--- a/src/it/MDOAP-38/pom.xml
+++ /dev/null
@@ -1,116 +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/xsd/maven-4.0.0.xsd";>
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>org.apache.maven.its.doap</groupId>
-  <artifactId>maven-it-plugin</artifactId>
-  <version>1.0-SNAPSHOT</version>
-  <packaging>maven-plugin</packaging>
-
-  <name>Test Plugin</name>
-  <description>
-    Tests the check of a simple plugin Tests the check of a simple plugin 
Tests the check of a simple plugin Tests the check of a simple plugin.
-  </description>
-  <url>http://maven.apache.org/plugins/maven-doap-plugin</url>
-  <inceptionYear>2009</inceptionYear>
-
-  <prerequisites>
-    <maven>3.9.0</maven>
-  </prerequisites>
-
-  <scm>
-    
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-doap-plugin/</connection>
-    
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-doap-plugin/</developerConnection>
-    
<url>http://svn.apache.org/viewvc/maven/plugins/trunk/maven-doap-plugin/</url>
-  </scm>
-  <issueManagement>
-    <system>jira</system>
-    <url>https://issues.apache.org/jira/browse/MDOAP</url>
-  </issueManagement>
-  <licenses>
-    <license>
-      <name>The Apache Software License, Version 2.0</name>
-      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
-      <distribution>repo</distribution>
-    </license>
-  </licenses>
-  <organization>
-    <name>The Apache Software Foundation</name>
-    <url>http://www.apache.org/</url>
-  </organization>
-  <mailingLists>
-    <mailingList>
-      <name>Maven Announcements List</name>
-      <post>[email protected]</post>
-      <subscribe>[email protected]</subscribe>
-      <unsubscribe>[email protected]</unsubscribe>
-      
<archive>http://mail-archives.apache.org/mod_mbox/maven-announce/</archive>
-      <otherArchives>
-        
<otherArchive>http://www.mail-archive.com/[email protected]</otherArchive>
-        
<otherArchive>http://www.nabble.com/Maven-Announcements-f15617.html</otherArchive>
-        
<otherArchive>http://markmail.org/list/org.apache.maven.announce</otherArchive>
-      </otherArchives>
-    </mailingList>
-  </mailingLists>
-
-  <developers>
-    <developer>
-      <id>nobody</id>
-      <name>Nobody</name>
-    </developer>
-  </developers>
-
-  <properties>
-    <maven.test.skip>true</maven.test.skip>
-  </properties>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-plugin-api</artifactId>
-      <version>@mavenVersion@</version>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-doap-plugin</artifactId>
-        <version>@project.version@</version>
-        <configuration>
-          <doapOptions>
-            <programmingLanguage>java</programmingLanguage>
-            <category>build-management</category>
-            <downloadPage>${project.url}/downloads</downloadPage>
-            <shortdesc>${project.description}</shortdesc>
-          </doapOptions>
-          <asfExtOptions>
-           <charter>World Domination</charter>
-           <chair>Nobody</chair>
-          </asfExtOptions>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-</project>
diff --git a/src/it/MDOAP-38/verify.groovy b/src/it/MDOAP-38/verify.groovy
deleted file mode 100644
index 3cb6cb2..0000000
--- a/src/it/MDOAP-38/verify.groovy
+++ /dev/null
@@ -1,24 +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.
- */
-def logFile = new File( basedir, 'build.log' )
-assert logFile.exists()
-content = logFile.text
-
-assert content.contains( 'The <doapOptions><shortdesc/></doapOptions> first 
sentence is too long maximum words number is 10.' )
diff --git a/src/it/basic/verify.groovy b/src/it/basic/verify.groovy
index c35ee7e..1549149 100644
--- a/src/it/basic/verify.groovy
+++ b/src/it/basic/verify.groovy
@@ -19,3 +19,12 @@
 
 def rdfFile = new File( basedir, 'target/site/doap_maven-it-plugin.rdf' )
 assert rdfFile.exists()
+
+def rdf = rdfFile.text
+// values interpolated from the POM by a real Maven build
+assert rdf.contains( '<name>Apache Test Plugin</name>' )
+assert rdf.contains( '<shortdesc xml:lang="en">Tests the check of a simple 
plugin</shortdesc>' )
+assert rdf.contains( '<download-page 
rdf:resource="http://maven.apache.org/plugins/maven-doap-plugin/downloads"/>' )
+// ASF extensions, written because the project is hosted at Apache
+assert rdf.contains( 'projects.apache.org/category/build-management"/>' )
+assert rdf.contains( '<asfext:charter>World Domination</asfext:charter>' )
diff --git a/src/it/doapfile/pom.xml b/src/it/doapfile/pom.xml
deleted file mode 100644
index 1c8de74..0000000
--- a/src/it/doapfile/pom.xml
+++ /dev/null
@@ -1,116 +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/xsd/maven-4.0.0.xsd";>
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>org.apache.maven.its.doap</groupId>
-  <artifactId>maven-it-plugin</artifactId>
-  <version>1.0-SNAPSHOT</version>
-  <packaging>maven-plugin</packaging>
-
-  <name>Test Plugin</name>
-  <description>
-    Tests the check of a simple plugin.
-  </description>
-  <url>http://maven.apache.org/plugins/maven-doap-plugin</url>
-  <inceptionYear>2011</inceptionYear>
-
-  <prerequisites>
-    <maven>3.9.0</maven>
-  </prerequisites>
-
-  <scm>
-    
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-doap-plugin/</connection>
-    
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-doap-plugin/</developerConnection>
-    
<url>http://svn.apache.org/viewvc/maven/plugins/trunk/maven-doap-plugin/</url>
-  </scm>
-  <issueManagement>
-    <system>jira</system>
-    <url>https://issues.apache.org/jira/browse/MDOAP</url>
-  </issueManagement>
-  <licenses>
-    <license>
-      <name>The Apache Software License, Version 2.0</name>
-      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
-      <distribution>repo</distribution>
-    </license>
-  </licenses>
-  <organization>
-    <name>The Apache Software Foundation</name>
-    <url>http://www.apache.org/</url>
-  </organization>
-  <mailingLists>
-    <mailingList>
-      <name>Maven Announcements List</name>
-      <post>[email protected]</post>
-      <subscribe>[email protected]</subscribe>
-      <unsubscribe>[email protected]</unsubscribe>
-      
<archive>http://mail-archives.apache.org/mod_mbox/maven-announce/</archive>
-      <otherArchives>
-        
<otherArchive>http://www.mail-archive.com/[email protected]</otherArchive>
-        
<otherArchive>http://www.nabble.com/Maven-Announcements-f15617.html</otherArchive>
-        
<otherArchive>http://markmail.org/list/org.apache.maven.announce</otherArchive>
-      </otherArchives>
-    </mailingList>
-  </mailingLists>
-
-  <developers>
-    <developer>
-      <id>nobody</id>
-      <name>Nobody</name>
-    </developer>
-  </developers>
-
-  <properties>
-    <maven.test.skip>true</maven.test.skip>
-  </properties>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-plugin-api</artifactId>
-      <version>@mavenVersion@</version>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-doap-plugin</artifactId>
-        <version>@project.version@</version>
-        <configuration>
-          <doapFile>target/foo.rdf</doapFile>
-          <doapOptions>
-            <programmingLanguage>java</programmingLanguage>
-            <category>build-management</category>
-            <downloadPage>${project.url}/downloads</downloadPage>
-          </doapOptions>
-          <asfExtOptions>
-           <charter>World Domination</charter>
-           <chair>Nobody</chair>
-          </asfExtOptions>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-</project>
diff --git a/src/it/doapfile/verify.groovy b/src/it/doapfile/verify.groovy
deleted file mode 100644
index 060093d..0000000
--- a/src/it/doapfile/verify.groovy
+++ /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.
- */
-
-def rdfFile = new File( basedir, 'target/foo.rdf' )
-assert rdfFile.exists()
diff --git a/src/it/minimal/verify.groovy b/src/it/minimal/verify.groovy
deleted file mode 100644
index a2d327c..0000000
--- a/src/it/minimal/verify.groovy
+++ /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.
- */
-
-def rdfFile = new File( basedir, 'target/site/doap_minimal.rdf' )
-assert rdfFile.exists()
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 ccef7ae..f6861d5 100644
--- a/src/test/java/org/apache/maven/plugin/doap/DoapMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/doap/DoapMojoTest.java
@@ -38,6 +38,7 @@ 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.logging.Log;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.StringUtils;
 import org.eclipse.aether.repository.RemoteRepository;
@@ -51,9 +52,11 @@ import static 
org.apache.maven.api.plugin.testing.MojoExtension.getVariableValue
 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.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.verify;
 
 /**
  * Test {@link DoapMojo} class.
@@ -69,6 +72,9 @@ class DoapMojoTest {
     @Inject
     private MavenSession session;
 
+    @Inject
+    private Log log;
+
     @BeforeEach
     void setUp() {
         // the harness mocks MavenSession without a project building request; 
build it as MavenSession does
@@ -489,6 +495,59 @@ class DoapMojoTest {
         return readFile(doapFile);
     }
 
+    /**
+     * Verify that a POM with empty scm, issueManagement, organization and 
prerequisites elements still
+     * generates a DOAP file.
+     *
+     * @throws Exception if any
+     */
+    @Test
+    @InjectMojo(goal = "generate", pom = "minimal-plugin-config.xml")
+    @Basedir("/unit/minimal/")
+    void testGeneratedDoapForMinimalPom(DoapMojo mojo) throws Exception {
+        MavenXpp3Reader pomReader = new MavenXpp3Reader();
+        try (InputStream in =
+                
Files.newInputStream(getTestFile("minimal-plugin-config.xml").toPath())) {
+            mavenProject.setModel(pomReader.read(in));
+        }
+
+        mojo.execute();
+
+        File doapFile = new File(getBasedir(), "target/doap_minimal.rdf");
+        assertTrue(doapFile.exists(), "Doap File was not generated!");
+        assertTrue(readFile(doapFile).contains("<name>minimal</name>"));
+    }
+
+    /**
+     * Verify that an ASF project fails when the first sentence of the short 
description is longer than
+     * ten words.
+     *
+     * @throws Exception if any
+     */
+    @Test
+    @InjectMojo(goal = "generate", pom = 
"asf-doap-configuration-plugin-config.xml")
+    @Basedir("/unit/asf-doap-configuration/")
+    void testShortDescTooLongFailsForASF(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));
+        }
+        DoapOptions doapOptions = getVariableValueFromObject(mojo, 
"doapOptions");
+        // the length check applies when the short description falls back to 
the description
+        String description = "Tests the check of a simple plugin Tests the 
check of a simple plugin.";
+        doapOptions.setDescription(description);
+        doapOptions.setShortdesc(description);
+        setVariableValueToObject(mojo, "doapOptions", doapOptions);
+
+        MojoExecutionException e = assertThrows(MojoExecutionException.class, 
mojo::execute);
+
+        assertEquals("The generated DOAP doesn't respect ASF rules, see 
above.", e.getMessage());
+        verify(log)
+                .error("The <doapOptions><shortdesc/></doapOptions> first 
sentence is too long maximum words "
+                        + "number is 10.");
+    }
+
     private String readFile(File file) throws IOException {
         return new String(Files.readAllBytes(file.toPath()), 
StandardCharsets.UTF_8);
     }
diff --git a/src/it/minimal/pom.xml 
b/src/test/resources/unit/minimal/minimal-plugin-config.xml
similarity index 70%
rename from src/it/minimal/pom.xml
rename to src/test/resources/unit/minimal/minimal-plugin-config.xml
index a4823af..742cbf2 100644
--- a/src/it/minimal/pom.xml
+++ b/src/test/resources/unit/minimal/minimal-plugin-config.xml
@@ -1,5 +1,3 @@
-<?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
@@ -9,7 +7,7 @@ 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
+    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
@@ -21,16 +19,22 @@ under the License.
 
 <project>
   <modelVersion>4.0.0</modelVersion>
-
-  <groupId>org.apache.maven.its.doap</groupId>
+  <groupId>org.apache.maven.plugin.doap.unit</groupId>
   <artifactId>minimal</artifactId>
   <version>1.0-SNAPSHOT</version>
-
-  <!-- minimal POM, almost all metadata missing -->
-
-  <!-- NOTE: We deliberately use empty tags here to check that partial 
metadata is handled properly -->
   <prerequisites/>
   <scm/>
   <issueManagement/>
   <organization/>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-doap-plugin</artifactId>
+        <configuration>
+          <doapFile>target/doap_minimal.rdf</doapFile>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>

Reply via email to