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-scm.git
The following commit(s) were added to refs/heads/master by this push:
new 45c3c30f3 Start tests migration to JUnit 5
45c3c30f3 is described below
commit 45c3c30f393eb7c4e48da6e7d7311fa456284891
Author: Slawomir Jaranowski <[email protected]>
AuthorDate: Sun Nov 16 17:39:30 2025 +0100
Start tests migration to JUnit 5
- first step - easy cases
---
maven-scm-api/pom.xml | 4 +-
.../java/org/apache/maven/scm/ChangeFileTest.java | 14 ++--
.../java/org/apache/maven/scm/ChangeSetTest.java | 80 +++++++++++-----------
.../java/org/apache/maven/scm/ScmFileSetTest.java | 26 +++----
.../java/org/apache/maven/scm/ScmResultTest.java | 18 ++---
.../apache/maven/scm/manager/ScmManagerTest.java | 8 +--
.../apache/maven/scm/provider/ScmUrlUtilsTest.java | 16 ++---
.../apache/maven/scm/util/FilenameUtilsTest.java | 10 +--
maven-scm-plugin/pom.xml | 11 +++
.../apache/maven/scm/plugin/BootstrapMojoTest.java | 31 +++++----
.../apache/maven/scm/plugin/StatusMojoTest.java | 34 +++++----
.../apache/maven/scm/plugin/ValidateMojoTest.java | 43 ++++++------
.../src/test/resources/mojos/status/status.xml | 1 -
maven-scm-test/pom.xml | 6 ++
.../maven/scm/manager/ScmManagerStubTest.java | 8 +--
pom.xml | 1 -
16 files changed, 165 insertions(+), 146 deletions(-)
diff --git a/maven-scm-api/pom.xml b/maven-scm-api/pom.xml
index f285b7641..841cf8296 100644
--- a/maven-scm-api/pom.xml
+++ b/maven-scm-api/pom.xml
@@ -46,8 +46,8 @@
<version>3.20.0</version>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git
a/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeFileTest.java
b/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeFileTest.java
index 809f3f69d..0b314305c 100644
--- a/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeFileTest.java
+++ b/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeFileTest.java
@@ -18,17 +18,17 @@
*/
package org.apache.maven.scm;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* @author <a href="mailto:[email protected]">Emmanuel Venisse </a>
*/
-public class ChangeFileTest {
+class ChangeFileTest {
@Test
- public void testNewFile() {
+ void testNewFile() {
ChangeFile f = new ChangeFile("test.java");
assertEquals("test.java", f.getName());
assertNull(f.getRevision());
@@ -36,7 +36,7 @@ public void testNewFile() {
}
@Test
- public void testNewFileRevision() {
+ void testNewFileRevision() {
ChangeFile f = new ChangeFile("test.java", "1.2.3");
assertEquals("test.java", f.getName());
assertEquals("1.2.3", f.getRevision());
@@ -44,7 +44,7 @@ public void testNewFileRevision() {
}
@Test
- public void testNewRevisionFile() {
+ void testNewRevisionFile() {
ChangeFile f = new ChangeFile("test.java", "revision1");
assertEquals("test.java", f.getName());
assertEquals("revision1", f.getRevision());
diff --git
a/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeSetTest.java
b/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeSetTest.java
index 248abad8e..f2676bf03 100644
--- a/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeSetTest.java
+++ b/maven-scm-api/src/test/java/org/apache/maven/scm/ChangeSetTest.java
@@ -22,14 +22,14 @@
import java.util.Calendar;
import java.util.Date;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for the {@link ChangeSet}class
@@ -37,7 +37,7 @@
* @author dion
*
*/
-public class ChangeSetTest {
+class ChangeSetTest {
/**
* the {@link ChangeSet} used for testing
*/
@@ -46,8 +46,8 @@ public class ChangeSetTest {
/**
* Initialize per test data
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
instance = createInstance();
}
@@ -64,10 +64,10 @@ private static ChangeSet createInstance() {
* Test of addFile methods: using ChangeFile
*/
@Test
- public void testAddFileWithFile() {
+ void testAddFileWithFile() {
ChangeFile file = new ChangeFile("maven:dummy");
instance.addFile(file);
- assertTrue("File name not found in list",
instance.toString().indexOf("maven:dummy") != -1);
+ assertTrue(instance.toString().indexOf("maven:dummy") != -1, "File
name not found in list");
assertTrue(instance.containsFilename("maven:"));
assertTrue(instance.containsFilename(":dummy"));
@@ -80,93 +80,93 @@ public void testAddFileWithFile() {
* Test of toString method
*/
@Test
- public void testToString() {
+ void testToString() {
// dion, Mon Apr 01 00:00:00 EST 2002, comment
String value = instance.toString();
- assertTrue("author not found in string", value.indexOf("dion") != -1);
- assertTrue("comment not found in string", value.indexOf("comment") !=
-1);
- assertTrue("date not found in string", value.indexOf("Mon Apr 01") !=
-1);
+ assertTrue(value.indexOf("dion") != -1, "author not found in string");
+ assertTrue(value.indexOf("comment") != -1, "comment not found in
string");
+ assertTrue(value.indexOf("Mon Apr 01") != -1, "date not found in
string");
}
/**
* Test of getAuthor method
*/
@Test
- public void testGetAuthor() {
- assertEquals("Author value not retrieved correctly", "dion",
instance.getAuthor());
+ void testGetAuthor() {
+ assertEquals("dion", instance.getAuthor(), "Author value not retrieved
correctly");
}
/**
* Test of setAuthor method
*/
@Test
- public void testSetAuthor() {
+ void testSetAuthor() {
instance.setAuthor("maven:dion");
- assertEquals("Author not set correctly", "maven:dion",
instance.getAuthor());
+ assertEquals("maven:dion", instance.getAuthor(), "Author not set
correctly");
}
/**
* Test of getComment method
*/
@Test
- public void testGetComment() {
- assertEquals("Comment value not retrieved correctly", "comment",
instance.getComment());
+ void testGetComment() {
+ assertEquals("comment", instance.getComment(), "Comment value not
retrieved correctly");
}
/**
* Test of setComment method
*/
@Test
- public void testSetComment() {
+ void testSetComment() {
instance.setComment("maven:comment");
- assertEquals("Comment not set correctly", "maven:comment",
instance.getComment());
+ assertEquals("maven:comment", instance.getComment(), "Comment not set
correctly");
}
/**
* Test of getDate method
*/
@Test
- public void testGetDate() {
- assertEquals("Date value not retrieved correctly", getDate(2002, 3,
1), instance.getDate());
+ void testGetDate() {
+ assertEquals(getDate(2002, 3, 1), instance.getDate(), "Date value not
retrieved correctly");
}
/**
* Test of setDate method with Date object
*/
@Test
- public void testSetDate() {
+ void testSetDate() {
Calendar cal = Calendar.getInstance();
Date date = cal.getTime();
instance.setDate(date);
- assertEquals("Date value not set correctly", date, instance.getDate());
+ assertEquals(date, instance.getDate(), "Date value not set correctly");
}
/**
* Test of setDate method with String
*/
@Test
- public void testSetDateFromString() {
+ void testSetDateFromString() {
instance.setDate("2002/03/04 00:00:00");
- assertEquals("Date value not set correctly from a string",
getDate(2002, 2, 4), instance.getDate());
+ assertEquals(getDate(2002, 2, 4), instance.getDate(), "Date value not
set correctly from a string");
}
/**
* Test of getDateFormatted method
*/
@Test
- public void testGetDateFormatted() {
- assertEquals("Date not formatted correctly", "2002-04-01",
instance.getDateFormatted());
+ void testGetDateFormatted() {
+ assertEquals("2002-04-01", instance.getDateFormatted(), "Date not
formatted correctly");
}
/**
* Test of getDateFormatted method
*/
@Test
- public void testGetTimeFormatted() {
- assertEquals("Time not formatted correctly", "00:00:00",
instance.getTimeFormatted());
+ void testGetTimeFormatted() {
+ assertEquals("00:00:00", instance.getTimeFormatted(), "Time not
formatted correctly");
}
- public static Date getDate(int year, int month, int day) {
+ static Date getDate(int year, int month, int day) {
Calendar cal = Calendar.getInstance();
cal.set(year, month, day, 0, 0, 0);
@@ -176,7 +176,7 @@ public static Date getDate(int year, int month, int day) {
}
@Test
- public void testEscapeValue() {
+ void testEscapeValue() {
assertEquals("", ChangeSet.escapeValue(""));
assertEquals("'", ChangeSet.escapeValue("'"));
assertEquals("a", ChangeSet.escapeValue("a"));
@@ -188,7 +188,7 @@ public void testEscapeValue() {
}
@Test
- public void testEquals() {
+ void testEquals() {
ChangeSet instance2 = createInstance();
assertEquals(instance, instance2);
@@ -200,7 +200,7 @@ public void testEquals() {
}
@Test
- public void testHashCode() {
+ void testHashCode() {
int hashCode1 = instance.hashCode();
instance.setAuthor("anotherAuthor");
@@ -210,7 +210,7 @@ public void testHashCode() {
}
@Test
- public void testToXml() {
+ void testToXml() {
String sXml = instance.toXML();
assertNotNull(sXml);
@@ -219,7 +219,7 @@ public void testToXml() {
}
@Test
- public void testToXmlWithFiles() {
+ void testToXmlWithFiles() {
instance.addFile(new ChangeFile("maven1:dummy"));
instance.addFile(new ChangeFile("maven2:dummy2"));
diff --git
a/maven-scm-api/src/test/java/org/apache/maven/scm/ScmFileSetTest.java
b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmFileSetTest.java
index 585499ac5..a3d6faec8 100644
--- a/maven-scm-api/src/test/java/org/apache/maven/scm/ScmFileSetTest.java
+++ b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmFileSetTest.java
@@ -23,19 +23,19 @@
import java.util.Iterator;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author dtran
*/
-public class ScmFileSetTest {
+class ScmFileSetTest {
private static String basedirPath;
- public static String getBasedir() {
+ private static String getBasedir() {
if (basedirPath != null) {
return basedirPath;
}
@@ -54,25 +54,25 @@ private String removeBasedir(String filename) {
}
@Test
- public void testFilesList() throws IOException {
+ void testFilesList() throws IOException {
ScmFileSet fileSet = new ScmFileSet(new File(getBasedir(), "src"),
"**/**");
assertEquals("src", fileSet.getBasedir().getName());
assertEquals("**/**", fileSet.getIncludes());
// assertEquals( ScmFileSet.DEFAULT_EXCLUDES, fileSet.getExcludes() );
assertTrue(
+ fileSet.getFileList().size() > 10,
"List of files should be longer than 10 elements, but
received: "
- + fileSet.getFileList().size(),
- fileSet.getFileList().size() > 10);
+ + fileSet.getFileList().size());
}
@Test
- public void testFilesListWithoutIncludesResultsEmptyList() throws
IOException {
+ void testFilesListWithoutIncludesResultsEmptyList() {
ScmFileSet fileSet = new ScmFileSet(new File(getBasedir(), "src"));
assertEquals(0, fileSet.getFileList().size());
}
@Test
- public void testFilesListExcludes() throws IOException {
+ void testFilesListExcludes() throws IOException {
ScmFileSet fileSet = new ScmFileSet(new File(getBasedir(), "src"),
"**/**", "**/exclude/**");
List<File> files = fileSet.getFileList();
@@ -87,14 +87,14 @@ public void testFilesListExcludes() throws IOException {
}
@Test
- public void testFilesListExcludes2() throws IOException {
+ void testFilesListExcludes2() throws IOException {
ScmFileSet fileSet = new ScmFileSet(new File(getBasedir(), "src"),
"**/scmfileset/**", "**/exclude/**");
assertEquals(2, fileSet.getFileList().size());
}
@Test
- public void testFilesListNoExcludes() throws IOException {
+ void testFilesListNoExcludes() throws IOException {
ScmFileSet fileSet = new ScmFileSet(new File(getBasedir(), "src"),
"**/scmfileset/**");
assertEquals(4, fileSet.getFileList().size());
diff --git
a/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
index b7d80fd16..47a4d1edb 100644
--- a/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
+++ b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
@@ -18,12 +18,12 @@
*/
package org.apache.maven.scm;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-public class ScmResultTest {
+class ScmResultTest {
private static final String PASSWORD = "secr$t";
@@ -36,13 +36,13 @@ public class ScmResultTest {
+ System.lineSeparator() + "fatal: Authentication failed for '" +
SCM_URL_GIT_COLON + "'";
@Test
- public void testPasswordsAreMaskedInOutput() throws Exception {
+ void testPasswordsAreMaskedInOutput() throws Exception {
ScmResult result = new ScmResult("git push", "git-push failed",
MOCK_ERROR_OUTPUT, false);
- assertNotSame("Command output contains password", MOCK_ERROR_OUTPUT,
result.getCommandOutput());
- assertTrue("Command output not masked",
result.getCommandOutput().contains(ScmResult.PASSWORD_PLACE_HOLDER));
+ assertNotSame(MOCK_ERROR_OUTPUT, result.getCommandOutput(), "Command
output contains password");
+
assertTrue(result.getCommandOutput().contains(ScmResult.PASSWORD_PLACE_HOLDER),
"Command output not masked");
result = new ScmResult("git push", "git-push failed",
MOCK_ERROR_MULTILINE_OUTPUT, false);
- assertNotSame("Command output contains password",
MOCK_ERROR_MULTILINE_OUTPUT, result.getCommandOutput());
- assertTrue("Command output not masked",
result.getCommandOutput().contains(ScmResult.PASSWORD_PLACE_HOLDER));
+ assertNotSame(MOCK_ERROR_MULTILINE_OUTPUT, result.getCommandOutput(),
"Command output contains password");
+
assertTrue(result.getCommandOutput().contains(ScmResult.PASSWORD_PLACE_HOLDER),
"Command output not masked");
}
}
diff --git
a/maven-scm-api/src/test/java/org/apache/maven/scm/manager/ScmManagerTest.java
b/maven-scm-api/src/test/java/org/apache/maven/scm/manager/ScmManagerTest.java
index a5d94af2a..a67605b0b 100644
---
a/maven-scm-api/src/test/java/org/apache/maven/scm/manager/ScmManagerTest.java
+++
b/maven-scm-api/src/test/java/org/apache/maven/scm/manager/ScmManagerTest.java
@@ -18,17 +18,17 @@
*/
package org.apache.maven.scm.manager;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author <a href="mailto:[email protected]">Emmanuel Venisse</a>
*
*/
-public class ScmManagerTest {
+class ScmManagerTest {
@Test
- public void testCleanScmUrl() throws Exception {
+ void testCleanScmUrl() {
BasicScmManager manager = new BasicScmManager();
assertEquals(
diff --git
a/maven-scm-api/src/test/java/org/apache/maven/scm/provider/ScmUrlUtilsTest.java
b/maven-scm-api/src/test/java/org/apache/maven/scm/provider/ScmUrlUtilsTest.java
index 507071b11..f3788e906 100644
---
a/maven-scm-api/src/test/java/org/apache/maven/scm/provider/ScmUrlUtilsTest.java
+++
b/maven-scm-api/src/test/java/org/apache/maven/scm/provider/ScmUrlUtilsTest.java
@@ -18,17 +18,17 @@
*/
package org.apache.maven.scm.provider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="mailto:[email protected]">Dennis Lundberg</a>
*
*/
-public class ScmUrlUtilsTest {
+class ScmUrlUtilsTest {
private static final String SCM_URL_INVALID_1 = null;
private static final String SCM_URL_INVALID_2 = "scm";
@@ -46,7 +46,7 @@ public class ScmUrlUtilsTest {
private static final String SCM_URL_VALID_4 =
"scm:a|provider-specific-part";
@Test
- public void testGetProvider() throws Exception {
+ void testGetProvider() {
assertEquals("a", ScmUrlUtils.getProvider(SCM_URL_VALID_1));
assertEquals("a", ScmUrlUtils.getProvider(SCM_URL_VALID_2));
assertEquals("a", ScmUrlUtils.getProvider(SCM_URL_VALID_3));
@@ -54,7 +54,7 @@ public void testGetProvider() throws Exception {
}
@Test
- public void testGetProviderSpecificPart() throws Exception {
+ void testGetProviderSpecificPart() {
assertEquals("", ScmUrlUtils.getProviderSpecificPart(SCM_URL_VALID_1));
assertEquals("", ScmUrlUtils.getProviderSpecificPart(SCM_URL_VALID_2));
assertEquals("provider-specific-part",
ScmUrlUtils.getProviderSpecificPart(SCM_URL_VALID_3));
@@ -62,7 +62,7 @@ public void testGetProviderSpecificPart() throws Exception {
}
@Test
- public void testIsValid() throws Exception {
+ void testIsValid() {
assertTrue(ScmUrlUtils.isValid(SCM_URL_VALID_1));
assertTrue(ScmUrlUtils.isValid(SCM_URL_VALID_2));
assertTrue(ScmUrlUtils.isValid(SCM_URL_VALID_3));
diff --git
a/maven-scm-api/src/test/java/org/apache/maven/scm/util/FilenameUtilsTest.java
b/maven-scm-api/src/test/java/org/apache/maven/scm/util/FilenameUtilsTest.java
index ae40fc8e7..32f4464ec 100644
---
a/maven-scm-api/src/test/java/org/apache/maven/scm/util/FilenameUtilsTest.java
+++
b/maven-scm-api/src/test/java/org/apache/maven/scm/util/FilenameUtilsTest.java
@@ -18,15 +18,15 @@
*/
package org.apache.maven.scm.util;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
-public class FilenameUtilsTest {
+class FilenameUtilsTest {
@Test
- public void testNormalize() {
+ void testNormalize() {
assertNull(FilenameUtils.normalizeFilename((String) null));
assertEquals("", FilenameUtils.normalizeFilename(""));
diff --git a/maven-scm-plugin/pom.xml b/maven-scm-plugin/pom.xml
index e7e54530c..27d8fd5cb 100644
--- a/maven-scm-plugin/pom.xml
+++ b/maven-scm-plugin/pom.xml
@@ -144,6 +144,16 @@
<version>4.13.2</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
@@ -209,6 +219,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
+ <version>3.9.1</version>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<cloneClean>true</cloneClean>
diff --git
a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BootstrapMojoTest.java
b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BootstrapMojoTest.java
index 888bf178d..4f0ff6a6b 100644
---
a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BootstrapMojoTest.java
+++
b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/BootstrapMojoTest.java
@@ -20,11 +20,11 @@
import java.io.File;
-import org.codehaus.plexus.util.FileUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Unit Test for BootstrapMojo
@@ -32,8 +32,11 @@
* @author <a href="mailto:[email protected]">Arne Degenring</a>
*
*/
-@RunWith(JUnit4.class)
-public class BootstrapMojoTest extends AbstractJUnit4MojoTestCase {
+class BootstrapMojoTest {
+
+ @TempDir
+ File tempDir;
+
File checkoutDir;
File projectDir;
@@ -42,25 +45,23 @@ public class BootstrapMojoTest extends
AbstractJUnit4MojoTestCase {
BootstrapMojo bootstrapMojo;
- @Before
- public void setUp() throws Exception {
- super.setUp();
+ @BeforeEach
+ void setUp() throws Exception {
- checkoutDir = getTestFile("target/checkout");
- FileUtils.forceDelete(checkoutDir);
+ checkoutDir = new File(tempDir, "target/checkout");
checkoutDir.mkdirs();
- projectDir = getTestFile("target/checkout/my/project");
+ projectDir = new File(checkoutDir, "my/project");
projectDir.mkdirs();
- goalDir = getTestFile("target/checkout/my/project/modules/1");
+ goalDir = new File(checkoutDir, "my/project/modules/1");
goalDir.mkdirs();
bootstrapMojo = new BootstrapMojo(null, null);
}
@Test
- public void testDetermineWorkingDirectoryPath() throws Exception {
+ void testDetermineWorkingDirectoryPath() throws Exception {
// only checkout dir
assertEquals(checkoutDir.getPath(),
bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, "", ""));
assertEquals(checkoutDir.getPath(),
bootstrapMojo.determineWorkingDirectoryPath(checkoutDir, null, null));
diff --git
a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/StatusMojoTest.java
b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/StatusMojoTest.java
index 242dea07d..6a65d4c4c 100644
---
a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/StatusMojoTest.java
+++
b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/StatusMojoTest.java
@@ -18,28 +18,34 @@
*/
package org.apache.maven.scm.plugin;
-import java.io.File;
-
+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.scm.ScmTestCase;
import org.apache.maven.scm.provider.svn.SvnScmTestUtils;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
-import static org.apache.maven.scm.ScmTestCase.checkSystemCmdPresence;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
/**
* @author <a href="mailto:[email protected]">Emmanuel Venisse</a>
*
*/
-@RunWith(JUnit4.class)
-public class StatusMojoTest extends AbstractJUnit4MojoTestCase {
- @Test
- public void testStatusMojo() throws Exception {
- checkSystemCmdPresence(SvnScmTestUtils.SVN_COMMAND_LINE);
+@MojoTest
+@EnabledIf(
+ value = "isSvnPresence",
+ disabledReason = "Skipping SVN tests since SVN command line client is
not available")
+class StatusMojoTest {
- StatusMojo mojo = (StatusMojo) lookupMojo("status",
getTestFile("src/test/resources/mojos/status/status.xml"));
+ static boolean isSvnPresence() {
+ return ScmTestCase.isSystemCmd(SvnScmTestUtils.SVN_COMMAND_LINE);
+ }
- mojo.setWorkingDirectory(new File(getBasedir()));
- mojo.execute();
+ @Test
+ @Basedir("/mojos/status/")
+ @InjectMojo(goal = "status", pom = "status.xml")
+ void testStatusMojo(StatusMojo mojo) {
+ assertDoesNotThrow(mojo::execute);
}
}
diff --git
a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ValidateMojoTest.java
b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ValidateMojoTest.java
index 5289b7cb8..f8565003b 100644
---
a/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ValidateMojoTest.java
+++
b/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ValidateMojoTest.java
@@ -18,41 +18,38 @@
*/
package org.apache.maven.scm.plugin;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoTest;
import org.apache.maven.plugin.MojoExecutionException;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author <a href="mailto:[email protected]">Emmanuel Venisse</a>
*
*/
-@RunWith(JUnit4.class)
-public class ValidateMojoTest extends AbstractJUnit4MojoTestCase {
+@MojoTest
+class ValidateMojoTest {
+
@Test
- public void testValidateWithoutScmUrl() throws Exception {
- ValidateMojo mojo = (ValidateMojo)
- lookupMojo("validate",
getTestFile("src/test/resources/mojos/validate/validateWithoutScmUrl.xml"));
- mojo.execute();
+ @InjectMojo(goal = "validate", pom =
"classpath:/mojos/validate/validateWithoutScmUrl.xml")
+ void testValidateWithoutScmUrl(ValidateMojo mojo) {
+ assertDoesNotThrow(mojo::execute);
}
@Test
- public void testValidateWithValidScmUrls() throws Exception {
- ValidateMojo mojo = (ValidateMojo)
- lookupMojo("validate",
getTestFile("src/test/resources/mojos/validate/validateWithValidScmUrls.xml"));
- mojo.execute();
+ @InjectMojo(goal = "validate", pom =
"classpath:/mojos/validate/validateWithValidScmUrls.xml")
+ void testValidateWithValidScmUrls(ValidateMojo mojo) {
+ assertDoesNotThrow(mojo::execute);
}
@Test
- public void testValidateWithInvalidScmUrls() throws Exception {
- ValidateMojo mojo = (ValidateMojo)
- lookupMojo("validate",
getTestFile("src/test/resources/mojos/validate/validateWithInvalidScmUrls.xml"));
- try {
- mojo.execute();
-
- fail("mojo execution must fail.");
- } catch (MojoExecutionException e) {
- assertNotNull(e.getMessage());
- }
+ @InjectMojo(goal = "validate", pom =
"classpath:/mojos/validate/validateWithInvalidScmUrls.xml")
+ void testValidateWithInvalidScmUrls(ValidateMojo mojo) throws Exception {
+ MojoExecutionException exception =
assertThrows(MojoExecutionException.class, mojo::execute);
+ assertNotNull(exception.getMessage());
}
}
diff --git a/maven-scm-plugin/src/test/resources/mojos/status/status.xml
b/maven-scm-plugin/src/test/resources/mojos/status/status.xml
index 978bb9687..5b8395cb1 100644
--- a/maven-scm-plugin/src/test/resources/mojos/status/status.xml
+++ b/maven-scm-plugin/src/test/resources/mojos/status/status.xml
@@ -23,7 +23,6 @@
<plugin>
<artifactId>maven-scm-plugin</artifactId>
<configuration>
- <settings implementation="org.apache.maven.settings.Settings"/>
<connectionType>connection</connectionType>
<connectionUrl>scm:svn:file:///${basedir}/target/repository/trunk</connectionUrl>
</configuration>
diff --git a/maven-scm-test/pom.xml b/maven-scm-test/pom.xml
index ce46b3792..292b28de6 100644
--- a/maven-scm-test/pom.xml
+++ b/maven-scm-test/pom.xml
@@ -75,6 +75,12 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <!-- first step - only used for test -->
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
diff --git
a/maven-scm-test/src/test/java/org/apache/maven/scm/manager/ScmManagerStubTest.java
b/maven-scm-test/src/test/java/org/apache/maven/scm/manager/ScmManagerStubTest.java
index 4c40d45a0..0cdd6d16d 100644
---
a/maven-scm-test/src/test/java/org/apache/maven/scm/manager/ScmManagerStubTest.java
+++
b/maven-scm-test/src/test/java/org/apache/maven/scm/manager/ScmManagerStubTest.java
@@ -26,10 +26,10 @@
import org.apache.maven.scm.provider.ScmProviderStub;
import org.apache.maven.scm.repository.ScmRepository;
import org.apache.maven.scm.repository.ScmRepositoryStub;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
* Test for the ScmManagerStub
@@ -47,7 +47,7 @@ public class ScmManagerStubTest {
private ScmRepository scmRepository;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
messages = new ArrayList<>(0);
scmProvider = new ScmProviderStub();
diff --git a/pom.xml b/pom.xml
index d563e89c0..fbd52212c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -443,7 +443,6 @@
<id>non-aggregate</id>
<reports>
<report>javadoc</report>
- <report>test-javadoc</report>
</reports>
</reportSet>
<reportSet>