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-release.git
The following commit(s) were added to refs/heads/master by this push:
new b81806cf Migrate JUnit 3/4 to JUnit 5
b81806cf is described below
commit b81806cf6d467905dd6fef450b821ee9db44dc41
Author: Slawomir Jaranowski <[email protected]>
AuthorDate: Sun Nov 9 17:27:37 2025 +0100
Migrate JUnit 3/4 to JUnit 5
---
.../src/test/resources/pomfinder/pom1.xml | 161 ---------------
maven-release-plugin/pom.xml | 9 +-
.../src/it/projects/branch/MRELEASE-458/pom.xml | 8 -
.../prepare/MRELEASE-1053/module-a/pom.xml | 6 +-
.../maven/plugin/release/module/a/AppTest.java | 38 +---
.../prepare/MRELEASE-1053/module-parent/pom.xml | 6 +-
.../ci-friendly-multi-module/module-a/pom.xml | 6 +-
.../maven/plugin/release/module/a/AppTest.java | 38 +---
.../ci-friendly-multi-module/module-b/pom.xml | 6 +-
.../maven/plugin/release/module/b/AppTest.java | 38 +---
.../prepare/ci-friendly-multi-module/pom.xml | 6 +-
.../prepare/flat-multi-module/module-a/pom.xml | 6 +-
.../maven/plugin/release/module/a/AppTest.java | 38 +---
.../prepare/flat-multi-module/module-b/pom.xml | 6 +-
.../maven/plugin/release/module/b/AppTest.java | 37 +---
.../flat-multi-module/parent-project/pom.xml | 6 +-
.../prepare/regular-multi-module/module-a/pom.xml | 6 +-
.../maven/plugin/release/module/a/AppTest.java | 38 +---
.../prepare/regular-multi-module/module-b/pom.xml | 6 +-
.../maven/plugin/release/module/b/AppTest.java | 40 +---
.../projects/prepare/regular-multi-module/pom.xml | 6 +-
.../plugins/release/CleanReleaseMojoTest.java | 39 ++--
.../plugins/release/PerformReleaseMojoTest.java | 223 +++++++++++----------
.../plugins/release/PrepareReleaseMojoTest.java | 178 ++++++++--------
.../plugins/release/StageReleaseMojoTest.java | 101 ++++++----
.../stubs/FlatMultiModuleMavenProjectStub.java | 92 ---------
.../plugins/release/stubs/MavenProjectStub.java | 64 ------
.../src/test/resources/mojos/clean/clean.xml | 34 ----
.../resources/mojos/perform/perform-with-args.xml | 5 -
.../mojos/perform/perform-with-flat-structure.xml | 5 -
.../mojos/perform/perform-with-multiline-goals.xml | 5 -
.../resources/mojos/perform/perform-with-scm.xml | 5 -
.../mojos/perform/perform-without-site.xml | 5 -
.../src/test/resources/mojos/perform/perform.xml | 5 -
.../src/test/resources/mojos/prepare/prepare.xml | 5 -
.../src/test/resources/mojos/stage/stage.xml | 5 -
pom.xml | 7 -
37 files changed, 394 insertions(+), 895 deletions(-)
diff --git a/maven-release-manager/src/test/resources/pomfinder/pom1.xml
b/maven-release-manager/src/test/resources/pomfinder/pom1.xml
index b6d57245..6ae1e3a5 100644
--- a/maven-release-manager/src/test/resources/pomfinder/pom1.xml
+++ b/maven-release-manager/src/test/resources/pomfinder/pom1.xml
@@ -31,165 +31,4 @@
<name>Maven Release Manager testartifact</name>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-repository-metadata</artifactId>
- <version>${mavenVersion}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- <version>1.0-alpha-9</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.4</version>
- </dependency>
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- <version>1.0</version>
- <exclusions>
- <exclusion>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <!-- scm dependencies -->
-
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-providers-standard</artifactId>
- <version>${scmVersion}</version>
- <type>pom</type>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-manager-plexus</artifactId>
- <version>${scmVersion}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-api</artifactId>
- <version>${scmVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-provider-svn-commons</artifactId>
- <version>${scmVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>org.jdom</groupId>
- <artifactId>jdom2</artifactId>
- </dependency>
- <dependency>
- <groupId>jaxen</groupId>
- <artifactId>jaxen</artifactId>
- <version>1.1-beta-8</version>
- <scope>runtime</scope>
- <exclusions>
- <exclusion>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>xerces</groupId>
- <artifactId>xmlParserAPIs</artifactId>
- </exclusion>
- <exclusion>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>xom</groupId>
- <artifactId>xom</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junitVersion}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-plugin-testing-harness</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-test</artifactId>
- <version>${scmVersion}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>jmock</groupId>
- <artifactId>jmock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>jmock</groupId>
- <artifactId>jmock-cglib</artifactId>
- <version>1.0.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <!-- Required because the Modello generated classes uses the assert
keyword -->
- <source>1.4</source>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <argLine>-Xmx256m</argLine>
- <excludes>
- <!-- Disabled for now - we can't mock classes from plexus-utils in
surefire -->
- <exclude>**/ForkedMavenExecutorTest.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.modello</groupId>
- <artifactId>modello-maven-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <goals>
- <goal>xpp3-reader</goal>
- <goal>java</goal>
- <goal>xpp3-writer</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <version>2.0.0</version>
- <packageWithVersion>false</packageWithVersion>
- <models>
- <model>src/main/mdo/release-descriptor.mdo</model>
- </models>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
diff --git a/maven-release-plugin/pom.xml b/maven-release-plugin/pom.xml
index b83c4dd5..cf193859 100644
--- a/maven-release-plugin/pom.xml
+++ b/maven-release-plugin/pom.xml
@@ -108,8 +108,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -123,6 +123,11 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
diff --git a/maven-release-plugin/src/it/projects/branch/MRELEASE-458/pom.xml
b/maven-release-plugin/src/it/projects/branch/MRELEASE-458/pom.xml
index c3573b4b..ffc0c2df 100644
--- a/maven-release-plugin/src/it/projects/branch/MRELEASE-458/pom.xml
+++ b/maven-release-plugin/src/it/projects/branch/MRELEASE-458/pom.xml
@@ -45,14 +45,6 @@
<version>1.0</version>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>@junitVersion@</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
<scm>
<connection>scm:stub|</connection>
<developerConnection>scm:stub|</developerConnection>
diff --git
a/maven-release-plugin/src/it/projects/prepare/MRELEASE-1053/module-a/pom.xml
b/maven-release-plugin/src/it/projects/prepare/MRELEASE-1053/module-a/pom.xml
index 27b10e64..561d8b86 100644
---
a/maven-release-plugin/src/it/projects/prepare/MRELEASE-1053/module-a/pom.xml
+++
b/maven-release-plugin/src/it/projects/prepare/MRELEASE-1053/module-a/pom.xml
@@ -30,9 +30,9 @@ under the License.
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>@junitVersion@</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-release-plugin/src/it/projects/prepare/MRELEASE-1053/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
b/maven-release-plugin/src/it/projects/prepare/MRELEASE-1053/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
index ca41b5f5..8156c2ca 100644
---
a/maven-release-plugin/src/it/projects/prepare/MRELEASE-1053/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
+++
b/maven-release-plugin/src/it/projects/prepare/MRELEASE-1053/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
@@ -8,9 +8,9 @@ package org.apache.maven.plugin.release.module.a;
* 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
@@ -19,39 +19,19 @@ package org.apache.maven.plugin.release.module.a;
* under the License.
*/
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Unit test for simple App.
*/
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
+public class AppTest {
/**
* Rigourous Test :-)
*/
- public void testApp()
- {
- assertTrue( true );
+ @Test
+ public void testApp() {
+ assertTrue(true);
}
}
diff --git
a/maven-release-plugin/src/it/projects/prepare/MRELEASE-1053/module-parent/pom.xml
b/maven-release-plugin/src/it/projects/prepare/MRELEASE-1053/module-parent/pom.xml
index 2fa53f76..601048c1 100644
---
a/maven-release-plugin/src/it/projects/prepare/MRELEASE-1053/module-parent/pom.xml
+++
b/maven-release-plugin/src/it/projects/prepare/MRELEASE-1053/module-parent/pom.xml
@@ -50,9 +50,9 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>@junitVersion@</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/pom.xml
b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/pom.xml
index 14c54172..603366f4 100644
---
a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/pom.xml
+++
b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/pom.xml
@@ -30,9 +30,9 @@ under the License.
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>@junitVersion@</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
index ca41b5f5..8156c2ca 100644
---
a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
+++
b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
@@ -8,9 +8,9 @@ package org.apache.maven.plugin.release.module.a;
* 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
@@ -19,39 +19,19 @@ package org.apache.maven.plugin.release.module.a;
* under the License.
*/
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Unit test for simple App.
*/
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
+public class AppTest {
/**
* Rigourous Test :-)
*/
- public void testApp()
- {
- assertTrue( true );
+ @Test
+ public void testApp() {
+ assertTrue(true);
}
}
diff --git
a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/pom.xml
b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/pom.xml
index e4430454..269fc789 100644
---
a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/pom.xml
+++
b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/pom.xml
@@ -30,9 +30,9 @@ under the License.
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>@junitVersion@</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java
b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java
index c1a903ec..5502d52c 100644
---
a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java
+++
b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java
@@ -8,9 +8,9 @@ package org.apache.maven.plugin.release.module.b;
* 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
@@ -19,39 +19,19 @@ package org.apache.maven.plugin.release.module.b;
* under the License.
*/
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Unit test for simple App.
*/
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
+public class AppTest {
/**
* Rigourous Test :-)
*/
- public void testApp()
- {
- assertTrue( true );
+ @Test
+ public void testApp() {
+ assertTrue(true);
}
}
diff --git
a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/pom.xml
b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/pom.xml
index e6c05b91..645bf35f 100644
---
a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/pom.xml
+++
b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/pom.xml
@@ -63,9 +63,9 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>@junitVersion@</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-a/pom.xml
b/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-a/pom.xml
index 5dd958c9..aeb84eee 100644
---
a/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-a/pom.xml
+++
b/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-a/pom.xml
@@ -32,9 +32,9 @@
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>@junitVersion@</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
b/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
index ca41b5f5..8156c2ca 100644
---
a/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
+++
b/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
@@ -8,9 +8,9 @@ package org.apache.maven.plugin.release.module.a;
* 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
@@ -19,39 +19,19 @@ package org.apache.maven.plugin.release.module.a;
* under the License.
*/
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Unit test for simple App.
*/
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
+public class AppTest {
/**
* Rigourous Test :-)
*/
- public void testApp()
- {
- assertTrue( true );
+ @Test
+ public void testApp() {
+ assertTrue(true);
}
}
diff --git
a/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-b/pom.xml
b/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-b/pom.xml
index eb3b9429..316a102c 100644
---
a/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-b/pom.xml
+++
b/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-b/pom.xml
@@ -32,9 +32,9 @@
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>@junitVersion@</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java
b/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java
index 3e11941d..5502d52c 100644
---
a/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java
+++
b/maven-release-plugin/src/it/projects/prepare/flat-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java
@@ -8,9 +8,9 @@ package org.apache.maven.plugin.release.module.b;
* 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
@@ -19,40 +19,19 @@ package org.apache.maven.plugin.release.module.b;
* under the License.
*/
+import org.junit.jupiter.api.Test;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Unit test for simple App.
*/
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
+public class AppTest {
/**
* Rigourous Test :-)
*/
- public void testApp()
- {
- assertTrue( true );
+ @Test
+ public void testApp() {
+ assertTrue(true);
}
}
diff --git
a/maven-release-plugin/src/it/projects/prepare/flat-multi-module/parent-project/pom.xml
b/maven-release-plugin/src/it/projects/prepare/flat-multi-module/parent-project/pom.xml
index 7fefdf7b..9910ba03 100644
---
a/maven-release-plugin/src/it/projects/prepare/flat-multi-module/parent-project/pom.xml
+++
b/maven-release-plugin/src/it/projects/prepare/flat-multi-module/parent-project/pom.xml
@@ -49,9 +49,9 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>@junitVersion@</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-a/pom.xml
b/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-a/pom.xml
index a36a18a3..bae31c64 100644
---
a/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-a/pom.xml
+++
b/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-a/pom.xml
@@ -31,9 +31,9 @@ under the License.
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>@junitVersion@</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
b/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
index ca41b5f5..8156c2ca 100644
---
a/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
+++
b/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java
@@ -8,9 +8,9 @@ package org.apache.maven.plugin.release.module.a;
* 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
@@ -19,39 +19,19 @@ package org.apache.maven.plugin.release.module.a;
* under the License.
*/
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Unit test for simple App.
*/
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
+public class AppTest {
/**
* Rigourous Test :-)
*/
- public void testApp()
- {
- assertTrue( true );
+ @Test
+ public void testApp() {
+ assertTrue(true);
}
}
diff --git
a/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-b/pom.xml
b/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-b/pom.xml
index 2103af3f..71b5dbbb 100644
---
a/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-b/pom.xml
+++
b/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-b/pom.xml
@@ -31,9 +31,9 @@ under the License.
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>@junitVersion@</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java
b/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java
index c1a903ec..8156c2ca 100644
---
a/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java
+++
b/maven-release-plugin/src/it/projects/prepare/regular-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin.release.module.b;
+package org.apache.maven.plugin.release.module.a;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -8,9 +8,9 @@ package org.apache.maven.plugin.release.module.b;
* 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
@@ -19,39 +19,19 @@ package org.apache.maven.plugin.release.module.b;
* under the License.
*/
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Unit test for simple App.
*/
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
+public class AppTest {
/**
* Rigourous Test :-)
*/
- public void testApp()
- {
- assertTrue( true );
+ @Test
+ public void testApp() {
+ assertTrue(true);
}
}
diff --git
a/maven-release-plugin/src/it/projects/prepare/regular-multi-module/pom.xml
b/maven-release-plugin/src/it/projects/prepare/regular-multi-module/pom.xml
index cd94c059..08803fd4 100644
--- a/maven-release-plugin/src/it/projects/prepare/regular-multi-module/pom.xml
+++ b/maven-release-plugin/src/it/projects/prepare/regular-multi-module/pom.xml
@@ -49,9 +49,9 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>@junitVersion@</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/CleanReleaseMojoTest.java
b/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/CleanReleaseMojoTest.java
index 07d09f1f..92f4cc30 100644
---
a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/CleanReleaseMojoTest.java
+++
b/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/CleanReleaseMojoTest.java
@@ -18,14 +18,18 @@
*/
package org.apache.maven.plugins.release;
-import java.io.File;
-
-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.shared.release.ReleaseCleanRequest;
import org.apache.maven.shared.release.ReleaseManager;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
-import static org.mockito.Mockito.mock;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -34,33 +38,32 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
*
* @author <a href="mailto:[email protected]">Brett Porter</a>
*/
-public class CleanReleaseMojoTest extends AbstractMojoTestCase {
- protected CleanReleaseMojo mojo;
+@ExtendWith(MockitoExtension.class)
+@MojoTest
+class CleanReleaseMojoTest {
- protected void setUp() throws Exception {
- super.setUp();
+ @Mock
+ private ReleaseManager releaseManagerMock;
- File testFile =
getTestFile("target/test-classes/mojos/clean/clean.xml");
- mojo = lookupMojo("clean", testFile);
- File workingDirectory = testFile.getParentFile();
- mojo.setBasedir(workingDirectory);
+ @Provides
+ private ReleaseManager releaseManager() {
+ return releaseManagerMock;
}
- public void testClean() throws Exception {
+ @Test
+ @InjectMojo(goal = "clean")
+ void testClean(CleanReleaseMojo mojo) throws Exception {
// prepare
ArgumentCaptor<ReleaseCleanRequest> request =
ArgumentCaptor.forClass(ReleaseCleanRequest.class);
- ReleaseManager mock = mock(ReleaseManager.class);
- mojo.setReleaseManager(mock);
-
// execute
mojo.execute();
// verify
- verify(mock).clean(request.capture());
+ verify(releaseManagerMock).clean(request.capture());
assertEquals(mojo.getReactorProjects(),
request.getValue().getReactorProjects());
- verifyNoMoreInteractions(mock);
+ verifyNoMoreInteractions(releaseManagerMock);
}
}
diff --git
a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java
b/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java
index f2b37fc2..89db9f1b 100644
---
a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java
+++
b/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java
@@ -18,49 +18,90 @@
*/
package org.apache.maven.plugins.release;
+import javax.inject.Inject;
+
import java.io.File;
import java.util.Arrays;
-
+import java.util.Collections;
+
+import org.apache.maven.api.di.Provides;
+import org.apache.maven.api.plugin.testing.Basedir;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+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.DistributionManagement;
-import org.apache.maven.model.Site;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.release.ReleaseExecutionException;
import org.apache.maven.shared.release.ReleaseFailureException;
import org.apache.maven.shared.release.ReleaseManager;
import org.apache.maven.shared.release.ReleasePerformRequest;
import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
/**
* Test release:perform.
*
* @author <a href="mailto:[email protected]">Brett Porter</a>
*/
-public class PerformReleaseMojoTest extends AbstractMojoTestCase {
- private File workingDirectory;
+@ExtendWith(MockitoExtension.class)
+@MojoTest
+class PerformReleaseMojoTest {
+
+ @Mock
+ private ReleaseManager releaseManagerMock;
+
+ @Inject
+ private MavenProject mavenProject;
+
+ @Inject
+ private MavenSession mavenSession;
+
+ @Provides
+ private ReleaseManager releaseManager() {
+ return releaseManagerMock;
+ }
+
+ @BeforeEach
+ void setup() {
+ when(mavenProject.getFile()).thenReturn(new File("pom.xml"));
- public void testPerform() throws Exception {
- PerformReleaseMojo mojo = getMojoWithProjectSite("perform.xml");
+ when(mavenProject.getGroupId()).thenReturn("groupId");
+ when(mavenProject.getArtifactId()).thenReturn("artifactId");
+ when(mavenProject.getVersion()).thenReturn("1.0.0-SNAPSHOT");
- ReleaseManager mock = mock(ReleaseManager.class);
- mojo.setReleaseManager(mock);
+
when(mavenSession.getProjects()).thenReturn(Collections.singletonList(mavenProject));
+ when(mavenSession.getRequest()).thenReturn(new
DefaultMavenExecutionRequest());
+ }
+ @Test
+ @Basedir("/mojos/perform")
+ @InjectMojo(goal = "perform", pom = "perform.xml")
+ void testPerform(PerformReleaseMojo mojo) throws Exception {
// execute
mojo.execute();
// verify
ArgumentCaptor<ReleasePerformRequest> argument =
ArgumentCaptor.forClass(ReleasePerformRequest.class);
- verify(mock).perform(argument.capture());
+ verify(releaseManagerMock).perform(argument.capture());
assertNotNull(argument.getValue().getReleaseDescriptorBuilder());
assertNotNull(argument.getValue().getReleaseEnvironment());
assertNotNull(argument.getValue().getReactorProjects());
@@ -70,21 +111,19 @@ public class PerformReleaseMojoTest extends
AbstractMojoTestCase {
argument.getValue().getReleaseDescriptorBuilder().build();
assertEquals("deploy site-deploy",
releaseDescriptor.getPerformGoals());
- verifyNoMoreInteractions(mock);
+ verifyNoMoreInteractions(releaseManagerMock);
}
- public void testPerformWithFlatStructure() throws Exception {
- PerformReleaseMojo mojo =
getMojoWithProjectSite("perform-with-flat-structure.xml");
-
- ReleaseManager mock = mock(ReleaseManager.class);
- mojo.setReleaseManager(mock);
-
+ @Test
+ @Basedir("/mojos/perform")
+ @InjectMojo(goal = "perform", pom = "perform-with-flat-structure.xml")
+ void testPerformWithFlatStructure(PerformReleaseMojo mojo) throws
Exception {
// execute
mojo.execute();
// verify
ArgumentCaptor<ReleasePerformRequest> argument =
ArgumentCaptor.forClass(ReleasePerformRequest.class);
- verify(mock).perform(argument.capture());
+ verify(releaseManagerMock).perform(argument.capture());
assertNotNull(argument.getValue().getReleaseDescriptorBuilder());
assertNotNull(argument.getValue().getReleaseEnvironment());
assertNotNull(argument.getValue().getReactorProjects());
@@ -97,59 +136,37 @@ public class PerformReleaseMojoTest extends
AbstractMojoTestCase {
"scm:svn:file://localhost/target/svnroot/flat-multi-module/trunk/root-project",
releaseDescriptor.getScmSourceUrl());
- verifyNoMoreInteractions(mock);
+ verifyNoMoreInteractions(releaseManagerMock);
}
- public void testPerformWithoutSite() throws Exception {
- File testFileDirectory =
getTestFile("target/test-classes/mojos/perform/");
- PerformReleaseMojo mojo = lookupMojo("perform", new
File(testFileDirectory, "perform-without-site.xml"));
- mojo.setBasedir(testFileDirectory);
- mojo.setPomFileName("pom.xml");
-
- MavenProject project = getVariableValueFromObject(mojo, "project");
- setVariableValueToObject(mojo, "session", newMavenSession(project));
-
- ReleaseManager mock = mock(ReleaseManager.class);
- mojo.setReleaseManager(mock);
-
+ @Test
+ @Basedir("/mojos/perform")
+ @InjectMojo(goal = "perform", pom = "perform-without-site.xml")
+ void testPerformWithoutSite(PerformReleaseMojo mojo) throws Exception {
// execute
mojo.execute();
// verify
ArgumentCaptor<ReleasePerformRequest> argument =
ArgumentCaptor.forClass(ReleasePerformRequest.class);
- verify(mock).perform(argument.capture());
+ verify(releaseManagerMock).perform(argument.capture());
assertNotNull(argument.getValue().getReleaseDescriptorBuilder());
assertNotNull(argument.getValue().getReleaseEnvironment());
assertNotNull(argument.getValue().getReactorProjects());
assertEquals(Boolean.FALSE, argument.getValue().getDryRun());
- verifyNoMoreInteractions(mock);
+ verifyNoMoreInteractions(releaseManagerMock);
ReleaseDescriptorBuilder.BuilderReleaseDescriptor releaseDescriptor =
argument.getValue().getReleaseDescriptorBuilder().build();
assertEquals("deploy", releaseDescriptor.getPerformGoals());
}
- private PerformReleaseMojo getMojoWithProjectSite(String fileName) throws
Exception {
- PerformReleaseMojo mojo = lookupMojo("perform", new
File(workingDirectory, fileName));
- mojo.setBasedir(workingDirectory);
- mojo.setPomFileName(fileName);
-
- MavenProject project = getVariableValueFromObject(mojo, "project");
- DistributionManagement distributionManagement = new
DistributionManagement();
- distributionManagement.setSite(new Site());
- project.setDistributionManagement(distributionManagement);
-
- setVariableValueToObject(mojo, "session", newMavenSession(project));
-
- return mojo;
- }
-
- public void testPerformWithExecutionException() throws Exception {
- PerformReleaseMojo mojo = getMojoWithProjectSite("perform.xml");
-
- ReleaseManager mock = mock(ReleaseManager.class);
- doThrow(new
ReleaseExecutionException("...")).when(mock).perform(isA(ReleasePerformRequest.class));
- mojo.setReleaseManager(mock);
+ @Test
+ @Basedir("/mojos/perform")
+ @InjectMojo(goal = "perform", pom = "perform.xml")
+ void testPerformWithExecutionException(PerformReleaseMojo mojo) throws
Exception {
+ doThrow(new ReleaseExecutionException("..."))
+ .when(releaseManagerMock)
+ .perform(isA(ReleasePerformRequest.class));
// execute
try {
@@ -157,13 +174,12 @@ public class PerformReleaseMojoTest extends
AbstractMojoTestCase {
fail("Should have thrown an exception");
} catch (MojoExecutionException e) {
- assertEquals(
- "Check cause", ReleaseExecutionException.class,
e.getCause().getClass());
+ assertEquals(ReleaseExecutionException.class,
e.getCause().getClass(), "Check cause");
}
// verify
ArgumentCaptor<ReleasePerformRequest> argument =
ArgumentCaptor.forClass(ReleasePerformRequest.class);
- verify(mock).perform(argument.capture());
+ verify(releaseManagerMock).perform(argument.capture());
assertNotNull(argument.getValue().getReleaseDescriptorBuilder());
assertNotNull(argument.getValue().getReleaseEnvironment());
assertNotNull(argument.getValue().getReactorProjects());
@@ -173,17 +189,17 @@ public class PerformReleaseMojoTest extends
AbstractMojoTestCase {
argument.getValue().getReleaseDescriptorBuilder().build();
assertEquals("deploy site-deploy",
releaseDescriptor.getPerformGoals());
- verifyNoMoreInteractions(mock);
+ verifyNoMoreInteractions(releaseManagerMock);
}
- public void testPerformWithExecutionFailure() throws Exception {
- PerformReleaseMojo mojo = getMojoWithProjectSite("perform.xml");
-
- ReleaseManager mock = mock(ReleaseManager.class);
+ @Test
+ @Basedir("/mojos/perform")
+ @InjectMojo(goal = "perform", pom = "perform.xml")
+ void testPerformWithExecutionFailure(PerformReleaseMojo mojo) throws
Exception {
ReleaseFailureException cause = new ReleaseFailureException("...");
- doThrow(cause).when(mock).perform(isA(ReleasePerformRequest.class));
+
doThrow(cause).when(releaseManagerMock).perform(isA(ReleasePerformRequest.class));
- mojo.setReleaseManager(mock);
+ mojo.setReleaseManager(releaseManagerMock);
// execute
try {
@@ -191,12 +207,12 @@ public class PerformReleaseMojoTest extends
AbstractMojoTestCase {
fail("Should have thrown an exception");
} catch (MojoFailureException e) {
- assertEquals("Check cause exists", cause, e.getCause());
+ assertEquals(cause, e.getCause(), "Check cause exists");
}
// verify
ArgumentCaptor<ReleasePerformRequest> argument =
ArgumentCaptor.forClass(ReleasePerformRequest.class);
- verify(mock).perform(argument.capture());
+ verify(releaseManagerMock).perform(argument.capture());
assertNotNull(argument.getValue().getReleaseDescriptorBuilder());
assertNotNull(argument.getValue().getReleaseEnvironment());
assertNotNull(argument.getValue().getReactorProjects());
@@ -206,21 +222,19 @@ public class PerformReleaseMojoTest extends
AbstractMojoTestCase {
argument.getValue().getReleaseDescriptorBuilder().build();
assertEquals("deploy site-deploy",
releaseDescriptor.getPerformGoals());
- verifyNoMoreInteractions(mock);
+ verifyNoMoreInteractions(releaseManagerMock);
}
- public void testPerformWithScm() throws Exception {
- PerformReleaseMojo mojo =
getMojoWithProjectSite("perform-with-scm.xml");
-
- ReleaseManager mock = mock(ReleaseManager.class);
- mojo.setReleaseManager(mock);
-
+ @Test
+ @Basedir("/mojos/perform")
+ @InjectMojo(goal = "perform", pom = "perform-with-scm.xml")
+ void testPerformWithScm(PerformReleaseMojo mojo) throws Exception {
// execute
mojo.execute();
// verify
ArgumentCaptor<ReleasePerformRequest> argument =
ArgumentCaptor.forClass(ReleasePerformRequest.class);
- verify(mock).perform(argument.capture());
+ verify(releaseManagerMock).perform(argument.capture());
assertNotNull(argument.getValue().getReleaseDescriptorBuilder());
assertNotNull(argument.getValue().getReleaseEnvironment());
assertNotNull(argument.getValue().getReactorProjects());
@@ -231,24 +245,23 @@ public class PerformReleaseMojoTest extends
AbstractMojoTestCase {
assertEquals("deploy site-deploy",
releaseDescriptor.getPerformGoals());
assertEquals("scm-url", releaseDescriptor.getScmSourceUrl());
- verifyNoMoreInteractions(mock);
+ verifyNoMoreInteractions(releaseManagerMock);
}
- public void testPerformWithProfiles() throws Exception {
- PerformReleaseMojo mojo = getMojoWithProjectSite("perform.xml");
-
- MavenSession session = getVariableValueFromObject(mojo, "session");
- session.getRequest().setActiveProfiles(Arrays.asList("prof1",
"2prof"));
-
- ReleaseManager mock = mock(ReleaseManager.class);
- mojo.setReleaseManager(mock);
+ @Test
+ @Basedir("/mojos/perform")
+ @InjectMojo(goal = "perform", pom = "perform.xml")
+ void testPerformWithProfiles(PerformReleaseMojo mojo) throws Exception {
+ MavenExecutionRequest request = mock(MavenExecutionRequest.class);
+ when(request.getActiveProfiles()).thenReturn(Arrays.asList("prof1",
"2prof"));
+ when(mavenSession.getRequest()).thenReturn(request);
// execute
mojo.execute();
// verify
ArgumentCaptor<ReleasePerformRequest> argument =
ArgumentCaptor.forClass(ReleasePerformRequest.class);
- verify(mock).perform(argument.capture());
+ verify(releaseManagerMock).perform(argument.capture());
assertNotNull(argument.getValue().getReleaseDescriptorBuilder());
assertNotNull(argument.getValue().getReleaseEnvironment());
assertNotNull(argument.getValue().getReactorProjects());
@@ -260,24 +273,23 @@ public class PerformReleaseMojoTest extends
AbstractMojoTestCase {
assertTrue(releaseDescriptor.getActivateProfiles().contains("prof1"));
assertTrue(releaseDescriptor.getActivateProfiles().contains("2prof"));
- verifyNoMoreInteractions(mock);
+ verifyNoMoreInteractions(releaseManagerMock);
}
- public void testPerformWithProfilesAndArguments() throws Exception {
- PerformReleaseMojo mojo =
getMojoWithProjectSite("perform-with-args.xml");
-
- MavenSession session = getVariableValueFromObject(mojo, "session");
- session.getRequest().setActiveProfiles(Arrays.asList("prof1",
"2prof"));
-
- ReleaseManager mock = mock(ReleaseManager.class);
- mojo.setReleaseManager(mock);
+ @Test
+ @Basedir("/mojos/perform")
+ @InjectMojo(goal = "perform", pom = "perform-with-args.xml")
+ void testPerformWithProfilesAndArguments(PerformReleaseMojo mojo) throws
Exception {
+ MavenExecutionRequest request = mock(MavenExecutionRequest.class);
+ when(request.getActiveProfiles()).thenReturn(Arrays.asList("prof1",
"2prof"));
+ when(mavenSession.getRequest()).thenReturn(request);
// execute
mojo.execute();
// verify
ArgumentCaptor<ReleasePerformRequest> argument =
ArgumentCaptor.forClass(ReleasePerformRequest.class);
- verify(mock).perform(argument.capture());
+ verify(releaseManagerMock).perform(argument.capture());
assertNotNull(argument.getValue().getReleaseDescriptorBuilder());
assertNotNull(argument.getValue().getReleaseEnvironment());
assertNotNull(argument.getValue().getReactorProjects());
@@ -290,21 +302,19 @@ public class PerformReleaseMojoTest extends
AbstractMojoTestCase {
assertTrue(releaseDescriptor.getActivateProfiles().contains("2prof"));
assertEquals("-Dmaven.test.skip=true",
releaseDescriptor.getAdditionalArguments());
- verifyNoMoreInteractions(mock);
+ verifyNoMoreInteractions(releaseManagerMock);
}
- public void testPerformWithMultilineGoals() throws Exception {
- PerformReleaseMojo mojo =
getMojoWithProjectSite("perform-with-multiline-goals.xml");
-
- ReleaseManager mock = mock(ReleaseManager.class);
- mojo.setReleaseManager(mock);
-
+ @Test
+ @Basedir("/mojos/perform")
+ @InjectMojo(goal = "perform", pom = "perform-with-multiline-goals.xml")
+ void testPerformWithMultilineGoals(PerformReleaseMojo mojo) throws
Exception {
// execute
mojo.execute();
// verify
ArgumentCaptor<ReleasePerformRequest> argument =
ArgumentCaptor.forClass(ReleasePerformRequest.class);
- verify(mock).perform(argument.capture());
+ verify(releaseManagerMock).perform(argument.capture());
assertNotNull(argument.getValue().getReleaseDescriptorBuilder());
assertNotNull(argument.getValue().getReleaseEnvironment());
assertNotNull(argument.getValue().getReactorProjects());
@@ -314,11 +324,6 @@ public class PerformReleaseMojoTest extends
AbstractMojoTestCase {
argument.getValue().getReleaseDescriptorBuilder().build();
assertEquals("deploy site-deploy",
releaseDescriptor.getPerformGoals());
- verifyNoMoreInteractions(mock);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- workingDirectory = getTestFile("target/test-classes/mojos/perform");
+ verifyNoMoreInteractions(releaseManagerMock);
}
}
diff --git
a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PrepareReleaseMojoTest.java
b/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PrepareReleaseMojoTest.java
index db4c8c21..f7c98220 100644
---
a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PrepareReleaseMojoTest.java
+++
b/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PrepareReleaseMojoTest.java
@@ -18,59 +18,96 @@
*/
package org.apache.maven.plugins.release;
-import java.io.File;
+import javax.inject.Inject;
+import java.io.File;
+import java.util.Collections;
+
+import org.apache.maven.api.di.Provides;
+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.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.release.ReleaseExecutionException;
import org.apache.maven.shared.release.ReleaseFailureException;
import org.apache.maven.shared.release.ReleaseManager;
import org.apache.maven.shared.release.ReleasePrepareRequest;
import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder;
import org.apache.maven.shared.release.env.ReleaseEnvironment;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir;
+import static
org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
/**
* Test release:prepare.
*
* @author <a href="mailto:[email protected]">Brett Porter</a>
*/
-public class PrepareReleaseMojoTest extends AbstractMojoTestCase {
- private void setDefaults(PrepareReleaseMojo mojo) throws
IllegalAccessException {
- setVariableValueToObject(mojo, "updateWorkingCopyVersions",
Boolean.TRUE);
+@ExtendWith(MockitoExtension.class)
+@MojoTest
+class PrepareReleaseMojoTest {
+
+ @Mock
+ private ReleaseManager releaseManagerMock;
+
+ @Inject
+ private MavenProject mavenProject;
+
+ @Inject
+ private MavenSession mavenSession;
+
+ @Provides
+ private ReleaseManager releaseManager() {
+ return releaseManagerMock;
}
- public void testPrepare() throws Exception {
- File testFile =
getTestFile("target/test-classes/mojos/prepare/prepare.xml");
- final PrepareReleaseMojo mojo = lookupMojo("prepare", testFile);
- mojo.getProject().setFile(testFile);
- setDefaults(mojo);
- mojo.setBasedir(testFile.getParentFile());
- mojo.setPomFileName("pom.xml");
- setVariableValueToObject(mojo, "session",
newMavenSession(mojo.project));
+ @BeforeEach
+ void setup() {
+ when(mavenProject.getFile()).thenReturn(new File(getBasedir(),
"prepare.xml"));
- ReleaseManager mock = mock(ReleaseManager.class);
- mojo.setReleaseManager(mock);
+ when(mavenProject.getGroupId()).thenReturn("groupId");
+ when(mavenProject.getArtifactId()).thenReturn("artifactId");
+ when(mavenProject.getVersion()).thenReturn("1.0.0-SNAPSHOT");
+
when(mavenSession.getProjects()).thenReturn(Collections.singletonList(mavenProject));
+ when(mavenSession.getRequest()).thenReturn(new
DefaultMavenExecutionRequest());
+ }
+
+ @Test
+ @Basedir("/mojos/prepare")
+ @InjectMojo(goal = "prepare", pom = "prepare.xml")
+ @MojoParameter(name = "updateDependencies", value = "false")
+ void testPrepare(PrepareReleaseMojo mojo) throws Exception {
// execute
mojo.execute();
ArgumentCaptor<ReleasePrepareRequest> prepareRequest =
ArgumentCaptor.forClass(ReleasePrepareRequest.class);
// verify
- verify(mock).prepare(prepareRequest.capture());
+ verify(releaseManagerMock).prepare(prepareRequest.capture());
assertThat(
prepareRequest.getValue().getReleaseDescriptorBuilder(),
@@ -86,18 +123,13 @@ public class PrepareReleaseMojoTest extends
AbstractMojoTestCase {
assertThat(releaseDescriptor.isUpdateDependencies(), is(false));
}
- public void testPrepareWithExecutionException() throws Exception {
- File testFile =
getTestFile("target/test-classes/mojos/prepare/prepare.xml");
- final PrepareReleaseMojo mojo = lookupMojo("prepare", testFile);
- mojo.getProject().setFile(testFile);
- setDefaults(mojo);
- mojo.setBasedir(testFile.getParentFile());
- mojo.setPomFileName("pom.xml");
- setVariableValueToObject(mojo, "session",
newMavenSession(mojo.project));
-
- ReleaseManager mock = mock(ReleaseManager.class);
- doThrow(new
ReleaseExecutionException("...")).when(mock).prepare(isA(ReleasePrepareRequest.class));
- mojo.setReleaseManager(mock);
+ @Test
+ @Basedir("/mojos/prepare")
+ @InjectMojo(goal = "prepare", pom = "prepare.xml")
+ void testPrepareWithExecutionException(PrepareReleaseMojo mojo) throws
Exception {
+ doThrow(new ReleaseExecutionException("..."))
+ .when(releaseManagerMock)
+ .prepare(isA(ReleasePrepareRequest.class));
// execute
try {
@@ -105,28 +137,21 @@ public class PrepareReleaseMojoTest extends
AbstractMojoTestCase {
fail("Should have thrown an exception");
} catch (MojoExecutionException e) {
- assertEquals(
- "Check cause", ReleaseExecutionException.class,
e.getCause().getClass());
+ assertEquals(ReleaseExecutionException.class,
e.getCause().getClass(), "Check cause");
}
// verify
- verify(mock).prepare(isA(ReleasePrepareRequest.class));
- verifyNoMoreInteractions(mock);
+ verify(releaseManagerMock).prepare(isA(ReleasePrepareRequest.class));
+ verifyNoMoreInteractions(releaseManagerMock);
}
- public void testPrepareWithExecutionFailure() throws Exception {
- File testFile =
getTestFile("target/test-classes/mojos/prepare/prepare.xml");
- final PrepareReleaseMojo mojo = lookupMojo("prepare", testFile);
- mojo.getProject().setFile(testFile);
- setDefaults(mojo);
- mojo.setBasedir(testFile.getParentFile());
- mojo.setPomFileName("pom.xml");
- setVariableValueToObject(mojo, "session",
newMavenSession(mojo.project));
+ @Test
+ @Basedir("/mojos/prepare")
+ @InjectMojo(goal = "prepare", pom = "prepare.xml")
+ void testPrepareWithExecutionFailure(PrepareReleaseMojo mojo) throws
Exception {
- ReleaseManager mock = mock(ReleaseManager.class);
ReleaseFailureException cause = new ReleaseFailureException("...");
- doThrow(cause).when(mock).prepare(isA(ReleasePrepareRequest.class));
- mojo.setReleaseManager(mock);
+
doThrow(cause).when(releaseManagerMock).prepare(isA(ReleasePrepareRequest.class));
// execute
try {
@@ -134,56 +159,37 @@ public class PrepareReleaseMojoTest extends
AbstractMojoTestCase {
fail("Should have thrown an exception");
} catch (MojoFailureException e) {
- assertEquals("Check cause exists", cause, e.getCause());
+ assertEquals(cause, e.getCause(), "Check cause exists");
}
// verify
- verify(mock).prepare(isA(ReleasePrepareRequest.class));
- verifyNoMoreInteractions(mock);
+ verify(releaseManagerMock).prepare(isA(ReleasePrepareRequest.class));
+ verifyNoMoreInteractions(releaseManagerMock);
}
- public void testLineSeparatorInPrepareWithPom() throws Exception {
- File testFile =
getTestFile("target/test-classes/mojos/prepare/prepare.xml");
- final PrepareWithPomReleaseMojo mojo = lookupMojo("prepare-with-pom",
testFile);
- mojo.getProject().setFile(testFile);
- setDefaults(mojo);
- setVariableValueToObject(mojo, "generateReleasePoms", Boolean.TRUE);
- mojo.setBasedir(testFile.getParentFile());
- mojo.setPomFileName("pom.xml");
- mojo.project.setFile(testFile);
- setVariableValueToObject(mojo, "session",
newMavenSession(mojo.project));
-
- ReleaseManager mock = mock(ReleaseManager.class);
- mojo.setReleaseManager(mock);
-
+ @Test
+ @Basedir("/mojos/prepare")
+ @InjectMojo(goal = "prepare-with-pom", pom = "prepare.xml")
+ void testLineSeparatorInPrepareWithPom(PrepareReleaseMojo mojo) throws
Exception {
int times = 1;
- testLineSeparator(null, "\n", mojo, mock, times++);
- testLineSeparator("source", "\n", mojo, mock, times++);
- testLineSeparator("cr", "\r", mojo, mock, times++);
- testLineSeparator("lf", "\n", mojo, mock, times++);
- testLineSeparator("crlf", "\r\n", mojo, mock, times++);
- testLineSeparator("system", System.lineSeparator(), mojo, mock,
times++);
+ testLineSeparator(null, "\n", mojo, releaseManagerMock, times++);
+ testLineSeparator("source", "\n", mojo, releaseManagerMock, times++);
+ testLineSeparator("cr", "\r", mojo, releaseManagerMock, times++);
+ testLineSeparator("lf", "\n", mojo, releaseManagerMock, times++);
+ testLineSeparator("crlf", "\r\n", mojo, releaseManagerMock, times++);
+ testLineSeparator("system", System.lineSeparator(), mojo,
releaseManagerMock, times++);
}
- public void testLineSeparatorInPrepare() throws Exception {
- File testFile =
getTestFile("target/test-classes/mojos/prepare/prepare.xml");
- final PrepareReleaseMojo mojo = lookupMojo("prepare", testFile);
- mojo.getProject().setFile(testFile);
- setDefaults(mojo);
- mojo.setBasedir(testFile.getParentFile());
- mojo.setPomFileName("pom.xml");
- mojo.project.setFile(testFile);
- setVariableValueToObject(mojo, "session",
newMavenSession(mojo.project));
-
- ReleaseManager mock = mock(ReleaseManager.class);
- mojo.setReleaseManager(mock);
-
+ @Test
+ @Basedir("/mojos/prepare")
+ @InjectMojo(goal = "prepare", pom = "prepare.xml")
+ void testLineSeparatorInPrepare(PrepareReleaseMojo mojo) throws Exception {
int times = 1;
- testLineSeparator(null, "\n", mojo, mock, times++);
- testLineSeparator("source", "\n", mojo, mock, times++);
- testLineSeparator("cr", "\r", mojo, mock, times++);
- testLineSeparator("lf", "\n", mojo, mock, times++);
- testLineSeparator("crlf", "\r\n", mojo, mock, times++);
- testLineSeparator("system", System.lineSeparator(), mojo, mock,
times++);
+ testLineSeparator(null, "\n", mojo, releaseManagerMock, times++);
+ testLineSeparator("source", "\n", mojo, releaseManagerMock, times++);
+ testLineSeparator("cr", "\r", mojo, releaseManagerMock, times++);
+ testLineSeparator("lf", "\n", mojo, releaseManagerMock, times++);
+ testLineSeparator("crlf", "\r\n", mojo, releaseManagerMock, times++);
+ testLineSeparator("system", System.lineSeparator(), mojo,
releaseManagerMock, times++);
}
private void testLineSeparator(
diff --git
a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/StageReleaseMojoTest.java
b/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/StageReleaseMojoTest.java
index 04033fce..93e195d3 100644
---
a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/StageReleaseMojoTest.java
+++
b/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/StageReleaseMojoTest.java
@@ -18,40 +18,81 @@
*/
package org.apache.maven.plugins.release;
-import java.io.File;
+import javax.inject.Inject;
-import org.apache.maven.model.DistributionManagement;
-import org.apache.maven.model.Site;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import java.io.File;
+import java.util.Collections;
+
+import org.apache.maven.api.di.Provides;
+import org.apache.maven.api.plugin.testing.Basedir;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoTest;
+import org.apache.maven.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.release.ReleaseManager;
import org.apache.maven.shared.release.ReleasePerformRequest;
import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
-import static org.mockito.Mockito.mock;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.AssertionsKt.assertNotNull;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
/**
* Test release:stage.
*
* @author <a href="mailto:[email protected]">Brett Porter</a>
*/
-public class StageReleaseMojoTest extends AbstractMojoTestCase {
- private File workingDirectory;
+@ExtendWith(MockitoExtension.class)
+@MojoTest
+class StageReleaseMojoTest {
+ @Mock
+ private ReleaseManager releaseManagerMock;
+
+ @Inject
+ private MavenProject mavenProject;
+
+ @Inject
+ private MavenSession mavenSession;
+
+ @Provides
+ private ReleaseManager releaseManager() {
+ return releaseManagerMock;
+ }
+
+ @BeforeEach
+ void setup() {
+ when(mavenProject.getFile()).thenReturn(new File("pom.xml"));
+
when(mavenSession.getProjects()).thenReturn(Collections.singletonList(mavenProject));
+ }
+
+ private void prepareMocks() {
+ when(mavenSession.getRequest()).thenReturn(new
DefaultMavenExecutionRequest());
- public void testStage() throws Exception {
- StageReleaseMojo mojo = getMojoWithProjectSite("stage.xml");
+ when(mavenProject.getGroupId()).thenReturn("groupId");
+ when(mavenProject.getArtifactId()).thenReturn("artifactId");
+ when(mavenProject.getVersion()).thenReturn("1.0.0-SNAPSHOT");
+ }
- ReleaseManager mock = mock(ReleaseManager.class);
- mojo.setReleaseManager(mock);
+ @Test
+ @Basedir("/mojos/stage")
+ @InjectMojo(goal = "stage", pom = "stage.xml")
+ void testStage(StageReleaseMojo mojo) throws Exception {
+ prepareMocks();
mojo.execute();
// verify
ArgumentCaptor<ReleasePerformRequest> argument =
ArgumentCaptor.forClass(ReleasePerformRequest.class);
- verify(mock).perform(argument.capture());
+ verify(releaseManagerMock).perform(argument.capture());
assertNotNull(argument.getValue().getReleaseDescriptorBuilder());
assertNotNull(argument.getValue().getReleaseEnvironment());
assertNotNull(argument.getValue().getReactorProjects());
@@ -62,11 +103,13 @@ public class StageReleaseMojoTest extends
AbstractMojoTestCase {
assertEquals("deploy site:stage-deploy",
releaseDescriptor.getPerformGoals());
assertEquals("-DskipTests -DaltDeploymentRepository=\"staging\"",
releaseDescriptor.getAdditionalArguments());
- verifyNoMoreInteractions(mock);
+ verifyNoMoreInteractions(releaseManagerMock);
}
- public void testCreateGoals() throws Exception {
- StageReleaseMojo mojo = getMojoWithProjectSite("stage.xml");
+ @Test
+ @Basedir("/mojos/stage")
+ @InjectMojo(goal = "stage", pom = "stage.xml")
+ void testCreateGoals(StageReleaseMojo mojo) {
mojo.createGoals();
assertEquals("deploy site:stage-deploy", mojo.goals);
mojo.goals = "deploy site:deploy";
@@ -74,31 +117,15 @@ public class StageReleaseMojoTest extends
AbstractMojoTestCase {
assertEquals("deploy site:stage-deploy", mojo.goals);
}
- public void testCreateArguments() throws Exception {
- StageReleaseMojo mojo = getMojoWithProjectSite("stage.xml");
+ @Test
+ @Basedir("/mojos/stage")
+ @InjectMojo(goal = "stage", pom = "stage.xml")
+ void testCreateArguments(StageReleaseMojo mojo) {
+ prepareMocks();
+
mojo.setDeploymentRepository();
ReleaseDescriptorBuilder.BuilderReleaseDescriptor releaseDescriptor =
mojo.createReleaseDescriptor().build();
assertEquals("-DskipTests -DaltDeploymentRepository=\"staging\"",
releaseDescriptor.getAdditionalArguments());
}
-
- private StageReleaseMojo getMojoWithProjectSite(String fileName) throws
Exception {
- StageReleaseMojo mojo = lookupMojo("stage", new File(workingDirectory,
fileName));
- mojo.setBasedir(workingDirectory);
- mojo.setPomFileName("pom.xml");
-
- MavenProject project = getVariableValueFromObject(mojo, "project");
- DistributionManagement distributionManagement = new
DistributionManagement();
- distributionManagement.setSite(new Site());
- project.setDistributionManagement(distributionManagement);
-
- setVariableValueToObject(mojo, "session", newMavenSession(project));
-
- return mojo;
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- workingDirectory = getTestFile("target/test-classes/mojos/stage");
- }
}
diff --git
a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/stubs/FlatMultiModuleMavenProjectStub.java
b/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/stubs/FlatMultiModuleMavenProjectStub.java
deleted file mode 100644
index 0b10b37d..00000000
---
a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/stubs/FlatMultiModuleMavenProjectStub.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.release.stubs;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.model.DistributionManagement;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Scm;
-
-/**
- * <p>Stub for a MavenProject with a flat structure.</p>
- *
- * <p>TODO: shouldn't need to do this, but the "stub" in the harness just
throws away values you set.
- * Just overriding the ones I need for this plugin.</p>
- *
- * @author <a href="mailto:[email protected]">Maria Odea Ching</a>
- */
-/*
- * @noinspection ClassNameSameAsAncestorName
- */
-public class FlatMultiModuleMavenProjectStub extends
org.apache.maven.plugin.testing.stubs.MavenProjectStub {
- public void setDistributionManagement(DistributionManagement
distributionManagement) {
- getModel().setDistributionManagement(distributionManagement);
- }
-
- public Model getModel() {
- Model model = super.getModel();
- if (model == null) {
- model = new Model();
- setModel(model);
- }
- return model;
- }
-
- public DistributionManagement getDistributionManagement() {
- return getModel().getDistributionManagement();
- }
-
- public List<String> getModules() {
- List<String> modules = new ArrayList<String>();
- modules.add("../core");
- modules.add("../webapp");
- modules.add("../commons");
-
- return modules;
- }
-
- public File getBasedir() {
- return new File("/flat-multi-module/root-project").getAbsoluteFile();
- }
-
- public Scm getScm() {
- Scm scm = new Scm();
-
scm.setConnection("scm:svn:file://localhost/target/svnroot/flat-multi-module/trunk/root-project");
-
- return scm;
- }
-
- @Override
- public String getGroupId() {
- return "GROUPID";
- }
-
- @Override
- public String getArtifactId() {
- return "ARTIFACTID";
- }
-
- @Override
- public String getVersion() {
- return "VERSION";
- }
-}
diff --git
a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/stubs/MavenProjectStub.java
b/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/stubs/MavenProjectStub.java
deleted file mode 100644
index f50f9ec4..00000000
---
a/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/stubs/MavenProjectStub.java
+++ /dev/null
@@ -1,64 +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.release.stubs;
-
-import org.apache.maven.model.DistributionManagement;
-import org.apache.maven.model.Model;
-
-/**
- * <p>Stub for MavenProject.</p>
- *
- * <p>TODO: shouldn't need to do this, but the "stub" in the harness just
throws away values you set.
- * Just overriding the ones I need for this plugin.</p>
- *
- * @author <a href="mailto:[email protected]">Brett Porter</a>
- */
-public class MavenProjectStub extends
org.apache.maven.plugin.testing.stubs.MavenProjectStub {
- public void setDistributionManagement(DistributionManagement
distributionManagement) {
- getModel().setDistributionManagement(distributionManagement);
- }
-
- public Model getModel() {
- Model model = super.getModel();
- if (model == null) {
- model = new Model();
- setModel(model);
- }
- return model;
- }
-
- public DistributionManagement getDistributionManagement() {
- return getModel().getDistributionManagement();
- }
-
- @Override
- public String getGroupId() {
- return "GROUPID";
- }
-
- @Override
- public String getArtifactId() {
- return "ARTIFACTID";
- }
-
- @Override
- public String getVersion() {
- return "VERSION";
- }
-}
diff --git a/maven-release-plugin/src/test/resources/mojos/clean/clean.xml
b/maven-release-plugin/src/test/resources/mojos/clean/clean.xml
deleted file mode 100644
index 2bb1c57a..00000000
--- a/maven-release-plugin/src/test/resources/mojos/clean/clean.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>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-release-plugin</artifactId>
- <configuration>
- <reactorProjects>
- <reactorProject
implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub" />
- </reactorProjects>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
\ No newline at end of file
diff --git
a/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml
b/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml
index cda042e6..e9fc9fa9 100644
---
a/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml
+++
b/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml
@@ -24,11 +24,6 @@
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
- <settings implementation="org.apache.maven.settings.Settings" />
- <project
implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub" />
- <reactorProjects>
- <reactorProject
implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub" />
- </reactorProjects>
<workingDirectory>${basedir}/target/checkout</workingDirectory>
<useReleaseProfile>true</useReleaseProfile>
<goals>deploy site-deploy</goals>
diff --git
a/maven-release-plugin/src/test/resources/mojos/perform/perform-with-flat-structure.xml
b/maven-release-plugin/src/test/resources/mojos/perform/perform-with-flat-structure.xml
index 1b5dc1ec..8ef01faa 100644
---
a/maven-release-plugin/src/test/resources/mojos/perform/perform-with-flat-structure.xml
+++
b/maven-release-plugin/src/test/resources/mojos/perform/perform-with-flat-structure.xml
@@ -24,11 +24,6 @@
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
- <settings implementation="org.apache.maven.settings.Settings" />
- <project
implementation="org.apache.maven.plugins.release.stubs.FlatMultiModuleMavenProjectStub"
/>
- <reactorProjects>
- <reactorProject
implementation="org.apache.maven.plugins.release.stubs.FlatMultiModuleMavenProjectStub"
/>
- </reactorProjects>
<workingDirectory>${basedir}/target/checkout</workingDirectory>
<useReleaseProfile>true</useReleaseProfile>
<connectionUrl>scm:svn:file://localhost/target/svnroot/flat-multi-module/trunk/root-project</connectionUrl>
diff --git
a/maven-release-plugin/src/test/resources/mojos/perform/perform-with-multiline-goals.xml
b/maven-release-plugin/src/test/resources/mojos/perform/perform-with-multiline-goals.xml
index 493c00e7..e37e57de 100644
---
a/maven-release-plugin/src/test/resources/mojos/perform/perform-with-multiline-goals.xml
+++
b/maven-release-plugin/src/test/resources/mojos/perform/perform-with-multiline-goals.xml
@@ -24,11 +24,6 @@
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
- <settings implementation="org.apache.maven.settings.Settings" />
- <project
implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub" />
- <reactorProjects>
- <reactorProject
implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub" />
- </reactorProjects>
<workingDirectory>${basedir}/target/checkout</workingDirectory>
<useReleaseProfile>true</useReleaseProfile>
<goals>
diff --git
a/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml
b/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml
index b2dfe64a..d2125ec0 100644
--- a/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml
+++ b/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml
@@ -24,11 +24,6 @@
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
- <settings implementation="org.apache.maven.settings.Settings" />
- <project
implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub" />
- <reactorProjects>
- <reactorProject
implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub" />
- </reactorProjects>
<workingDirectory>${basedir}/target/checkout</workingDirectory>
<useReleaseProfile>true</useReleaseProfile>
<connectionUrl>scm-url</connectionUrl>
diff --git
a/maven-release-plugin/src/test/resources/mojos/perform/perform-without-site.xml
b/maven-release-plugin/src/test/resources/mojos/perform/perform-without-site.xml
index d661d428..fc15a043 100644
---
a/maven-release-plugin/src/test/resources/mojos/perform/perform-without-site.xml
+++
b/maven-release-plugin/src/test/resources/mojos/perform/perform-without-site.xml
@@ -24,11 +24,6 @@
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
- <settings implementation="org.apache.maven.settings.Settings" />
- <project
implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub" />
- <reactorProjects>
- <reactorProject
implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub" />
- </reactorProjects>
<workingDirectory>${basedir}/target/checkout</workingDirectory>
<goals>deploy</goals>
<useReleaseProfile>true</useReleaseProfile>
diff --git a/maven-release-plugin/src/test/resources/mojos/perform/perform.xml
b/maven-release-plugin/src/test/resources/mojos/perform/perform.xml
index ebcf45af..c794be4d 100644
--- a/maven-release-plugin/src/test/resources/mojos/perform/perform.xml
+++ b/maven-release-plugin/src/test/resources/mojos/perform/perform.xml
@@ -24,11 +24,6 @@
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
- <settings implementation="org.apache.maven.settings.Settings" />
- <project
implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub" />
- <reactorProjects>
- <reactorProject
implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub" />
- </reactorProjects>
<workingDirectory>${basedir}/target/checkout</workingDirectory>
<goals>deploy site-deploy</goals>
<useReleaseProfile>true</useReleaseProfile>
diff --git a/maven-release-plugin/src/test/resources/mojos/prepare/prepare.xml
b/maven-release-plugin/src/test/resources/mojos/prepare/prepare.xml
index ef619798..577d4e82 100644
--- a/maven-release-plugin/src/test/resources/mojos/prepare/prepare.xml
+++ b/maven-release-plugin/src/test/resources/mojos/prepare/prepare.xml
@@ -24,11 +24,6 @@
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
- <settings implementation="org.apache.maven.settings.Settings" />
- <project
implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub" />
- <reactorProjects>
- <reactorProject
implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub" />
- </reactorProjects>
<resume>true</resume>
</configuration>
</plugin>
diff --git a/maven-release-plugin/src/test/resources/mojos/stage/stage.xml
b/maven-release-plugin/src/test/resources/mojos/stage/stage.xml
index 6a54431c..543a5852 100644
--- a/maven-release-plugin/src/test/resources/mojos/stage/stage.xml
+++ b/maven-release-plugin/src/test/resources/mojos/stage/stage.xml
@@ -24,11 +24,6 @@
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
- <settings implementation="org.apache.maven.settings.Settings" />
- <project
implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub" />
- <reactorProjects>
- <reactorProject
implementation="org.apache.maven.plugins.release.stubs.MavenProjectStub" />
- </reactorProjects>
<workingDirectory>${basedir}/target/checkout</workingDirectory>
<stagingRepository>staging</stagingRepository>
<goals>deploy site-deploy</goals>
diff --git a/pom.xml b/pom.xml
index 3d1d5ed4..d1d108b0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -94,7 +94,6 @@
<resolverVersion>1.9.24</resolverVersion>
<wagonVersion>3.5.3</wagonVersion>
<slf4jVersion>1.7.36</slf4jVersion>
- <junitVersion>4.13.2</junitVersion>
<!-- TODO: remove with next parent -->
<version.maven-invoker-plugin>3.9.1</version.maven-invoker-plugin>
@@ -271,12 +270,6 @@
<artifactId>jdom2</artifactId>
<version>2.0.6.1</version>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junitVersion}</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>