diff --git a/pom.xml b/pom.xml
index c6501d7e..d0e23a49 100644
--- a/pom.xml
+++ b/pom.xml
@@ -109,17 +109,6 @@
2.0b6
compile
-
- org.testng
- testng
- 7.5
- test
-
-
- junit
- junit
- test
-
org.apache.maven.shared
file-management
@@ -132,15 +121,14 @@
1.7.36
- org.slf4j
- slf4j-simple
- 1.7.36
+ org.junit.jupiter
+ junit-jupiter
test
- org.assertj
- assertj-core
- 3.24.2
+ org.slf4j
+ slf4j-simple
+ 1.7.36
test
diff --git a/src/test/java/org/codehaus/mojo/buildhelper/FixtureUtils.java b/src/test/java/org/codehaus/mojo/buildhelper/FixtureUtils.java
index 99fae85f..27854d4a 100644
--- a/src/test/java/org/codehaus/mojo/buildhelper/FixtureUtils.java
+++ b/src/test/java/org/codehaus/mojo/buildhelper/FixtureUtils.java
@@ -25,7 +25,7 @@
import java.util.Properties;
/**
- * A utility class for managing test resources.
+ * A utility class for managing test resources - used by integration tests - groovy scripting.
*
* @author Adrian Price demonfiddler@virginmedia.com
* @since 1.12
@@ -118,7 +118,7 @@ public static void createResources( File baseDir, Properties properties, long ba
if ( !propertyValue.isEmpty() )
{
int offset = Integer.parseInt( propertyValue );
- long ts = baseTimestamp + ( offset * 1000 );
+ long ts = baseTimestamp + ( offset * 1000L);
file.setLastModified( ts );
assert file.lastModified() == ts : "failed to set last modified timestamp for "
+ file.getCanonicalPath();
diff --git a/src/test/java/org/codehaus/mojo/buildhelper/ParseVersionTest.java b/src/test/java/org/codehaus/mojo/buildhelper/ParseVersionTest.java
index 883d5fe2..141c03a7 100644
--- a/src/test/java/org/codehaus/mojo/buildhelper/ParseVersionTest.java
+++ b/src/test/java/org/codehaus/mojo/buildhelper/ParseVersionTest.java
@@ -24,19 +24,20 @@
* SOFTWARE.
*/
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
import java.util.Properties;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ParseVersionTest
{
- private static class TestParseVersionMojo
+ public static class TestParseVersionMojo
extends ParseVersionMojo
{
- private Properties properties;
+ private final Properties properties;
public TestParseVersionMojo( Properties properties )
{
@@ -49,17 +50,18 @@ protected void defineProperty( String name, String value )
}
}
+ @Nested
public class TestParseVersion
{
private Properties props;
private ParseVersionMojo mojo;
- @BeforeMethod
+ @BeforeEach
public void beforeClass()
{
props = new Properties();
- mojo = new TestParseVersionMojo( props );
+ mojo = new TestParseVersionMojo(props);
mojo.setPropertyPrefix( "parsed" );
mojo.setFormattedPropertyPrefix( "formatted" );
@@ -72,9 +74,7 @@ public void beforeClass()
}
@Test
- public void testJunkVersion()
- throws Exception
- {
+ public void checkJunkVersion() {
// Test a junk version string
mojo.parseVersion( "junk" );
@@ -87,9 +87,7 @@ public void testJunkVersion()
}
@Test
- public void testBasicMavenVersionString()
- throws Exception
- {
+ public void checkBasicMavenVersionString() {
// Test a basic maven version string
mojo.parseVersion( "1.0.0" );
@@ -102,7 +100,7 @@ public void testBasicMavenVersionString()
}
@Test
- public void testVersionStringWithQualifier()
+ public void checkVersionStringWithQualifier()
{
// Test a version string with qualifier
mojo.parseVersion( "2.3.4-beta-5" );
@@ -116,7 +114,7 @@ public void testVersionStringWithQualifier()
}
@Test
- public void testOSGiVersionStringWithQualifier()
+ public void checkOSGiVersionStringWithQualifier()
{
// Test an osgi version string
mojo.parseVersion( "2.3.4.beta_5" );
@@ -130,7 +128,7 @@ public void testOSGiVersionStringWithQualifier()
}
@Test
- public void testSnapshotVersion()
+ public void checkSnapshotVersion()
{
// Test a snapshot version string
mojo.parseVersion( "1.2.3-SNAPSHOT" );
@@ -144,7 +142,7 @@ public void testSnapshotVersion()
}
@Test
- public void testSnapshotVersion2()
+ public void checkSnapshotVersion2()
{
// Test a snapshot version string
mojo.parseVersion( "2.0.17-SNAPSHOT" );
@@ -158,7 +156,7 @@ public void testSnapshotVersion2()
}
@Test
- public void testVersionStringWithBuildNumber()
+ public void checkVersionStringWithBuildNumber()
{
// Test a version string with a build number
mojo.parseVersion( "1.2.3-4" );
@@ -173,7 +171,7 @@ public void testVersionStringWithBuildNumber()
}
@Test
- public void testSnapshotVersionStringWithBuildNumber()
+ public void checkSnapshotVersionStringWithBuildNumber()
{
// Test a version string with a build number
mojo.parseVersion( "1.2.3-4-SNAPSHOT" );
@@ -188,17 +186,18 @@ public void testSnapshotVersionStringWithBuildNumber()
}
- public class TestParseNextVersion
+ @Nested
+ class TestParseNextVersion
{
private Properties props;
private ParseVersionMojo mojo;
- @BeforeMethod
+ @BeforeEach
public void beforeClass()
{
props = new Properties();
- mojo = new TestParseVersionMojo( props );
+ mojo = new TestParseVersionMojo(props);
mojo.setPropertyPrefix( "parsed" );
mojo.setFormattedPropertyPrefix( "formatted" );
// The settings should in line with the given defaultValues of the parameters
@@ -210,7 +209,7 @@ public void beforeClass()
}
@Test
- public void testJunkVersion()
+ public void checkJunkVersion()
{
mojo.parseVersion( "junk" );
@@ -290,18 +289,18 @@ public void testVersionStringWithBuildNumber()
}
-
- public class TestFormattedVersion
+ @Nested
+ class TestFormattedVersion
{
private Properties props;
private ParseVersionMojo mojo;
- @BeforeMethod
+ @BeforeEach
public void beforeClass()
{
props = new Properties();
- mojo = new TestParseVersionMojo( props );
+ mojo = new TestParseVersionMojo(props);
mojo.setPropertyPrefix( "parsed" );
mojo.setFormattedPropertyPrefix( "formatted" );
// The settings should in line with the given defaultValues of the parameters
diff --git a/src/test/java/org/codehaus/mojo/buildhelper/versioning/VersionInformationTest.java b/src/test/java/org/codehaus/mojo/buildhelper/versioning/VersionInformationTest.java
index 01aa6e6b..9bc09e8e 100644
--- a/src/test/java/org/codehaus/mojo/buildhelper/versioning/VersionInformationTest.java
+++ b/src/test/java/org/codehaus/mojo/buildhelper/versioning/VersionInformationTest.java
@@ -19,83 +19,72 @@
* under the License.
*/
-import static org.assertj.core.api.Assertions.assertThat;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author Karl Heinz Marbaise khmarbaise@apache.org
*/
public class VersionInformationTest
{
-
- private VersionInformation createVersion( String version )
- {
- return new VersionInformation( version );
- }
-
- private void assertVersion( VersionInformation v, int major, int minor, int patch, long buildNumber,
- String qualifier )
- {
- assertThat( v.getMajor() ).isEqualTo( major );
- assertThat( v.getMinor() ).isEqualTo( minor );
- assertThat( v.getPatch() ).isEqualTo( patch );
- assertThat( v.getBuildNumber() ).isEqualTo( buildNumber );
- assertThat( v.getQualifier() ).isEqualTo( qualifier );
- }
-
// @formatter:off
- @DataProvider
- public Object[][] createVersions() {
- return new Object[][] {
- { "1", 1, 0, 0, 0, null },
+ private static Object[][] createVersions() {
+ return new Object[][] {
+ { "1", 1, 0, 0, 0, null },
{ "1-23", 1, 0, 0, 23, null },
- { "1-23.heger", 1, 0, 0, 23, ".heger" },
+ { "1-23.heger", 1, 0, 0, 23, ".heger" },
{ "1.2-45", 1, 2, 0, 45, null },
- { "1.2-45.qual", 1, 2, 0, 45, ".qual" },
+ { "1.2-45.qual", 1, 2, 0, 45, ".qual" },
{ "1.2-45-qual", 1, 2, 0, 45, "-qual" },
- { "3.2", 3, 2, 0, 0, null },
- { "5.7.1", 5, 7, 1, 0, null },
+ { "3.2", 3, 2, 0, 0, null },
+ { "5.7.1", 5, 7, 1, 0, null },
{ "1.9.04-0012", 1, 9, 4, 12, null },
- { "01.9.04-0012", 1, 9, 4, 12, null },
+ { "01.9.04-0012", 1, 9, 4, 12, null },
{ "20.03.5-22", 20, 3, 5, 22, null },
- { "20.03.5-056", 20, 3, 5, 56, null },
+ { "20.03.5-056", 20, 3, 5, 56, null },
{ "20.4.06.0-SNAPSHOT", 20, 4, 6, 0, "0-SNAPSHOT" },
- { "1.2.3-SNAPSHOT", 1, 2, 3, 0, "SNAPSHOT" },
- { "1.2.3-01-SNAPSHOT", 1, 2, 3, 1, "-SNAPSHOT" },
+ { "1.2.3-SNAPSHOT", 1, 2, 3, 0, "SNAPSHOT" },
+ { "1.2.3-01-SNAPSHOT", 1, 2, 3, 1, "-SNAPSHOT" },
{ "1.2.3-1-SNAPSHOT", 1, 2, 3, 1, "-SNAPSHOT" },
{ "20.03.5.2016060708", 20, 3, 5, 0, "2016060708" },
{ "20.03.5-23-2016060708", 20, 3, 5, 23, "-2016060708" },
{ "20.03.5-23.2016060708", 20, 3, 5, 23, ".2016060708" },
- { "20.03.5-111.anton", 20, 3, 5, 111, ".anton" },
+ { "20.03.5-111.anton", 20, 3, 5, 111, ".anton" },
{ "20.03.5.22-SNAPSHOT", 20, 3, 5, 0, "22-SNAPSHOT" },
- { "20.03.5.XYZ.345", 20, 3, 5, 0, "XYZ.345" },
+ { "20.03.5.XYZ.345", 20, 3, 5, 0, "XYZ.345" },
{ "20-88.03.5.XYZ.345", 20, 0, 0, 88, ".03.5.XYZ.345" },
{ "20.4-88.03.5.XYZ.345", 20, 4, 0, 88, ".03.5.XYZ.345" },
{ "020.04-88.03.5.XYZ.345", 20, 4, 0, 88, ".03.5.XYZ.345" },
{ "20.7.12-88.03.5.XYZ.345", 20, 7, 12, 88, ".03.5.XYZ.345" },
{ "20.03.5-111-34-anton", 20, 3, 5, 111, "-34-anton" },
- { "20.03.5-111-34.anton", 20, 3, 5, 111, "-34.anton" },
- { "junk", 0, 0, 0, 0, "junk" },
- { "2.3.4-beta_5", 2, 3, 4, 0, "beta_5" },
+ { "20.03.5-111-34.anton", 20, 3, 5, 111, "-34.anton" },
+ { "junk", 0, 0, 0, 0, "junk" },
+ { "2.3.4-beta_5", 2, 3, 4, 0, "beta_5" },
{ "2.3.4.beta_5", 2, 3, 4, 0, "beta_5" },
- { "1.2.3-20171002135756", 1, 2, 3, 20171002135756l, null }
+ { "1.2.3-20171002135756", 1, 2, 3, 20171002135756L, null }
};
}
// @formatter:on
- @Test( dataProvider = "createVersions" )
+ @ParameterizedTest
+ @MethodSource("createVersions")
public void checkVersions( String version, int major, int minor, int patch, long buildNumber, String qualifier )
{
- VersionInformation vi = createVersion( version );
- assertVersion( vi, major, minor, patch, buildNumber, qualifier );
- }
+ VersionInformation vi = new VersionInformation(version);
+ assertEquals( vi.getMajor(), major);
+ assertEquals( vi.getMinor(), minor);
+ assertEquals( vi.getPatch(), patch);
+ assertEquals( vi.getBuildNumber(), buildNumber);
+ assertEquals( vi.getQualifier(), qualifier);
+ }
- @Test( expectedExceptions = NumberFormatException.class )
+ @Test
public void shouldFaileWithNumberFormatException()
{
- String version = "999999999999.12345678.12.beta_5";
- createVersion( version );
+ assertThrows(NumberFormatException.class, () -> new VersionInformation("999999999999.12345678.12.beta_5"));
}
}