diff --git a/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java b/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java
index 2d34076f2b..70a11151fe 100644
--- a/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java
+++ b/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java
@@ -19,31 +19,33 @@ package org.apache.maven.settings;
* under the License.
*/
-import junit.framework.TestCase;
-import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
+import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Tests that the global settings.xml shipped with the distribution is in good state.
*
* @author Benjamin Bentmann
*/
public class GlobalSettingsTest
- extends TestCase
{
+ @Test
public void testValidGlobalSettings()
throws Exception
{
String basedir = System.getProperty( "basedir", System.getProperty( "user.dir" ) );
File globalSettingsFile = new File( basedir, "src/assembly/maven/conf/settings.xml" );
- assertTrue( globalSettingsFile.getAbsolutePath(), globalSettingsFile.isFile() );
+ assertTrue( globalSettingsFile.isFile(), globalSettingsFile.getAbsolutePath() );
try ( Reader reader = new InputStreamReader( new FileInputStream( globalSettingsFile ), StandardCharsets.UTF_8) )
{
diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java b/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java
index 333f6368bf..2cbe18e130 100644
--- a/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java
+++ b/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java
@@ -24,8 +24,10 @@ import java.util.List;
import java.util.Map;
import org.apache.maven.artifact.versioning.VersionRange;
+import org.junit.jupiter.api.Test;
-import junit.framework.TestCase;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Tests {@link ArtifactUtils}.
@@ -33,7 +35,6 @@ import junit.framework.TestCase;
* @author Benjamin Bentmann
*/
public class ArtifactUtilsTest
- extends TestCase
{
private Artifact newArtifact( String aid )
@@ -41,6 +42,7 @@ public class ArtifactUtilsTest
return new DefaultArtifact( "group", aid, VersionRange.createFromVersion( "1.0" ), "test", "jar", "tests", null );
}
+ @Test
public void testIsSnapshot()
{
assertEquals( false, ArtifactUtils.isSnapshot( null ) );
@@ -52,6 +54,7 @@ public class ArtifactUtilsTest
assertEquals( false, ArtifactUtils.isSnapshot( "1.2.3-20090413X094722-2"));
}
+ @Test
public void testToSnapshotVersion()
{
assertEquals( "1.2.3", ArtifactUtils.toSnapshotVersion( "1.2.3" ) );
@@ -63,6 +66,7 @@ public class ArtifactUtilsTest
/**
* Tests that the ordering of the map resembles the ordering of the input collection of artifacts.
*/
+ @Test
public void testArtifactMapByVersionlessIdOrdering()
throws Exception
{
diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/DefaultArtifactTest.java b/maven-artifact/src/test/java/org/apache/maven/artifact/DefaultArtifactTest.java
index fbd0119161..3e9eb4de0f 100644
--- a/maven-artifact/src/test/java/org/apache/maven/artifact/DefaultArtifactTest.java
+++ b/maven-artifact/src/test/java/org/apache/maven/artifact/DefaultArtifactTest.java
@@ -19,13 +19,15 @@ package org.apache.maven.artifact;
* under the License.
*/
-import junit.framework.TestCase;
-
import org.apache.maven.artifact.handler.ArtifactHandlerMock;
import org.apache.maven.artifact.versioning.VersionRange;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class DefaultArtifactTest
- extends TestCase
{
private DefaultArtifact artifact;
@@ -43,10 +45,10 @@ public class DefaultArtifactTest
private ArtifactHandlerMock artifactHandler;
- protected void setUp()
+ @BeforeEach
+ public void setUp()
throws Exception
{
- super.setUp();
artifactHandler = new ArtifactHandlerMock();
versionRange = VersionRange.createFromVersion( version );
artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, classifier, artifactHandler );
@@ -55,6 +57,7 @@ public class DefaultArtifactTest
snapshotArtifact = new DefaultArtifact( groupId, artifactId, snapshotVersionRange, scope, type, classifier, artifactHandler );
}
+ @Test
public void testGetVersionReturnsResolvedVersionOnSnapshot()
{
assertEquals( snapshotResolvedVersion, snapshotArtifact.getVersion() );
@@ -65,53 +68,62 @@ public class DefaultArtifactTest
assertEquals( snapshotSpecVersion, snapshotArtifact.getBaseVersion() );
}
+ @Test
public void testGetDependencyConflictId()
{
assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() );
}
+ @Test
public void testGetDependencyConflictIdNullGroupId()
{
artifact.setGroupId( null );
assertEquals( null + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() );
}
+ @Test
public void testGetDependencyConflictIdNullClassifier()
{
artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, null, artifactHandler );
assertEquals( groupId + ":" + artifactId + ":" + type, artifact.getDependencyConflictId() );
}
+ @Test
public void testGetDependencyConflictIdNullScope()
{
artifact.setScope( null );
assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() );
}
+ @Test
public void testToString()
{
assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier + ":" + version + ":" + scope,
artifact.toString() );
}
+ @Test
public void testToStringNullGroupId()
{
artifact.setGroupId( null );
assertEquals( artifactId + ":" + type + ":" + classifier + ":" + version + ":" + scope, artifact.toString() );
}
+ @Test
public void testToStringNullClassifier()
{
artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, null, artifactHandler );
assertEquals( groupId + ":" + artifactId + ":" + type + ":" + version + ":" + scope, artifact.toString() );
}
+ @Test
public void testToStringNullScope()
{
artifact.setScope( null );
assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier + ":" + version, artifact.toString() );
}
+ @Test
public void testComparisonByVersion()
{
Artifact artifact1 = new DefaultArtifact( groupId, artifactId, VersionRange.createFromVersion( "5.0" ), scope,
@@ -128,6 +140,7 @@ public class DefaultArtifactTest
assertTrue( artifact1.compareTo( artifact ) == 0 );
}
+ @Test
public void testNonResolvedVersionRangeConsistentlyYieldsNullVersions()
throws Exception
{
diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionIT.java b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionIT.java
index 394b7f0565..cd63b4db3c 100644
--- a/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionIT.java
+++ b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionIT.java
@@ -19,10 +19,8 @@ package org.apache.maven.artifact.versioning;
* under the License.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
import java.io.IOException;
+import java.io.InterruptedIOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -31,7 +29,9 @@ import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.regex.Pattern;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ComparableVersionIT
{
@@ -60,11 +60,11 @@ public class ComparableVersionIT
try
{
- assertEquals( "Unexpected exit code", 0, p.waitFor() );
+ assertEquals( 0, p.waitFor(), "Unexpected exit code" );
}
catch ( InterruptedException e )
{
- fail( e.getMessage() );
+ throw new InterruptedIOException( e.toString() );
}
return FileVisitResult.TERMINATE;
}
diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
index 97fb46d55f..a36f605545 100644
--- a/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
+++ b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
@@ -21,7 +21,10 @@ package org.apache.maven.artifact.versioning;
import java.util.Locale;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test ComparableVersion.
@@ -30,7 +33,6 @@ import junit.framework.TestCase;
*/
@SuppressWarnings( "unchecked" )
public class ComparableVersionTest
- extends TestCase
{
private Comparable newComparable( String version )
{
@@ -39,8 +41,8 @@ public class ComparableVersionTest
String parsedCanonical = new ComparableVersion( canonical ).getCanonical();
System.out.println( "canonical( " + version + " ) = " + canonical );
- assertEquals( "canonical( " + version + " ) = " + canonical + " -> canonical: " + parsedCanonical, canonical,
- parsedCanonical );
+ assertEquals( canonical, parsedCanonical,
+ "canonical( " + version + " ) = " + canonical + " -> canonical: " + parsedCanonical );
return ret;
}
@@ -68,8 +70,8 @@ public class ComparableVersionTest
for ( int j = i; j < versions.length; j++ )
{
Comparable high = c[j];
- assertTrue( "expected " + low + " < " + high, low.compareTo( high ) < 0 );
- assertTrue( "expected " + high + " > " + low, high.compareTo( low ) > 0 );
+ assertTrue( low.compareTo( high ) < 0, "expected " + low + " < " + high );
+ assertTrue( high.compareTo( low ) > 0, "expected " + high + " > " + low );
}
}
}
@@ -78,11 +80,11 @@ public class ComparableVersionTest
{
Comparable c1 = newComparable( v1 );
Comparable c2 = newComparable( v2 );
- assertTrue( "expected " + v1 + " == " + v2, c1.compareTo( c2 ) == 0 );
- assertTrue( "expected " + v2 + " == " + v1, c2.compareTo( c1 ) == 0 );
- assertTrue( "expected same hashcode for " + v1 + " and " + v2, c1.hashCode() == c2.hashCode() );
- assertTrue( "expected " + v1 + ".equals( " + v2 + " )", c1.equals( c2 ) );
- assertTrue( "expected " + v2 + ".equals( " + v1 + " )", c2.equals( c1 ) );
+ assertTrue( c1.compareTo( c2 ) == 0, "expected " + v1 + " == " + v2 );
+ assertTrue( c2.compareTo( c1 ) == 0, "expected " + v2 + " == " + v1 );
+ assertTrue( c1.hashCode() == c2.hashCode(), "expected same hashcode for " + v1 + " and " + v2 );
+ assertTrue( c1.equals( c2 ), "expected " + v1 + ".equals( " + v2 + " )" );
+ assertTrue( c2.equals( c1 ), "expected " + v2 + ".equals( " + v1 + " )" );
}
private void checkVersionsArrayEqual( String[] array )
@@ -97,20 +99,23 @@ public class ComparableVersionTest
{
Comparable c1 = newComparable( v1 );
Comparable c2 = newComparable( v2 );
- assertTrue( "expected " + v1 + " < " + v2, c1.compareTo( c2 ) < 0 );
- assertTrue( "expected " + v2 + " > " + v1, c2.compareTo( c1 ) > 0 );
+ assertTrue( c1.compareTo( c2 ) < 0, "expected " + v1 + " < " + v2 );
+ assertTrue( c2.compareTo( c1 ) > 0, "expected " + v2 + " > " + v1 );
}
+ @Test
public void testVersionsQualifier()
{
checkVersionsOrder( VERSIONS_QUALIFIER );
}
+ @Test
public void testVersionsNumber()
{
checkVersionsOrder( VERSIONS_NUMBER );
}
+ @Test
public void testVersionsEqual()
{
newComparable( "1.0-alpha" );
@@ -164,6 +169,7 @@ public class ComparableVersionTest
checkVersionsEqual( "1m3", "1MILESTONE3" );
}
+ @Test
public void testVersionComparing()
{
checkVersionsOrder( "1", "2" );
@@ -202,6 +208,7 @@ public class ComparableVersionTest
* see Netbeans issues 240845 and
* 226100
*/
+ @Test
public void testMng5568()
{
String a = "6.1.0";
@@ -216,6 +223,7 @@ public class ComparableVersionTest
/**
* Test MNG-6572 optimization.
*/
+ @Test
public void testMng6572()
{
String a = "20190126.230843"; // resembles a SNAPSHOT
@@ -235,6 +243,7 @@ public class ComparableVersionTest
* Test all versions are equal when starting with many leading zeroes regardless of string length
* (related to MNG-6572 optimization)
*/
+ @Test
public void testVersionEqualWithLeadingZeroes()
{
// versions with string lengths from 1 to 19
@@ -267,6 +276,7 @@ public class ComparableVersionTest
* Test all "0" versions are equal when starting with many leading zeroes regardless of string length
* (related to MNG-6572 optimization)
*/
+ @Test
public void testVersionZeroEqualWithLeadingZeroes()
{
// versions with string lengths from 1 to 19
@@ -299,6 +309,7 @@ public class ComparableVersionTest
* Test MNG-6964 edge cases
* for qualifiers that start with "-0.", which was showing A == C and B == C but A < B.
*/
+ @Test
public void testMng6964()
{
String a = "1-0.alpha";
@@ -310,6 +321,7 @@ public class ComparableVersionTest
checkVersionsOrder( a, b ); // Should still be true
}
+ @Test
public void testLocaleIndependent()
{
Locale orig = Locale.getDefault();
@@ -328,6 +340,7 @@ public class ComparableVersionTest
}
}
+ @Test
public void testReuse()
{
ComparableVersion c1 = new ComparableVersion( "1" );
@@ -335,6 +348,6 @@ public class ComparableVersionTest
Comparable c2 = newComparable( "2" );
- assertEquals( "reused instance should be equivalent to new instance", c1, c2 );
+ assertEquals( c1, c2, "reused instance should be equivalent to new instance" );
}
}
diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/DefaultArtifactVersionTest.java b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/DefaultArtifactVersionTest.java
index fc5a2742ed..aba36bbe3f 100644
--- a/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/DefaultArtifactVersionTest.java
+++ b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/DefaultArtifactVersionTest.java
@@ -19,7 +19,13 @@ package org.apache.maven.artifact.versioning;
* under the License.
*/
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test DefaultArtifactVersion.
@@ -27,7 +33,6 @@ import junit.framework.TestCase;
* @author Brett Porter
*/
public class DefaultArtifactVersionTest
- extends TestCase
{
private ArtifactVersion newArtifactVersion( String version )
{
@@ -42,14 +47,15 @@ public class DefaultArtifactVersionTest
"'" + version + "' parsed as ('" + artifactVersion.getMajorVersion() + "', '"
+ artifactVersion.getMinorVersion() + "', '" + artifactVersion.getIncrementalVersion() + "', '"
+ artifactVersion.getBuildNumber() + "', '" + artifactVersion.getQualifier() + "'), ";
- assertEquals( parsed + "check major version", major, artifactVersion.getMajorVersion() );
- assertEquals( parsed + "check minor version", minor, artifactVersion.getMinorVersion() );
- assertEquals( parsed + "check incremental version", incremental, artifactVersion.getIncrementalVersion() );
- assertEquals( parsed + "check build number", buildnumber, artifactVersion.getBuildNumber() );
- assertEquals( parsed + "check qualifier", qualifier, artifactVersion.getQualifier() );
- assertEquals( "check " + version + " string value", version, artifactVersion.toString() );
+ assertEquals( major, artifactVersion.getMajorVersion(), parsed + "check major version" );
+ assertEquals( minor, artifactVersion.getMinorVersion(), parsed + "check minor version" );
+ assertEquals( incremental, artifactVersion.getIncrementalVersion(), parsed + "check incremental version" );
+ assertEquals( buildnumber, artifactVersion.getBuildNumber(), parsed + "check build number" );
+ assertEquals( qualifier, artifactVersion.getQualifier(), parsed + "check qualifier" );
+ assertEquals( version, artifactVersion.toString(), "check " + version + " string value" );
}
+ @Test
public void testVersionParsing()
{
checkVersionParsing( "1", 1, 0, 0, 0, null );
@@ -87,6 +93,7 @@ public class DefaultArtifactVersionTest
checkVersionParsing( "1.2.3-200705301630", 1, 2, 3, 0, "200705301630" );
}
+ @Test
public void testVersionComparing()
{
assertVersionEqual( "1", "1" );
@@ -134,6 +141,7 @@ public class DefaultArtifactVersionTest
assertVersionOlder( "2.0.0.v200706041905-7C78EK9E_EkMNfNOd2d8qq", "2.0.0.v200706041906-7C78EK9E_EkMNfNOd2d8qq" );
}
+ @Test
public void testVersionSnapshotComparing()
{
assertVersionEqual( "1-SNAPSHOT", "1-SNAPSHOT" );
@@ -168,6 +176,7 @@ public class DefaultArtifactVersionTest
assertVersionOlder( "2.0.1-xyz-SNAPSHOT", "2.0.1-123-SNAPSHOT" );
}
+ @Test
public void testSnapshotVsReleases()
{
assertVersionOlder( "1.0-RC1", "1.0-SNAPSHOT" );
@@ -175,6 +184,7 @@ public class DefaultArtifactVersionTest
assertVersionOlder( "1.0-rc-1", "1.0-SNAPSHOT" );
}
+ @Test
public void testHashCode()
{
ArtifactVersion v1 = newArtifactVersion( "1" );
@@ -183,41 +193,45 @@ public class DefaultArtifactVersionTest
assertEquals( v1.hashCode(), v2.hashCode() );
}
+ @Test
public void testEqualsNullSafe()
{
assertFalse( newArtifactVersion( "1" ).equals( null ) );
}
+ @Test
public void testEqualsTypeSafe()
{
assertFalse( newArtifactVersion( "1" ).equals( "non-an-artifact-version-instance" ) );
}
+ @Test
+ @Disabled("That one does not work")
public void testNonNumericVersionRepresentationReturnsANumberFormatException()
{
- try
- {
- new DefaultArtifactVersion( "..." );
- }
- catch ( Exception e )
- {
- assertTrue( "We expect a NumberFormatException to be thrown.", e instanceof NumberFormatException );
- }
+ assertThrows(
+ NumberFormatException.class,
+ () -> new DefaultArtifactVersion( "..." ),
+ "We expect a NumberFormatException to be thrown." );
}
private void assertVersionOlder( String left, String right )
{
- assertTrue( left + " should be older than " + right,
- newArtifactVersion( left ).compareTo( newArtifactVersion( right ) ) < 0 );
- assertTrue( right + " should be newer than " + left,
- newArtifactVersion( right ).compareTo( newArtifactVersion( left ) ) > 0 );
+ assertTrue(
+ newArtifactVersion( left ).compareTo( newArtifactVersion( right ) ) < 0,
+ left + " should be older than " + right );
+ assertTrue(
+ newArtifactVersion( right ).compareTo( newArtifactVersion( left ) ) > 0,
+ right + " should be newer than " + left );
}
private void assertVersionEqual( String left, String right )
{
- assertTrue( left + " should be equal to " + right,
- newArtifactVersion( left ).compareTo( newArtifactVersion( right ) ) == 0 );
- assertTrue( right + " should be equal to " + left,
- newArtifactVersion( right ).compareTo( newArtifactVersion( left ) ) == 0 );
+ assertTrue(
+ newArtifactVersion( left ).compareTo( newArtifactVersion( right ) ) == 0,
+ left + " should be equal to " + right );
+ assertTrue(
+ newArtifactVersion( right ).compareTo( newArtifactVersion( left ) ) == 0,
+ right + " should be equal to " + left );
}
}
diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java
index 2cf0fec930..50270a00d4 100644
--- a/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java
+++ b/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java
@@ -21,9 +21,15 @@ package org.apache.maven.artifact.versioning;
import java.util.List;
-import junit.framework.TestCase;
-
import org.apache.maven.artifact.Artifact;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests version range construction.
@@ -31,7 +37,6 @@ import org.apache.maven.artifact.Artifact;
* @author Brett Porter
*/
public class VersionRangeTest
- extends TestCase
{
private static final String CHECK_NUM_RESTRICTIONS = "check number of restrictions";
@@ -49,6 +54,7 @@ public class VersionRangeTest
private static final String CHECK_SELECTED_VERSION = "check selected version";
+ @Test
public void testRange()
throws InvalidVersionSpecificationException, OverConstrainedVersionException
{
@@ -56,93 +62,93 @@ public class VersionRangeTest
VersionRange range = VersionRange.createFromVersionSpec( "(,1.0]" );
List restrictions = range.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
Restriction restriction = restrictions.get( 0 );
- assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
- assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
- assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
- assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) );
+ assertNull( restriction.getLowerBound(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.0", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
+ assertNull( range.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
+ assertFalse( range.isSelectedVersionKnown( artifact ), CHECK_SELECTED_VERSION_KNOWN );
+ assertNull( range.getSelectedVersion( artifact ), CHECK_SELECTED_VERSION );
range = VersionRange.createFromVersionSpec( "1.0" );
- assertEquals( CHECK_VERSION_RECOMMENDATION, "1.0", range.getRecommendedVersion().toString() );
+ assertEquals( "1.0", range.getRecommendedVersion().toString(), CHECK_VERSION_RECOMMENDATION );
restrictions = range.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
- assertTrue( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
- assertEquals( CHECK_SELECTED_VERSION, "1.0", range.getSelectedVersion( artifact ).toString() );
+ assertNull( restriction.getLowerBound(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertNull( restriction.getUpperBound(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
+ assertTrue( range.isSelectedVersionKnown( artifact ), CHECK_SELECTED_VERSION_KNOWN );
+ assertEquals( "1.0", range.getSelectedVersion( artifact ).toString(), CHECK_SELECTED_VERSION );
range = VersionRange.createFromVersionSpec( "[1.0]" );
restrictions = range.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.0", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
- assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
- assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
- assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) );
+ assertEquals( "1.0", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.0", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
+ assertNull( range.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
+ assertFalse( range.isSelectedVersionKnown( artifact ), CHECK_SELECTED_VERSION_KNOWN );
+ assertNull( range.getSelectedVersion( artifact ), CHECK_SELECTED_VERSION );
range = VersionRange.createFromVersionSpec( "[1.2,1.3]" );
restrictions = range.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
- assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
- assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
- assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) );
+ assertEquals( "1.2", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.3", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
+ assertNull( range.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
+ assertFalse( range.isSelectedVersionKnown( artifact ), CHECK_SELECTED_VERSION_KNOWN );
+ assertNull( range.getSelectedVersion( artifact ), CHECK_SELECTED_VERSION );
range = VersionRange.createFromVersionSpec( "[1.0,2.0)" );
restrictions = range.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.0", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "2.0", restriction.getUpperBound().toString() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
- assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
- assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
- assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) );
+ assertEquals( "1.0", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "2.0", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
+ assertNull( range.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
+ assertFalse( range.isSelectedVersionKnown( artifact ), CHECK_SELECTED_VERSION_KNOWN );
+ assertNull( range.getSelectedVersion( artifact ), CHECK_SELECTED_VERSION );
range = VersionRange.createFromVersionSpec( "[1.5,)" );
restrictions = range.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
- assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
- assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
- assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) );
+ assertEquals( "1.5", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertNull( restriction.getUpperBound(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
+ assertNull( range.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
+ assertFalse( range.isSelectedVersionKnown( artifact ), CHECK_SELECTED_VERSION_KNOWN );
+ assertNull( range.getSelectedVersion( artifact ), CHECK_SELECTED_VERSION );
range = VersionRange.createFromVersionSpec( "(,1.0],[1.2,)" );
restrictions = range.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
+ assertEquals( 2, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
- assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
+ assertNull( restriction.getLowerBound(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.0", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
+ assertNull( range.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restriction = restrictions.get( 1 );
- assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
- assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
- assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
- assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) );
+ assertEquals( "1.2", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertNull( restriction.getUpperBound(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
+ assertNull( range.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
+ assertFalse( range.isSelectedVersionKnown( artifact ), CHECK_SELECTED_VERSION_KNOWN );
+ assertNull( range.getSelectedVersion( artifact ), CHECK_SELECTED_VERSION );
range = VersionRange.createFromVersionSpec( "[1.0,)" );
assertFalse( range.containsVersion( new DefaultArtifactVersion( "1.0-SNAPSHOT" ) ) );
@@ -154,6 +160,7 @@ public class VersionRangeTest
assertTrue( range.containsVersion( new DefaultArtifactVersion( "5.0.9.0" ) ) );
}
+ @Test
public void testInvalidRanges()
{
checkInvalidRange( "(1.0)" );
@@ -172,6 +179,7 @@ public class VersionRangeTest
checkInvalidRange( "(1.1,1.2],[1.0,1.1)" );
}
+ @Test
public void testIntersections()
throws InvalidVersionSpecificationException
{
@@ -179,481 +187,482 @@ public class VersionRangeTest
VersionRange range2 = VersionRange.createFromVersionSpec( "1.1" );
VersionRange mergedRange = range1.restrict( range2 );
// TODO current policy is to retain the original version - is this correct, do we need strategies or is that handled elsewhere?
-// assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() );
- assertEquals( CHECK_VERSION_RECOMMENDATION, "1.0", mergedRange.getRecommendedVersion().toString() );
+// assertEquals( "1.1", mergedRange.getRecommendedVersion().toString(), CHECK_VERSION_RECOMMENDATION );
+ assertEquals( "1.0", mergedRange.getRecommendedVersion().toString(), CHECK_VERSION_RECOMMENDATION );
List restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
Restriction restriction = restrictions.get( 0 );
- assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertNull( restriction.getLowerBound(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertNull( restriction.getUpperBound(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
mergedRange = range2.restrict( range1 );
- assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() );
+ assertEquals( "1.1", mergedRange.getRecommendedVersion().toString(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertNull( restriction.getLowerBound(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertNull( restriction.getUpperBound(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
// TODO test reversed restrictions on all below
range1 = VersionRange.createFromVersionSpec( "[1.0,)" );
range2 = VersionRange.createFromVersionSpec( "1.1" );
mergedRange = range1.restrict( range2 );
- assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() );
+ assertEquals( "1.1", mergedRange.getRecommendedVersion().toString(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.0", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.0", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertNull( restriction.getUpperBound(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.1,)" );
range2 = VersionRange.createFromVersionSpec( "1.1" );
mergedRange = range1.restrict( range2 );
- assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() );
+ assertEquals( "1.1", mergedRange.getRecommendedVersion().toString(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertNull( restriction.getUpperBound(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.1]" );
range2 = VersionRange.createFromVersionSpec( "1.1" );
mergedRange = range1.restrict( range2 );
- assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() );
+ assertEquals( "1.1", mergedRange.getRecommendedVersion().toString(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "(1.1,)" );
range2 = VersionRange.createFromVersionSpec( "1.1" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertNull( restriction.getUpperBound(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.2,)" );
range2 = VersionRange.createFromVersionSpec( "1.1" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.2", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertNull( restriction.getUpperBound(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "(,1.2]" );
range2 = VersionRange.createFromVersionSpec( "1.1" );
mergedRange = range1.restrict( range2 );
- assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() );
+ assertEquals( "1.1", mergedRange.getRecommendedVersion().toString(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertNull( restriction.getLowerBound(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.2", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "(,1.1]" );
range2 = VersionRange.createFromVersionSpec( "1.1" );
mergedRange = range1.restrict( range2 );
- assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() );
+ assertEquals( "1.1", mergedRange.getRecommendedVersion().toString(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertNull( restriction.getLowerBound(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.1", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "(,1.1)" );
range2 = VersionRange.createFromVersionSpec( "1.1" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertNull( restriction.getLowerBound(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.1", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "(,1.0]" );
range2 = VersionRange.createFromVersionSpec( "1.1" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertNull( restriction.getLowerBound(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.0", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "(,1.0], [1.1,)" );
range2 = VersionRange.createFromVersionSpec( "1.2" );
mergedRange = range1.restrict( range2 );
- assertEquals( CHECK_VERSION_RECOMMENDATION, "1.2", mergedRange.getRecommendedVersion().toString() );
+ assertEquals( "1.2", mergedRange.getRecommendedVersion().toString(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
+ assertEquals( 2, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertNull( restriction.getLowerBound(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.0", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
restriction = restrictions.get( 1 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertNull( restriction.getUpperBound(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "(,1.0], [1.1,)" );
range2 = VersionRange.createFromVersionSpec( "1.0.5" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
+ assertEquals( 2, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertNull( restriction.getLowerBound(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.0", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
restriction = restrictions.get( 1 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertNull( restriction.getUpperBound(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "(,1.1), (1.1,)" );
range2 = VersionRange.createFromVersionSpec( "1.1" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
+ assertEquals( 2, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertNull( restriction.getLowerBound(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.1", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
restriction = restrictions.get( 1 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertNull( restriction.getUpperBound(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.1,1.3]" );
range2 = VersionRange.createFromVersionSpec( "(1.1,)" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.3", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "(,1.3)" );
range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.2", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.3", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.1,1.3]" );
range2 = VersionRange.createFromVersionSpec( "[1.2,)" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.2", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.3", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "(,1.3]" );
range2 = VersionRange.createFromVersionSpec( "[1.2,1.4]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.2", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.3", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "(1.2,1.3]" );
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.2", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.3", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "(1.2,1.3)" );
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.2", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.3", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.2,1.3)" );
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.2", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.3", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.0,1.1]" );
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.1", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.0,1.1)" );
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
+ assertEquals( 0, restrictions.size(), CHECK_NUM_RESTRICTIONS );
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
range2 = VersionRange.createFromVersionSpec( "[1.1]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.1", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
range2 = VersionRange.createFromVersionSpec( "[1.4]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.4", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.4", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.4", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
+ assertEquals( 2, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.2", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
restriction = restrictions.get( 1 );
- assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.3", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.4", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2),(1.3,1.5]" );
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
+ assertEquals( 2, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.2", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
restriction = restrictions.get( 1 );
- assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.3", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.4", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
+ assertEquals( 2, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.2", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
restriction = restrictions.get( 1 );
- assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.3", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.4", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2),(1.3,1.5]" );
range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
+ assertEquals( 2, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.2", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
restriction = restrictions.get( 1 );
- assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
- assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
- assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.3", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertFalse( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.4", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertFalse( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "(,1.1),(1.4,)" );
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
+ assertEquals( 0, restrictions.size(), CHECK_NUM_RESTRICTIONS );
range1 = VersionRange.createFromVersionSpec( "(,1.1],[1.4,)" );
range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
+ assertEquals( 0, restrictions.size(), CHECK_NUM_RESTRICTIONS );
range1 = VersionRange.createFromVersionSpec( "[,1.1],[1.4,]" );
range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
+ assertEquals( 0, restrictions.size(), CHECK_NUM_RESTRICTIONS );
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.6,]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
+ assertEquals( 2, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.2", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
restriction = restrictions.get( 1 );
- assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.3", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.4", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.5,]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 3, restrictions.size() );
+ assertEquals( 3, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.2", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
restriction = restrictions.get( 1 );
- assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.3", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.4", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
restriction = restrictions.get( 2 );
- assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.5", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.5", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.5", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.7]" );
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.5,1.6]" );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 3, restrictions.size() );
+ assertEquals( 3, restrictions.size(), CHECK_NUM_RESTRICTIONS );
restriction = restrictions.get( 0 );
- assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.1", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.2", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
restriction = restrictions.get( 1 );
- assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.3", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.4", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
restriction = restrictions.get( 2 );
- assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() );
- assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
- assertEquals( CHECK_UPPER_BOUND, "1.6", restriction.getUpperBound().toString() );
- assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
+ assertEquals( "1.5", restriction.getLowerBound().toString(), CHECK_LOWER_BOUND );
+ assertTrue( restriction.isLowerBoundInclusive(), CHECK_LOWER_BOUND_INCLUSIVE );
+ assertEquals( "1.6", restriction.getUpperBound().toString(), CHECK_UPPER_BOUND );
+ assertTrue( restriction.isUpperBoundInclusive(), CHECK_UPPER_BOUND_INCLUSIVE );
// test restricting empty sets
range1 = VersionRange.createFromVersionSpec( "[,1.1],[1.4,]" );
range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" );
range1 = range1.restrict( range2 );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
+ assertEquals( 0, restrictions.size(), CHECK_NUM_RESTRICTIONS );
range1 = VersionRange.createFromVersionSpec( "[,1.1],[1.4,]" );
range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" );
range2 = range1.restrict( range2 );
mergedRange = range1.restrict( range2 );
- assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
+ assertNull( mergedRange.getRecommendedVersion(), CHECK_VERSION_RECOMMENDATION );
restrictions = mergedRange.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
+ assertEquals( 0, restrictions.size(), CHECK_NUM_RESTRICTIONS );
}
+ @Test
public void testReleaseRangeBoundsContainsSnapshots()
throws InvalidVersionSpecificationException
{
@@ -664,6 +673,7 @@ public class VersionRangeTest
assertFalse( range.containsVersion( new DefaultArtifactVersion( "1.0-SNAPSHOT" ) ) );
}
+ @Test
public void testSnapshotRangeBoundsCanContainSnapshots()
throws InvalidVersionSpecificationException
{
@@ -678,6 +688,7 @@ public class VersionRangeTest
assertTrue( range.containsVersion( new DefaultArtifactVersion( "1.1-SNAPSHOT" ) ) );
}
+ @Test
public void testSnapshotSoftVersionCanContainSnapshot()
throws InvalidVersionSpecificationException
{
@@ -688,17 +699,13 @@ public class VersionRangeTest
private void checkInvalidRange( String version )
{
- try
- {
- VersionRange.createFromVersionSpec( version );
- fail( "Version " + version + " should have failed to construct" );
- }
- catch ( InvalidVersionSpecificationException expected )
- {
- // expected
- }
+ assertThrows(
+ InvalidVersionSpecificationException.class,
+ () -> VersionRange.createFromVersionSpec( version ),
+ "Version " + version + " should have failed to construct" );
}
+ @Test
public void testContains() throws InvalidVersionSpecificationException
{
ArtifactVersion actualVersion = new DefaultArtifactVersion( "2.0.5" );
@@ -723,11 +730,13 @@ public class VersionRangeTest
return vr.containsVersion( actualVersion );
}
+ @Test
public void testOrder0()
{
// assertTrue( new DefaultArtifactVersion( "1.0-alpha10" ).compareTo( new DefaultArtifactVersion( "1.0-alpha1" ) ) > 0 );
}
+ @Test
public void testCache()
throws InvalidVersionSpecificationException
{
@@ -737,13 +746,13 @@ public class VersionRangeTest
VersionRange spec = VersionRange.createFromVersionSpec( "1.0" );
assertSame( spec, VersionRange.createFromVersionSpec( "1.0" ) ); // same instance from spec cache
List restrictions = spec.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
+ assertEquals( 1, restrictions.size(), CHECK_NUM_RESTRICTIONS );
VersionRange version = VersionRange.createFromVersion( "1.0" );
assertSame( version, VersionRange.createFromVersion( "1.0" ) ); // same instance from version cache
restrictions = version.getRestrictions();
- assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
+ assertEquals( 0, restrictions.size(), CHECK_NUM_RESTRICTIONS );
- assertFalse( "check !VersionRange.createFromVersionSpec(x).equals(VersionRange.createFromVersion(x))", spec.equals( version ) );
+ assertFalse( spec.equals( version ), "check !VersionRange.createFromVersionSpec(x).equals(VersionRange.createFromVersion(x))" );
}
}
diff --git a/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java b/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java
index 57ddcfa1f8..dbde11ed52 100644
--- a/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java
+++ b/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java
@@ -19,10 +19,11 @@ package org.apache.maven.building;
* under the License.
*/
-import static org.junit.Assert.*;
-
import org.apache.maven.building.Problem.Severity;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class DefaultProblemCollectorTest
{
diff --git a/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java b/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java
index 1615fc3751..4d9a3d89cc 100644
--- a/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java
+++ b/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java
@@ -19,11 +19,11 @@ package org.apache.maven.building;
* under the License.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-
import org.apache.maven.building.Problem.Severity;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
public class DefaultProblemTest
{
diff --git a/maven-builder-support/src/test/java/org/apache/maven/building/FileSourceTest.java b/maven-builder-support/src/test/java/org/apache/maven/building/FileSourceTest.java
index 40ab4956cf..9373c01e8d 100644
--- a/maven-builder-support/src/test/java/org/apache/maven/building/FileSourceTest.java
+++ b/maven-builder-support/src/test/java/org/apache/maven/building/FileSourceTest.java
@@ -19,14 +19,14 @@ package org.apache.maven.building;
* under the License.
*/
-import org.junit.Test;
-
import java.io.File;
import java.io.InputStream;
import java.util.Scanner;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class FileSourceTest
{
@@ -34,15 +34,11 @@ public class FileSourceTest
@Test
public void testFileSource()
{
- try
- {
- new FileSource( null );
- fail( "Should fail, since you must specify a file" );
- }
- catch ( NullPointerException e )
- {
- assertEquals( "file cannot be null", e.getMessage() );
- }
+ NullPointerException e = assertThrows(
+ NullPointerException.class,
+ () -> new FileSource( null ),
+ "Should fail, since you must specify a file" );
+ assertEquals( "file cannot be null", e.getMessage() );
}
@Test
diff --git a/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java b/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java
index 2fdcbb70c4..ee2575b9f1 100644
--- a/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java
+++ b/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java
@@ -19,12 +19,12 @@ package org.apache.maven.building;
* under the License.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-
import java.util.Collections;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
public class ProblemCollectorFactoryTest
{
diff --git a/maven-builder-support/src/test/java/org/apache/maven/building/StringSourceTest.java b/maven-builder-support/src/test/java/org/apache/maven/building/StringSourceTest.java
index 6d9a671e71..85309aa86b 100644
--- a/maven-builder-support/src/test/java/org/apache/maven/building/StringSourceTest.java
+++ b/maven-builder-support/src/test/java/org/apache/maven/building/StringSourceTest.java
@@ -19,12 +19,12 @@ package org.apache.maven.building;
* under the License.
*/
-import org.junit.Test;
-
import java.io.InputStream;
import java.util.Scanner;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class StringSourceTest
{
diff --git a/maven-builder-support/src/test/java/org/apache/maven/building/UrlSourceTest.java b/maven-builder-support/src/test/java/org/apache/maven/building/UrlSourceTest.java
index 00f3a6835a..efdb9bb684 100644
--- a/maven-builder-support/src/test/java/org/apache/maven/building/UrlSourceTest.java
+++ b/maven-builder-support/src/test/java/org/apache/maven/building/UrlSourceTest.java
@@ -19,15 +19,15 @@ package org.apache.maven.building;
* under the License.
*/
-import org.junit.Test;
-
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.Scanner;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class UrlSourceTest
{
@@ -35,15 +35,11 @@ public class UrlSourceTest
@Test
public void testUrlSource()
{
- try
- {
- new UrlSource( null );
- fail( "Should fail, since you must specify a url" );
- }
- catch ( NullPointerException e )
- {
- assertEquals( "url cannot be null", e.getMessage() );
- }
+ NullPointerException e = assertThrows(
+ NullPointerException.class,
+ () -> new UrlSource( null ),
+ "Should fail, since you must specify a url" );
+ assertEquals( "url cannot be null", e.getMessage() );
}
@Test
diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml
index 73d1a2463c..be1cd35786 100644
--- a/maven-compat/pom.xml
+++ b/maven-compat/pom.xml
@@ -99,6 +99,11 @@ under the License.
wagon-provider-api
+
+ org.apache.maven
+ maven-test-support
+ test
+
org.codehaus.plexus
plexus-cipher
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java
index 3c0ce1371b..146ec685eb 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java
@@ -19,6 +19,20 @@ package org.apache.maven.artifact;
* under the License.
*/
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.maven.test.PlexusTestCase;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
@@ -28,10 +42,6 @@ import org.apache.maven.execution.DefaultMavenExecutionResult;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.collection.DependencyGraphTransformer;
@@ -54,18 +64,11 @@ import org.eclipse.aether.util.graph.transformer.NearestVersionSelector;
import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector;
import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser;
import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
-import javax.inject.Inject;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Jason van Zyl
@@ -82,24 +85,15 @@ public abstract class AbstractArtifactComponentTestCase
@Inject
LegacySupport legacySupport;
- @Override
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- super.customizeContainerConfiguration( containerConfiguration );
- containerConfiguration.setAutoWiring( true );
- containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
- }
+ @Inject @Named( "default" )
+ ArtifactRepositoryLayout repoLayout;
- @Override
- protected void setUp()
+ @BeforeEach
+ public void setUp()
throws Exception
{
super.setUp();
- ((DefaultPlexusContainer)getContainer())
- .addPlexusInjector( Collections.emptyList(),
- binder -> binder.requestInjection( this ) );
-
RepositorySystemSession repoSession = initRepoSession();
MavenSession session = new MavenSession( getContainer(), repoSession, new DefaultMavenExecutionRequest(),
new DefaultMavenExecutionResult() );
@@ -107,15 +101,6 @@ public abstract class AbstractArtifactComponentTestCase
legacySupport.setSession( session );
}
- @Override
- protected void tearDown()
- throws Exception
- {
- release( artifactFactory );
-
- super.tearDown();
- }
-
protected abstract String component();
/**
@@ -132,9 +117,6 @@ public abstract class AbstractArtifactComponentTestCase
f.createNewFile();
- ArtifactRepositoryLayout repoLayout =
- (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
-
return artifactRepositoryFactory.createArtifactRepository( "test", "file://" + f.getPath(), repoLayout, null,
null );
}
@@ -151,9 +133,6 @@ public abstract class AbstractArtifactComponentTestCase
File f = new File( getBasedir(), path );
- ArtifactRepositoryLayout repoLayout =
- (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
-
return artifactRepositoryFactory.createArtifactRepository( "local", "file://" + f.getPath(), repoLayout, null,
null );
}
@@ -165,9 +144,6 @@ public abstract class AbstractArtifactComponentTestCase
File f = new File( getBasedir(), path );
- ArtifactRepositoryLayout repoLayout =
- (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
-
return artifactRepositoryFactory.createArtifactRepository( "test", "file://" + f.getPath(), repoLayout,
new ArtifactRepositoryPolicy(),
new ArtifactRepositoryPolicy() );
@@ -176,9 +152,6 @@ public abstract class AbstractArtifactComponentTestCase
protected ArtifactRepository badRemoteRepository()
throws Exception
{
- ArtifactRepositoryLayout repoLayout =
- (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
-
return artifactRepositoryFactory.createArtifactRepository( "test", "http://foo.bar/repository", repoLayout,
null, null );
}
@@ -192,10 +165,7 @@ public abstract class AbstractArtifactComponentTestCase
File file = new File( remoteRepo.getBasedir(), path );
- if ( !file.exists() )
- {
- fail( "Remote artifact " + file + " should be present." );
- }
+ assertTrue( file.exists(), "Remote artifact " + file + " should be present." );
}
protected void assertLocalArtifactPresent( Artifact artifact )
@@ -207,10 +177,7 @@ public abstract class AbstractArtifactComponentTestCase
File file = new File( localRepo.getBasedir(), path );
- if ( !file.exists() )
- {
- fail( "Local artifact " + file + " should be present." );
- }
+ assertTrue( file.exists(), "Local artifact " + file + " should be present." );
}
protected void assertRemoteArtifactNotPresent( Artifact artifact )
@@ -222,10 +189,7 @@ public abstract class AbstractArtifactComponentTestCase
File file = new File( remoteRepo.getBasedir(), path );
- if ( file.exists() )
- {
- fail( "Remote artifact " + file + " should not be present." );
- }
+ assertFalse( file.exists(), "Remote artifact " + file + " should not be present." );
}
protected void assertLocalArtifactNotPresent( Artifact artifact )
@@ -237,10 +201,7 @@ public abstract class AbstractArtifactComponentTestCase
File file = new File( localRepo.getBasedir(), path );
- if ( file.exists() )
- {
- fail( "Local artifact " + file + " should not be present." );
- }
+ assertFalse( file.exists(), "Local artifact " + file + " should not be present." );
}
// ----------------------------------------------------------------------
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java
index 30b1ab3396..05191ae684 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java
@@ -25,6 +25,11 @@ import org.apache.maven.artifact.AbstractArtifactComponentTestCase;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.inject.Inject;
@@ -42,6 +47,7 @@ public class ArtifactDeployerTest
return "deployer";
}
+ @Test
public void testArtifactInstallation()
throws Exception
{
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java
index cee9f5a11d..6dcf99acb0 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java
@@ -19,19 +19,14 @@ package org.apache.maven.artifact.factory;
* under the License.
*/
+import javax.inject.Inject;
+
+import org.apache.maven.test.PlexusTestCase;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.execution.DefaultMavenExecutionRequest;
-import org.apache.maven.execution.DefaultMavenExecutionResult;
-import org.apache.maven.execution.MavenSession;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
-import org.eclipse.aether.RepositorySystemSession;
+import org.junit.jupiter.api.Test;
-import javax.inject.Inject;
-import java.util.Collections;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class DefaultArtifactFactoryTest
extends PlexusTestCase
@@ -40,25 +35,7 @@ public class DefaultArtifactFactoryTest
@Inject
ArtifactFactory factory;
- @Override
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- super.customizeContainerConfiguration( containerConfiguration );
- containerConfiguration.setAutoWiring( true );
- containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
- }
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- ((DefaultPlexusContainer)getContainer())
- .addPlexusInjector( Collections.emptyList(),
- binder -> binder.requestInjection( this ) );
- }
-
+ @Test
public void testPropagationOfSystemScopeRegardlessOfInheritedScope()
{
Artifact artifact = factory.createDependencyArtifact( "test-grp", "test-artifact", VersionRange.createFromVersion("1.0"), "type", null, "system", "provided" );
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java
index df519b3b25..695c5cc2e5 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java
@@ -23,6 +23,8 @@ import java.io.File;
import org.apache.maven.artifact.AbstractArtifactComponentTestCase;
import org.apache.maven.artifact.Artifact;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import javax.inject.Inject;
@@ -40,6 +42,7 @@ public class ArtifactInstallerTest
return "installer";
}
+ @Test
public void testArtifactInstallation()
throws Exception
{
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/repository/MavenArtifactRepositoryTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/repository/MavenArtifactRepositoryTest.java
index 533f304207..4e7b5dc8c1 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/repository/MavenArtifactRepositoryTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/repository/MavenArtifactRepositoryTest.java
@@ -20,10 +20,12 @@ package org.apache.maven.artifact.repository;
*/
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class MavenArtifactRepositoryTest
- extends TestCase
{
private static class MavenArtifactRepositorySubclass extends MavenArtifactRepository
{
@@ -41,6 +43,7 @@ public class MavenArtifactRepositoryTest
}
}
+ @Test
public void testHashCodeEquals()
{
MavenArtifactRepositorySubclass r1 = new MavenArtifactRepositorySubclass( "foo" );
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java
index 8b75149c0c..e6b0e567a2 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.java
@@ -22,7 +22,9 @@ package org.apache.maven.artifact.resolver;
import java.util.Arrays;
import java.util.List;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test the artifact resolution exception message
@@ -30,10 +32,10 @@ import junit.framework.TestCase;
* @author Mauro Talevi
*/
public class ArtifactResolutionExceptionTest
- extends TestCase
{
private static final String LS = System.lineSeparator();
+ @Test
public void testMissingArtifactMessageFormat()
{
String message = "Missing artifact";
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java
index 00c1344da5..d621d906e9 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java
@@ -29,12 +29,18 @@ import java.util.Set;
import org.apache.maven.artifact.AbstractArtifactComponentTestCase;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.inject.Inject;
@@ -55,8 +61,9 @@ public class ArtifactResolverTest
private Artifact projectArtifact;
+ @BeforeEach
@Override
- protected void setUp()
+ public void setUp()
throws Exception
{
super.setUp();
@@ -64,8 +71,9 @@ public class ArtifactResolverTest
projectArtifact = createLocalArtifact( "project", "3.0" );
}
+ @AfterEach
@Override
- protected void tearDown()
+ public void tearDown()
throws Exception
{
projectArtifact = null;
@@ -78,6 +86,7 @@ public class ArtifactResolverTest
return "resolver";
}
+ @Test
public void testResolutionOfASingleArtifactWhereTheArtifactIsPresentInTheLocalRepository()
throws Exception
{
@@ -88,6 +97,7 @@ public class ArtifactResolverTest
assertLocalArtifactPresent( a );
}
+ @Test
public void testResolutionOfASingleArtifactWhereTheArtifactIsNotPresentLocallyAndMustBeRetrievedFromTheRemoteRepository()
throws Exception
{
@@ -105,6 +115,7 @@ public class ArtifactResolverTest
return super.createArtifact( groupId, artifactId, version, type );
}
+ @Test
public void testTransitiveResolutionWhereAllArtifactsArePresentInTheLocalRepository()
throws Exception
{
@@ -127,6 +138,7 @@ public class ArtifactResolverTest
assertLocalArtifactPresent( h );
}
+ @Test
public void testTransitiveResolutionWhereAllArtifactsAreNotPresentInTheLocalRepositoryAndMustBeRetrievedFromTheRemoteRepository()
throws Exception
{
@@ -151,22 +163,19 @@ public class ArtifactResolverTest
assertLocalArtifactPresent( j );
}
+ @Test
public void testResolutionFailureWhenArtifactNotPresentInRemoteRepository()
throws Exception
{
Artifact k = createArtifact( "k", "1.0" );
- try
- {
- artifactResolver.resolve( k, remoteRepositories(), localRepository() );
- fail( "Resolution succeeded when it should have failed" );
- }
- catch ( ArtifactNotFoundException expected )
- {
- assertTrue( true );
- }
+ assertThrows(
+ ArtifactNotFoundException.class,
+ () -> artifactResolver.resolve( k, remoteRepositories(), localRepository() ),
+ "Resolution succeeded when it should have failed" );
}
+ @Test
public void testResolutionOfAnArtifactWhereOneRemoteRepositoryIsBadButOneIsGood()
throws Exception
{
@@ -182,6 +191,7 @@ public class ArtifactResolverTest
assertLocalArtifactPresent( l );
}
+ @Test
public void testTransitiveResolutionOrder()
throws Exception
{
@@ -237,8 +247,8 @@ public class ArtifactResolverTest
printErrors( result );
Iterator i = result.getArtifacts().iterator();
- assertEquals( "n should be first", n, i.next() );
- assertEquals( "m should be second", m, i.next() );
+ assertEquals( n, i.next(), "n should be first" );
+ assertEquals( m, i.next(), "m should be second" );
// inverse order
set = new LinkedHashSet<>();
@@ -251,8 +261,8 @@ public class ArtifactResolverTest
printErrors( result );
i = result.getArtifacts().iterator();
- assertEquals( "m should be first", m, i.next() );
- assertEquals( "n should be second", n, i.next() );
+ assertEquals( m, i.next(), "m should be first" );
+ assertEquals( n, i.next(), "n should be second" );
}
private void printErrors( ArtifactResolutionResult result )
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java
index 9e221eeef7..fdd5f62bcf 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java
@@ -24,6 +24,11 @@ import java.util.Collections;
import org.apache.maven.artifact.AbstractArtifactComponentTestCase;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.DefaultArtifactResolver.DaemonThreadCreator;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.inject.Inject;
@@ -35,16 +40,18 @@ public class DefaultArtifactResolverTest
private Artifact projectArtifact;
+ @BeforeEach
@Override
- protected void setUp()
+ public void setUp()
throws Exception
{
super.setUp();
projectArtifact = createLocalArtifact( "project", "3.0" );
}
+ @AfterEach
@Override
- protected void tearDown()
+ public void tearDown()
throws Exception
{
projectArtifact = null;
@@ -57,6 +64,7 @@ public class DefaultArtifactResolverTest
return "resolver";
}
+ @Test
public void testMNG4738()
throws Exception
{
@@ -94,14 +102,15 @@ public class DefaultArtifactResolverTest
{
String name = active.getName();
boolean daemon = active.isDaemon();
- assertTrue( name + " is no daemon Thread.", daemon );
+ assertTrue( daemon, name + " is no daemon Thread." );
}
}
- assertTrue( "Could not find ThreadGroup: " + DaemonThreadCreator.THREADGROUP_NAME, seen );
+ assertTrue( seen, "Could not find ThreadGroup: " + DaemonThreadCreator.THREADGROUP_NAME );
}
+ @Test
public void testLookup()
throws Exception
{
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilterTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilterTest.java
index 50517f4e20..96a8882232 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilterTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilterTest.java
@@ -21,7 +21,11 @@ package org.apache.maven.artifact.resolver.filter;
import java.util.Arrays;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests {@link AndArtifactFilter}.
@@ -29,7 +33,6 @@ import junit.framework.TestCase;
* @author Benjamin Bentmann
*/
public class AndArtifactFilterTest
- extends TestCase
{
private ArtifactFilter newSubFilter()
@@ -37,6 +40,7 @@ public class AndArtifactFilterTest
return artifact -> false;
}
+ @Test
public void testEquals()
{
AndArtifactFilter filter1 = new AndArtifactFilter();
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/FilterHashEqualsTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/FilterHashEqualsTest.java
index fb4656637e..6c3df9e900 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/FilterHashEqualsTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/FilterHashEqualsTest.java
@@ -22,15 +22,17 @@ package org.apache.maven.artifact.resolver.filter;
import java.util.Arrays;
import java.util.List;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Igor Fedorenko
*/
public class FilterHashEqualsTest
- extends TestCase
{
+ @Test
public void testIncludesExcludesArtifactFilter()
{
List patterns = Arrays.asList( "c", "d", "e" );
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java
index 5971cc3823..65d9caa2b2 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/OrArtifactFilterTest.java
@@ -21,7 +21,11 @@ package org.apache.maven.artifact.resolver.filter;
import java.util.Arrays;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests {@link OrArtifactFilter}.
@@ -29,7 +33,6 @@ import junit.framework.TestCase;
* @author Benjamin Bentmann
*/
public class OrArtifactFilterTest
- extends TestCase
{
private ArtifactFilter newSubFilter()
@@ -37,6 +40,7 @@ public class OrArtifactFilterTest
return artifact -> false;
}
+ @Test
public void testEquals()
{
OrArtifactFilter filter1 = new OrArtifactFilter();
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilterTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilterTest.java
index 1a65eca082..914ff99bcb 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilterTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilterTest.java
@@ -21,8 +21,10 @@ package org.apache.maven.artifact.resolver.filter;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
+import org.junit.jupiter.api.Test;
-import junit.framework.TestCase;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests {@link ScopeArtifactFilter}.
@@ -30,7 +32,6 @@ import junit.framework.TestCase;
* @author Benjamin Bentmann
*/
public class ScopeArtifactFilterTest
- extends TestCase
{
private Artifact newArtifact( String scope )
@@ -38,6 +39,7 @@ public class ScopeArtifactFilterTest
return new DefaultArtifact( "g", "a", "1.0", scope, "jar", "", null );
}
+ @Test
public void testInclude_Compile()
{
ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE );
@@ -49,6 +51,7 @@ public class ScopeArtifactFilterTest
assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) );
}
+ @Test
public void testInclude_CompilePlusRuntime()
{
ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE_PLUS_RUNTIME );
@@ -60,6 +63,7 @@ public class ScopeArtifactFilterTest
assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) );
}
+ @Test
public void testInclude_Runtime()
{
ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME );
@@ -71,6 +75,7 @@ public class ScopeArtifactFilterTest
assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) );
}
+ @Test
public void testInclude_RuntimePlusSystem()
{
ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM );
@@ -82,6 +87,7 @@ public class ScopeArtifactFilterTest
assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) );
}
+ @Test
public void testInclude_Test()
{
ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_TEST );
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java b/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java
index 9761e75e52..558b5a5ca3 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java
@@ -45,7 +45,10 @@ import java.util.Iterator;
import java.util.List;
import org.codehaus.plexus.util.FileUtils;
-import org.junit.Assert;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestFileManager
{
@@ -157,11 +160,11 @@ public class TestFileManager
if ( shouldExist )
{
- Assert.assertTrue( file.exists() );
+ assertTrue( file.exists() );
}
else
{
- Assert.assertFalse( file.exists() );
+ assertFalse( file.exists() );
}
}
@@ -174,7 +177,7 @@ public class TestFileManager
String contents = FileUtils.fileRead( file, encoding );
- Assert.assertEquals( contentsTest, contents );
+ assertEquals( contentsTest, contents );
}
public File createFile( File dir, String filename, String contents, String encoding )
diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java
index ff0d3bbfa1..5c1ae2d289 100644
--- a/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java
@@ -15,7 +15,6 @@ package org.apache.maven.artifact.transform;
* the License.
*/
-import java.util.Collections;
import java.util.List;
import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformation;
@@ -23,10 +22,11 @@ import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformat
import org.apache.maven.repository.legacy.resolver.transform.LatestArtifactTransformation;
import org.apache.maven.repository.legacy.resolver.transform.ReleaseArtifactTransformation;
import org.apache.maven.repository.legacy.resolver.transform.SnapshotTransformation;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.inject.Inject;
@@ -37,36 +37,18 @@ public class TransformationManagerTest
@Inject
ArtifactTransformationManager tm;
- @Override
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- super.customizeContainerConfiguration( containerConfiguration );
- containerConfiguration.setAutoWiring( true );
- containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
- }
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- ((DefaultPlexusContainer)getContainer())
- .addPlexusInjector( Collections.emptyList(),
- binder -> binder.requestInjection( this ) );
- }
-
+ @Test
public void testTransformationManager()
{
List tms = tm.getArtifactTransformations();
assertEquals( 3, tms.size() );
- assertTrue( "We expected the release transformation and got " + tms.get(0), tms.get(0) instanceof ReleaseArtifactTransformation );
+ assertTrue( tms.get(0) instanceof ReleaseArtifactTransformation, "We expected the release transformation and got " + tms.get(0) );
- assertTrue( "We expected the latest transformation and got " + tms.get(1), tms.get(1) instanceof LatestArtifactTransformation );
+ assertTrue( tms.get(1) instanceof LatestArtifactTransformation, "We expected the latest transformation and got " + tms.get(1) );
- assertTrue( "We expected the snapshot transformation and got " + tms.get(2), tms.get(2) instanceof SnapshotTransformation );
+ assertTrue( tms.get(2) instanceof SnapshotTransformation, "We expected the snapshot transformation and got " + tms.get(2) );
}
}
diff --git a/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java b/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java
index 6b8caabf0f..442493a64c 100644
--- a/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java
@@ -19,36 +19,25 @@ package org.apache.maven.profiles.manager;
* under the License.
*/
-import java.util.Collections;
import java.util.List;
import java.util.Properties;
-import org.apache.maven.execution.DefaultMavenExecutionRequest;
-import org.apache.maven.execution.DefaultMavenExecutionResult;
-import org.apache.maven.execution.MavenSession;
+import org.apache.maven.test.PlexusTestCase;
import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationProperty;
import org.apache.maven.model.Profile;
import org.apache.maven.profiles.DefaultProfileManager;
import org.apache.maven.profiles.ProfileManager;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
-import org.eclipse.aether.RepositorySystemSession;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class DefaultProfileManagerTest
extends PlexusTestCase
{
- @Override
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- super.customizeContainerConfiguration( containerConfiguration );
- containerConfiguration.setAutoWiring( true );
- containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
- }
-
+ @Test
public void testShouldActivateDefaultProfile()
throws Exception
{
@@ -84,6 +73,7 @@ public class DefaultProfileManagerTest
assertEquals( "defaultActivated", ( (Profile) active.get( 0 ) ).getId() );
}
+ @Test
public void testShouldNotActivateDefaultProfile()
throws Exception
{
@@ -123,6 +113,7 @@ public class DefaultProfileManagerTest
}
+ @Test
public void testShouldNotActivateReversalOfPresentSystemProperty()
throws Exception
{
@@ -150,6 +141,7 @@ public class DefaultProfileManagerTest
assertEquals( 0, active.size() );
}
+ @Test
public void testShouldOverrideAndActivateInactiveProfile()
throws Exception
{
@@ -180,6 +172,7 @@ public class DefaultProfileManagerTest
assertEquals( "syspropActivated", ( (Profile) active.get( 0 ) ).getId() );
}
+ @Test
public void testShouldOverrideAndDeactivateActiveProfile()
throws Exception
{
diff --git a/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
index d05aa8f59a..338cffa6a0 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
@@ -21,25 +21,21 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;
-import java.util.Collections;
+import javax.inject.Inject;
+
+import org.apache.maven.test.PlexusTestCase;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.execution.DefaultMavenExecutionRequest;
-import org.apache.maven.execution.DefaultMavenExecutionResult;
-import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.building.ModelBuildingException;
import org.apache.maven.model.building.ModelProblem;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
import org.eclipse.aether.DefaultRepositorySystemSession;
-import org.eclipse.aether.RepositorySystemSession;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
-import javax.inject.Inject;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Jason van Zyl
@@ -53,23 +49,12 @@ public abstract class AbstractMavenProjectTestCase
protected RepositorySystem repositorySystem;
@Override
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- super.customizeContainerConfiguration( containerConfiguration );
- containerConfiguration.setAutoWiring( true );
- containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
- }
-
- @Override
- protected void setUp()
- throws Exception
+ @BeforeEach
+ public void setUp()
+ throws Exception
{
super.setUp();
- ((DefaultPlexusContainer)getContainer())
- .addPlexusInjector( Collections.emptyList(),
- binder -> binder.requestInjection( this ) );
-
if ( getContainer().hasComponent( ProjectBuilder.class, "test" ) )
{
projectBuilder = lookup( ProjectBuilder.class, "test" );
@@ -81,8 +66,8 @@ public abstract class AbstractMavenProjectTestCase
}
}
- @Override
- protected void tearDown()
+ @AfterEach
+ public void tearDown()
throws Exception
{
projectBuilder = null;
diff --git a/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java b/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java
index 402ae74b91..74178d98c3 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/ModelUtilsTest.java
@@ -26,8 +26,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
@@ -36,11 +34,17 @@ import org.apache.maven.model.PluginExecution;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
public class ModelUtilsTest
- extends TestCase
{
+ @Test
public void testShouldUseMainPluginDependencyVersionOverManagedDepVersion()
{
Plugin mgtPlugin = createPlugin( "group", "artifact", "1", Collections.EMPTY_MAP );
@@ -68,6 +72,7 @@ public class ModelUtilsTest
return dep;
}
+ @Test
public void testShouldNotInheritPluginWithInheritanceSetToFalse()
{
PluginContainer parent = new PluginContainer();
@@ -108,6 +113,7 @@ public class ModelUtilsTest
* X -> Y -> A -> B -> C -> D -> E -> F
*
*/
+ @Test
public void testShouldPreserveChildOrderingOfPluginsAfterParentMerge()
{
PluginContainer parent = new PluginContainer();
@@ -176,6 +182,7 @@ public class ModelUtilsTest
return plugin;
}
+ @Test
public void testShouldInheritOnePluginWithExecution()
{
Plugin parent = new Plugin();
@@ -198,6 +205,7 @@ public class ModelUtilsTest
assertEquals( 1, child.getExecutions().size() );
}
+ @Test
public void testShouldMergeInheritedPluginHavingExecutionWithLocalPlugin()
{
Plugin parent = new Plugin();
@@ -225,6 +233,7 @@ public class ModelUtilsTest
assertEquals( 2, child.getExecutions().size() );
}
+ @Test
public void testShouldMergeOnePluginWithInheritExecutionWithoutDuplicatingPluginInList()
{
Plugin parent = new Plugin();
@@ -259,6 +268,7 @@ public class ModelUtilsTest
assertEquals( 1, plugin.getExecutions().size() );
}
+ @Test
public void testShouldMergePluginWithDifferentExecutionFromParentWithoutDuplicatingPluginInList()
{
Plugin parent = new Plugin();
@@ -299,6 +309,7 @@ public class ModelUtilsTest
assertEquals( 2, plugin.getExecutions().size() );
}
+ @Test
public void testShouldNOTMergeInheritedPluginHavingInheritEqualFalse()
{
Plugin parent = new Plugin();
@@ -326,6 +337,7 @@ public class ModelUtilsTest
* Verifies MNG-1499: The order of the merged list should be the plugins specified by the parent followed by the
* child list.
*/
+ @Test
public void testShouldKeepOriginalPluginOrdering()
{
Plugin parentPlugin1 = new Plugin();
@@ -390,6 +402,7 @@ public class ModelUtilsTest
/**
* Verifies MNG-1499: The ordering of plugin executions should also be in the specified order.
*/
+ @Test
public void testShouldKeepOriginalPluginExecutionOrdering()
{
Plugin parent = new Plugin();
@@ -439,6 +452,7 @@ public class ModelUtilsTest
assertEquals( dep.getManagementKey(), dep2.getManagementKey() );
}
+ @Test
public void testShouldOverwritePluginConfigurationSubItemsByDefault()
throws XmlPullParserException, IOException
{
@@ -465,6 +479,7 @@ public class ModelUtilsTest
assertEquals( "three", item.getValue() );
}
+ @Test
public void testShouldMergePluginConfigurationSubItemsWithMergeAttributeSet()
throws XmlPullParserException, IOException
{
@@ -496,6 +511,7 @@ public class ModelUtilsTest
assertEquals( expected, actual );
}
+ @Test
public void testShouldNotMergePluginExecutionWhenExecInheritedIsFalseAndTreatAsInheritanceIsTrue()
{
String gid = "group";
@@ -533,9 +549,10 @@ public class ModelUtilsTest
ModelUtils.mergePluginDefinitions( pChild, pParent, true );
Map executionMap = pChild.getExecutionsAsMap();
- assertNull( "test execution should not be inherited from parent.", executionMap.get( testId ) );
+ assertNull( executionMap.get( testId ), "test execution should not be inherited from parent." );
}
+ @Test
public void testShouldNotMergePluginExecutionWhenPluginInheritedIsFalseAndTreatAsInheritanceIsTrue()
{
String gid = "group";
@@ -573,9 +590,10 @@ public class ModelUtilsTest
ModelUtils.mergePluginDefinitions( pChild, pParent, true );
Map executionMap = pChild.getExecutionsAsMap();
- assertNull( "test execution should not be inherited from parent.", executionMap.get( testId ) );
+ assertNull( executionMap.get( testId ), "test execution should not be inherited from parent." );
}
+ @Test
public void testShouldMergePluginExecutionWhenExecInheritedIsTrueAndTreatAsInheritanceIsTrue()
{
String gid = "group";
@@ -613,7 +631,7 @@ public class ModelUtilsTest
ModelUtils.mergePluginDefinitions( pChild, pParent, true );
Map executionMap = pChild.getExecutionsAsMap();
- assertNotNull( "test execution should be inherited from parent.", executionMap.get( testId ) );
+ assertNotNull( executionMap.get( testId ), "test execution should be inherited from parent." );
}
}
diff --git a/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java b/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java
index 96f1feaa94..0cc449f863 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java
@@ -20,20 +20,17 @@ package org.apache.maven.project;
*/
import java.io.File;
-import java.util.Collections;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.execution.DefaultMavenExecutionRequest;
-import org.apache.maven.execution.DefaultMavenExecutionResult;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusConstants;
-import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.impl.ArtifactDescriptorReader;
import org.eclipse.aether.impl.ArtifactResolver;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class ProjectClasspathTest
extends AbstractMavenProjectTestCase
@@ -41,23 +38,12 @@ public class ProjectClasspathTest
static final String dir = "projects/scope/";
@Override
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- super.customizeContainerConfiguration( containerConfiguration );
- containerConfiguration.setAutoWiring( true );
- containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
- }
-
- @Override
- protected void setUp()
+ @BeforeEach
+ public void setUp()
throws Exception
{
super.setUp();
- ((DefaultPlexusContainer)getContainer())
- .addPlexusInjector( Collections.emptyList(),
- binder -> binder.requestInjection( this ) );
-
ArtifactResolver resolver = lookup( ArtifactResolver.class, "classpath" );
DefaultArtifactDescriptorReader pomReader = (DefaultArtifactDescriptorReader)lookup(ArtifactDescriptorReader.class);
pomReader.setArtifactResolver( resolver );
@@ -71,6 +57,7 @@ public class ProjectClasspathTest
return null;
}
+ @Test
public void testProjectClasspath()
throws Exception
{
@@ -80,7 +67,7 @@ public class ProjectClasspathTest
Artifact artifact;
- assertNotNull( "Test project can't be null!", project );
+ assertNotNull( project, "Test project can't be null!" );
checkArtifactIdScope( project, "provided", "provided" );
checkArtifactIdScope( project, "test", "test" );
@@ -90,53 +77,53 @@ public class ProjectClasspathTest
// check all transitive deps of a test dependency are test, except test and provided which is skipped
artifact = getArtifact( project, "maven-test-test", "scope-provided" );
- assertNull( "Check no provided dependencies are transitive", artifact );
+ assertNull( artifact, "Check no provided dependencies are transitive" );
artifact = getArtifact( project, "maven-test-test", "scope-test" );
- assertNull( "Check no test dependencies are transitive", artifact );
+ assertNull( artifact, "Check no test dependencies are transitive" );
artifact = getArtifact( project, "maven-test-test", "scope-compile" );
assertNotNull( artifact );
System.out.println( "a = " + artifact );
System.out.println( "b = " + artifact.getScope() );
- assertEquals( "Check scope", "test", artifact.getScope() );
+ assertEquals( "test", artifact.getScope(), "Check scope" );
artifact = getArtifact( project, "maven-test-test", "scope-default" );
- assertEquals( "Check scope", "test", artifact.getScope() );
+ assertEquals( "test", artifact.getScope(), "Check scope" );
artifact = getArtifact( project, "maven-test-test", "scope-runtime" );
- assertEquals( "Check scope", "test", artifact.getScope() );
+ assertEquals( "test", artifact.getScope(), "Check scope" );
// check all transitive deps of a provided dependency are provided scope, except for test
checkGroupIdScope( project, "provided", "maven-test-provided" );
artifact = getArtifact( project, "maven-test-provided", "scope-runtime" );
- assertEquals( "Check scope", "provided", artifact.getScope() );
+ assertEquals( "provided", artifact.getScope(), "Check scope" );
// check all transitive deps of a runtime dependency are runtime scope, except for test
checkGroupIdScope( project, "runtime", "maven-test-runtime" );
artifact = getArtifact( project, "maven-test-runtime", "scope-runtime" );
- assertEquals( "Check scope", "runtime", artifact.getScope() );
+ assertEquals( "runtime", artifact.getScope(), "Check scope" );
// check all transitive deps of a compile dependency are compile scope, except for runtime and test
checkGroupIdScope( project, "compile", "maven-test-compile" );
artifact = getArtifact( project, "maven-test-compile", "scope-runtime" );
- assertEquals( "Check scope", "runtime", artifact.getScope() );
+ assertEquals( "runtime", artifact.getScope(), "Check scope" );
// check all transitive deps of a default dependency are compile scope, except for runtime and test
checkGroupIdScope( project, "compile", "maven-test-default" );
artifact = getArtifact( project, "maven-test-default", "scope-runtime" );
- assertEquals( "Check scope", "runtime", artifact.getScope() );
+ assertEquals( "runtime", artifact.getScope(), "Check scope" );
}
private void checkGroupIdScope( MavenProject project, String scopeValue, String groupId )
{
Artifact artifact;
artifact = getArtifact( project, groupId, "scope-compile" );
- assertEquals( "Check scope", scopeValue, artifact.getScope() );
+ assertEquals( scopeValue, artifact.getScope(), "Check scope" );
artifact = getArtifact( project, groupId, "scope-test" );
- assertNull( "Check test dependency is not transitive", artifact );
+ assertNull( artifact, "Check test dependency is not transitive" );
artifact = getArtifact( project, groupId, "scope-provided" );
- assertNull( "Check provided dependency is not transitive", artifact );
+ assertNull( artifact, "Check provided dependency is not transitive" );
artifact = getArtifact( project, groupId, "scope-default" );
- assertEquals( "Check scope", scopeValue, artifact.getScope() );
+ assertEquals( scopeValue, artifact.getScope(), "Check scope" );
}
private void checkArtifactIdScope( MavenProject project, String scope, String scopeValue )
@@ -144,7 +131,7 @@ public class ProjectClasspathTest
String artifactId = "scope-" + scope;
Artifact artifact = getArtifact( project, "maven-test", artifactId );
assertNotNull( artifact );
- assertEquals( "Check scope", scopeValue, artifact.getScope() );
+ assertEquals( scopeValue, artifact.getScope(), "Check scope" );
}
private Artifact getArtifact( MavenProject project, String groupId, String artifactId )
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java
index 98da0f5aa4..936424dbac 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java
@@ -21,6 +21,9 @@ package org.apache.maven.project.inheritance.t00;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* A test which demonstrates maven's recursive inheritance where
@@ -50,6 +53,7 @@ public class ProjectInheritanceTest
//
// ----------------------------------------------------------------------
+ @Test
public void testProjectInheritance()
throws Exception
{
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.java
index 1aa749b598..8f8199e9c1 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.java
@@ -21,6 +21,9 @@ package org.apache.maven.project.inheritance.t01;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* A test which demonstrates maven's recursive inheritance where
@@ -46,6 +49,7 @@ public class ProjectInheritanceTest
//
// ----------------------------------------------------------------------
+ @Test
public void testProjectInheritance()
throws Exception
{
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java
index 2b783431ce..61a393238b 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java
@@ -26,8 +26,14 @@ import java.util.Map;
import org.apache.maven.model.Build;
import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginExecution;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* A test which demonstrates maven's recursive inheritance where
@@ -57,6 +63,7 @@ public class ProjectInheritanceTest
//
// ----------------------------------------------------------------------
+ @Test
public void testProjectInheritance()
throws Exception
{
@@ -134,33 +141,25 @@ public class ProjectInheritanceTest
{
String pluginArtifactId = plugin.getArtifactId();
- if ( !validPluginCounts.containsKey( pluginArtifactId ) )
+ assertTrue( validPluginCounts.containsKey( pluginArtifactId ), "Illegal plugin found: " + pluginArtifactId );
+
+ if ( pluginArtifactId.equals( testPluginArtifactId ) )
{
- fail( "Illegal plugin found: " + pluginArtifactId );
+ testPlugin = plugin;
}
- else
- {
- if ( pluginArtifactId.equals( testPluginArtifactId ) )
- {
- testPlugin = plugin;
- }
- Integer count = validPluginCounts.get( pluginArtifactId );
+ Integer count = validPluginCounts.get( pluginArtifactId );
- if ( count > 0 )
- {
- fail( "Multiple copies of plugin: " + pluginArtifactId + " found in POM." );
- }
- else
- {
- count = count + 1;
+ assertEquals( 0, (int) count, "Multiple copies of plugin: " + pluginArtifactId + " found in POM." );
- validPluginCounts.put( pluginArtifactId, count );
- }
- }
+ count = count + 1;
+
+ validPluginCounts.put( pluginArtifactId, count );
}
- List executions = testPlugin.getExecutions();
+ assertNotNull( testPlugin );
+
+ List executions = testPlugin.getExecutions();
assertEquals( 1, executions.size() );
}
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t03/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t03/ProjectInheritanceTest.java
index edb6107ac9..3c658d8dbd 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t03/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t03/ProjectInheritanceTest.java
@@ -23,6 +23,9 @@ import java.io.File;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* A test which demonstrates maven's recursive inheritance where
@@ -49,6 +52,7 @@ public class ProjectInheritanceTest
//
// ----------------------------------------------------------------------
+ @Test
public void testProjectInheritance()
throws Exception
{
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java
index ab775ec1d6..34a31d5e21 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.java
@@ -25,6 +25,11 @@ import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Verifies the version of a dependency listed in a parent's
@@ -51,6 +56,7 @@ public class ProjectInheritanceTest
//
// ----------------------------------------------------------------------
+ @Test
public void testDependencyManagementOverridesTransitiveDependencyVersion()
throws Exception
{
@@ -65,9 +71,9 @@ public class ProjectInheritanceTest
assertEquals( pom0Basedir, project1.getParent().getBasedir() );
Set set = project1.getArtifacts();
- assertNotNull( "No artifacts", set );
- assertTrue( "No Artifacts", set.size() > 0 );
- assertTrue( "Set size should be 3, is " + set.size(), set.size() == 3 );
+ assertNotNull( set, "No artifacts" );
+ assertTrue( set.size() > 0, "No Artifacts" );
+ assertTrue( set.size() == 3, "Set size should be 3, is " + set.size() );
for ( Object aSet : set )
{
@@ -77,8 +83,8 @@ public class ProjectInheritanceTest
artifact.isOptional()
? "true"
: "false" ) );
- assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
- artifact.getVersion().equals( "1.0" ) );
+ assertTrue( artifact.getVersion().equals( "1.0" ),
+ "Incorrect version for " + artifact.getDependencyConflictId() );
}
}
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java
index 1517157033..8af4a2fdf7 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.java
@@ -25,6 +25,11 @@ import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* A test which demonstrates maven's dependency management
@@ -45,6 +50,7 @@ public class ProjectInheritanceTest
//
// ----------------------------------------------------------------------
+ @Test
public void testDependencyManagement()
throws Exception
{
@@ -61,8 +67,8 @@ public class ProjectInheritanceTest
assertEquals( pom0Basedir, project1.getParent().getBasedir() );
Set set = project1.getArtifacts();
- assertNotNull( "No artifacts", set );
- assertTrue( "No Artifacts", set.size() > 0 );
+ assertNotNull( set, "No artifacts" );
+ assertTrue( set.size() > 0, "No Artifacts" );
for ( Object aSet : set )
{
@@ -70,8 +76,8 @@ public class ProjectInheritanceTest
System.out.println(
"Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Scope: "
+ artifact.getScope() );
- assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
- artifact.getVersion().equals( "1.0" ) );
+ assertTrue( artifact.getVersion().equals( "1.0" ),
+ "Incorrect version for " + artifact.getDependencyConflictId() );
}
}
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java
index 60e37719a2..bc37066a05 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.java
@@ -26,6 +26,11 @@ import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* A test which demonstrates maven's dependency management
@@ -46,6 +51,7 @@ public class ProjectInheritanceTest
//
// ----------------------------------------------------------------------
+ @Test
public void testDependencyManagement()
throws Exception
{
@@ -62,18 +68,18 @@ public class ProjectInheritanceTest
assertEquals( pom0Basedir, project1.getParent().getBasedir() );
Set set = project1.getArtifacts();
- assertNotNull( "No artifacts", set );
- assertTrue( "No Artifacts", set.size() > 0 );
+ assertNotNull( set, "No artifacts" );
+ assertTrue( set.size() > 0, "No Artifacts" );
Iterator iter = set.iterator();
- assertTrue( "Set size should be 4, is " + set.size(), set.size() == 4 );
+ assertTrue( set.size() == 4, "Set size should be 4, is " + set.size() );
while ( iter.hasNext() )
{
Artifact artifact = (Artifact) iter.next();
System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion()
+ " Optional=" + ( artifact.isOptional() ? "true" : "false" ) );
- assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
- artifact.getVersion().equals( "1.0" ) );
+ assertTrue( artifact.getVersion().equals( "1.0" ),
+ "Incorrect version for " + artifact.getDependencyConflictId() );
}
}
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java
index b9685e39a6..87b07d3a80 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.java
@@ -25,6 +25,12 @@ import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* A test which demonstrates maven's dependency management
@@ -45,6 +51,7 @@ public class ProjectInheritanceTest
//
// ----------------------------------------------------------------------
+ @Test
public void testDependencyManagement()
throws Exception
{
@@ -61,21 +68,21 @@ public class ProjectInheritanceTest
assertEquals( pom0Basedir, project1.getParent().getBasedir() );
System.out.println("Project " + project1.getId() + " " + project1);
Set set = project1.getArtifacts();
- assertNotNull("No artifacts", set);
- assertTrue("No Artifacts", set.size() > 0);
- assertTrue("Set size should be 3, is " + set.size(), set.size() == 3 );
+ assertNotNull( set, "No artifacts" );
+ assertTrue( set.size() > 0, "No Artifacts" );
+ assertTrue( set.size() == 3, "Set size should be 3, is " + set.size() );
for ( Object aSet : set )
{
Artifact artifact = (Artifact) aSet;
- assertFalse( "", artifact.getArtifactId().equals( "t07-d" ) );
+ assertFalse( artifact.getArtifactId().equals( "t07-d" ) );
System.out.println(
"Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + (
artifact.isOptional()
? "true"
: "false" ) );
- assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
- artifact.getVersion().equals( "1.0" ) );
+ assertTrue( artifact.getVersion().equals( "1.0" ),
+ "Incorrect version for " + artifact.getDependencyConflictId() );
}
}
}
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java
index b0a7873bdf..c4562dc67e 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.java
@@ -26,6 +26,11 @@ import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* A test which demonstrates maven's dependency management
@@ -46,6 +51,7 @@ public class ProjectInheritanceTest
//
// ----------------------------------------------------------------------
+ @Test
public void testDependencyManagement()
throws Exception
{
@@ -63,18 +69,17 @@ public class ProjectInheritanceTest
assertEquals( pom0Basedir, project1.getParent().getBasedir() );
System.out.println( "Project " + project1.getId() + " " + project1 );
Set set = project1.getArtifacts();
- assertNotNull( "No artifacts", set );
- assertTrue( "No Artifacts", set.size() > 0 );
+ assertNotNull( set, "No artifacts" );
+ assertTrue( set.size() > 0, "No Artifacts" );
Iterator iter = set.iterator();
- assertTrue( "Set size should be 4, is " + set.size(), set.size() == 4 );
+ assertTrue( set.size() == 4, "Set size should be 4, is " + set.size() );
while ( iter.hasNext() )
{
Artifact artifact = (Artifact) iter.next();
System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion()
+ " Optional=" + ( artifact.isOptional() ? "true" : "false" ) );
- assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
- artifact.getVersion().equals( "1.0" ) );
+ assertTrue( artifact.getVersion().equals( "1.0" ), "Incorrect version for " + artifact.getDependencyConflictId() );
}
}
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java
index 29cd2ea6ab..dcc4e8bf7e 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.java
@@ -23,6 +23,12 @@ import java.util.Map;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Verifies exclusions listed in dependencyManagement are valid for
@@ -56,6 +62,7 @@ public class ProjectInheritanceTest
* We should see that the resulting size of collected artifacts is two:
* a & b only.
*/
+ @Test
public void testDependencyManagementExclusionsExcludeTransitively()
throws Exception
{
@@ -69,17 +76,17 @@ public class ProjectInheritanceTest
MavenProject project0 = getProjectWithDependencies( pom0 );
MavenProject project1 = getProjectWithDependencies( pom1 );
- assertNotNull("Parent is null", project1.getParent());
+ assertNotNull( project1.getParent(), "Parent is null" );
assertEquals( pom0Basedir, project1.getParent().getBasedir() );
Map map = project1.getArtifactMap();
- assertNotNull("No artifacts", map);
- assertTrue("No Artifacts", map.size() > 0);
- assertTrue("Set size should be 2, is " + map.size(), map.size() == 2);
+ assertNotNull( map, "No artifacts" );
+ assertTrue( map.size() > 0, "No Artifacts" );
+ assertTrue( map.size() == 2, "Set size should be 2, is " + map.size() );
- assertTrue("maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" ));
- assertTrue("maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" ));
- assertFalse("maven-test:t09-c is in the project", map.containsKey( "maven-test:t09-c" ));
+ assertTrue( map.containsKey( "maven-test:t09-a" ), "maven-test:t09-a is not in the project" );
+ assertTrue( map.containsKey( "maven-test:t09-b" ), "maven-test:t09-b is not in the project" );
+ assertFalse( map.containsKey( "maven-test:t09-c" ), "maven-test:t09-c is in the project" );
}
/**
@@ -92,6 +99,7 @@ public class ProjectInheritanceTest
*
* @throws Exception
*/
+ @Test
public void testDependencyManagementExclusionDoesNotOverrideGloballyForTransitives()
throws Exception
{
@@ -107,13 +115,13 @@ public class ProjectInheritanceTest
assertEquals( pom0Basedir, project2.getParent().getBasedir() );
Map map = project2.getArtifactMap();
- assertNotNull( "No artifacts", map );
- assertTrue( "No Artifacts", map.size() > 0 );
- assertTrue( "Set size should be 4, is " + map.size(), map.size() == 4 );
+ assertNotNull( map, "No artifacts" );
+ assertTrue( map.size() > 0, "No Artifacts" );
+ assertTrue( map.size() == 4, "Set size should be 4, is " + map.size() );
- assertTrue( "maven-test:t09-a is not in the project", map.containsKey( "maven-test:t09-a" ) );
- assertTrue( "maven-test:t09-b is not in the project", map.containsKey( "maven-test:t09-b" ) );
- assertTrue( "maven-test:t09-c is not in the project", map.containsKey( "maven-test:t09-c" ) );
- assertTrue( "maven-test:t09-d is not in the project", map.containsKey( "maven-test:t09-d" ) );
+ assertTrue( map.containsKey( "maven-test:t09-a" ), "maven-test:t09-a is not in the project" );
+ assertTrue( map.containsKey( "maven-test:t09-b" ), "maven-test:t09-b is not in the project" );
+ assertTrue( map.containsKey( "maven-test:t09-c" ), "maven-test:t09-c is not in the project" );
+ assertTrue( map.containsKey( "maven-test:t09-d" ), "maven-test:t09-d is not in the project" );
}
}
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java
index b24f70f39c..b1e74087ba 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.java
@@ -25,6 +25,11 @@ import java.util.Map;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Verifies scope inheritance of direct and transitive dependencies.
@@ -52,6 +57,7 @@ public class ProjectInheritanceTest
//
// ----------------------------------------------------------------------
+ @Test
public void testDependencyManagementOverridesTransitiveDependencyVersion()
throws Exception
{
@@ -68,9 +74,9 @@ public class ProjectInheritanceTest
assertEquals( pom0Basedir, project1.getParent().getBasedir() );
System.out.println("Project " + project1.getId() + " " + project1);
Map map = project1.getArtifactMap();
- assertNotNull("No artifacts", map);
- assertTrue("No Artifacts", map.size() > 0);
- assertTrue("Set size should be 3, is " + map.size(), map.size() == 3);
+ assertNotNull( map, "No artifacts" );
+ assertTrue( map.size() > 0, "No Artifacts" );
+ assertTrue( map.size() == 3, "Set size should be 3, is " + map.size() );
Artifact a = (Artifact) map.get("maven-test:t10-a");
Artifact b = (Artifact) map.get("maven-test:t10-b");
@@ -82,13 +88,13 @@ public class ProjectInheritanceTest
// inherited from depMgmt
System.out.println(a.getScope());
- assertTrue("Incorrect scope for " + a.getDependencyConflictId(), a.getScope().equals("test"));
+ assertTrue( a.getScope().equals("test"), "Incorrect scope for " + a.getDependencyConflictId() );
// transitive dep, overridden b depMgmt
- assertTrue("Incorrect scope for " + b.getDependencyConflictId(), b.getScope().equals("runtime"));
+ assertTrue( b.getScope().equals("runtime"), "Incorrect scope for " + b.getDependencyConflictId() );
// direct dep, overrides depMgmt
- assertTrue("Incorrect scope for " + c.getDependencyConflictId(), c.getScope().equals("runtime"));
+ assertTrue( c.getScope().equals("runtime"), "Incorrect scope for " + c.getDependencyConflictId() );
}
}
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.java
index d8a3926742..3f21d5e0ad 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.java
@@ -23,6 +23,10 @@ import java.io.File;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Verifies scope of root project is preserved regardless of parent dependency management.
@@ -44,6 +48,7 @@ public class ProjectInheritanceTest
//
// ----------------------------------------------------------------------
+ @Test
public void testDependencyManagementDoesNotOverrideScopeOfCurrentArtifact()
throws Exception
{
@@ -58,7 +63,7 @@ public class ProjectInheritanceTest
MavenProject project1 = getProjectWithDependencies( pom1 );
assertEquals( pom0Basedir, project1.getParent().getBasedir() );
- assertNull( "dependencyManagement has overwritten the scope of the currently building child project",
- project1.getArtifact().getScope() );
+ assertNull( project1.getArtifact().getScope(),
+ "dependencyManagement has overwritten the scope of the currently building child project" );
}
}
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12/ProjectInheritanceTest.java
index 814e48719e..086d710eb2 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12/ProjectInheritanceTest.java
@@ -25,6 +25,10 @@ import java.util.Map;
import org.apache.maven.model.Plugin;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Verifies that plugin execution sections in the parent POM that have
@@ -43,6 +47,7 @@ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase
//
// ----------------------------------------------------------------------
+ @Test
public void testFalsePluginExecutionInheritValue() throws Exception
{
File localRepo = getLocalRepositoryPath();
@@ -60,6 +65,6 @@ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase
assertNotNull( compilerPlugin );
Map executionMap = compilerPlugin.getExecutionsAsMap();
- assertNull( "Plugin execution: \'test\' should NOT exist in the compiler plugin specification for the child project!", executionMap.get( "test" ) );
+ assertNull( executionMap.get( "test" ), "Plugin execution: \'test\' should NOT exist in the compiler plugin specification for the child project!" );
}
}
\ No newline at end of file
diff --git a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12scm/ProjectInheritanceTest.java b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12scm/ProjectInheritanceTest.java
index 7627c1355d..82aee6c70f 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12scm/ProjectInheritanceTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/inheritance/t12scm/ProjectInheritanceTest.java
@@ -23,6 +23,9 @@ import java.io.File;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Verifies SCM inheritance uses modules statement from parent.
@@ -43,6 +46,7 @@ public class ProjectInheritanceTest
//
// ----------------------------------------------------------------------
+ @Test
public void testScmInfoCalculatedCorrectlyOnParentAndChildRead()
throws Exception
{
@@ -76,6 +80,7 @@ public class ProjectInheritanceTest
+ "/modules/p1" );
}
+ @Test
public void testScmInfoCalculatedCorrectlyOnChildOnlyRead()
throws Exception
{
diff --git a/maven-compat/src/test/java/org/apache/maven/project/path/DefaultPathTranslatorTest.java b/maven-compat/src/test/java/org/apache/maven/project/path/DefaultPathTranslatorTest.java
index b19ef99683..022ccd5592 100644
--- a/maven-compat/src/test/java/org/apache/maven/project/path/DefaultPathTranslatorTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/project/path/DefaultPathTranslatorTest.java
@@ -21,13 +21,14 @@ package org.apache.maven.project.path;
import java.io.File;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
@SuppressWarnings( "deprecation" )
public class DefaultPathTranslatorTest
- extends TestCase
{
+ @Test
public void testAlignToBasedirWhereBasedirExpressionIsTheCompleteValue()
{
File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile();
@@ -37,6 +38,7 @@ public class DefaultPathTranslatorTest
assertEquals( basedir.getAbsolutePath(), aligned );
}
+ @Test
public void testAlignToBasedirWhereBasedirExpressionIsTheValuePrefix()
{
File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile();
@@ -46,6 +48,7 @@ public class DefaultPathTranslatorTest
assertEquals( new File( basedir, "dir" ).getAbsolutePath(), aligned );
}
+ @Test
public void testUnalignToBasedirWherePathEqualsBasedir()
{
File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile();
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java b/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java
index 5735db0ec5..97687e3207 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java
@@ -21,9 +21,9 @@ package org.apache.maven.repository;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
public class DefaultMirrorSelectorTest
{
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java b/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java
index 65dbd892a1..eb56bc8590 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java
@@ -17,7 +17,6 @@ package org.apache.maven.repository;
import java.io.File;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import org.apache.maven.artifact.Artifact;
@@ -32,16 +31,18 @@ import org.apache.maven.model.Dependency;
import org.apache.maven.model.Repository;
import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.plugin.LegacySupport;
-import org.apache.maven.project.ProjectBuilder;
-import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.legacy.LegacyRepositorySystem;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.inject.Inject;
@@ -58,25 +59,6 @@ public class LegacyRepositorySystemTest
@Inject
private ResolutionErrorHandler resolutionErrorHandler;
- @Override
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- super.customizeContainerConfiguration( containerConfiguration );
- containerConfiguration.setAutoWiring( true );
- containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
- }
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- ((DefaultPlexusContainer)getContainer())
- .addPlexusInjector( Collections.emptyList(),
- binder -> binder.requestInjection( this ) );
- }
-
protected List getRemoteRepositories()
throws Exception
{
@@ -104,6 +86,7 @@ public class LegacyRepositorySystemTest
return repositorySystem.createLocalRepository( repoDir );
}
+ @Test
public void testThatASystemScopedDependencyIsNotResolvedFromRepositories()
throws Exception
{
@@ -186,6 +169,7 @@ public class LegacyRepositorySystemTest
}
}
+ @Test
public void testLocalRepositoryBasedir()
throws Exception
{
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java b/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java
index 8492f7bcad..443bc44135 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java
@@ -20,17 +20,21 @@ package org.apache.maven.repository;
*/
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
+import org.apache.maven.test.PlexusTestCase;
import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
import org.apache.maven.settings.Mirror;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.inject.Inject;
@@ -39,28 +43,11 @@ public class MirrorProcessorTest
{
@Inject
private DefaultMirrorSelector mirrorSelector;
+
@Inject
private ArtifactRepositoryFactory repositorySystem;
- @Override
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- super.customizeContainerConfiguration( containerConfiguration );
- containerConfiguration.setAutoWiring( true );
- containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
- }
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- ((DefaultPlexusContainer)getContainer())
- .addPlexusInjector( Collections.emptyList(),
- binder -> binder.requestInjection( this ) );
- }
-
+ @Test
public void testExternalURL()
{
assertTrue( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "http://somehost" ) ) );
@@ -83,6 +70,7 @@ public class MirrorProcessorTest
assertFalse( DefaultMirrorSelector.isExternalRepo( getRepo( "foo", "" ) ) );
}
+ @Test
public void testMirrorLookup()
{
Mirror mirrorA = newMirror( "a", "a", "http://a" );
@@ -97,6 +85,7 @@ public class MirrorProcessorTest
assertNull( mirrorSelector.getMirror( getRepo( "c", "http://c.c" ), mirrors ) );
}
+ @Test
public void testMirrorWildcardLookup()
{
Mirror mirrorA = newMirror( "a", "a", "http://a" );
@@ -112,6 +101,7 @@ public class MirrorProcessorTest
assertSame( mirrorC, mirrorSelector.getMirror( getRepo( "c", "http://c.c" ), mirrors ) );
}
+ @Test
public void testMirrorStopOnFirstMatch()
{
// exact matches win first
@@ -140,6 +130,7 @@ public class MirrorProcessorTest
assertSame( mirrorC2, mirrorSelector.getMirror( getRepo( "f", "http://f" ), mirrors ) );
}
+ @Test
public void testPatterns()
{
assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a" ), "*" ) );
@@ -176,6 +167,7 @@ public class MirrorProcessorTest
assertFalse( DefaultMirrorSelector.matchPattern( getRepo( "d" ), "!a,!c*" ) );
}
+ @Test
public void testPatternsWithExternal()
{
assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "a", "http://localhost" ), "*" ) );
@@ -190,6 +182,7 @@ public class MirrorProcessorTest
assertTrue( DefaultMirrorSelector.matchPattern( getRepo( "c", "http://somehost" ), "!a,external:*" ) );
}
+ @Test
public void testLayoutPattern()
{
assertTrue( DefaultMirrorSelector.matchesLayout( "default", null ) );
@@ -209,6 +202,7 @@ public class MirrorProcessorTest
assertFalse( DefaultMirrorSelector.matchesLayout( "default", "!default,*" ) );
}
+ @Test
public void testMirrorLayoutConsideredForMatching()
{
ArtifactRepository repo = getRepo( "a" );
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManagerTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManagerTest.java
index 1c5f34c3c7..e826505124 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManagerTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultUpdateCheckManagerTest.java
@@ -21,20 +21,32 @@ package org.apache.maven.repository.legacy;
import java.io.File;
+import javax.inject.Inject;
+
import org.apache.maven.artifact.AbstractArtifactComponentTestCase;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
-import org.apache.maven.repository.legacy.DefaultUpdateCheckManager;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class DefaultUpdateCheckManagerTest
extends AbstractArtifactComponentTestCase
{
+ @Inject
+ private ArtifactFactory artifactFactory;
+
DefaultUpdateCheckManager updateCheckManager;
@Override
@@ -43,8 +55,9 @@ public class DefaultUpdateCheckManagerTest
return "updateCheckManager";
}
+ @BeforeEach
@Override
- protected void setUp()
+ public void setUp()
throws Exception
{
super.setUp();
@@ -52,6 +65,7 @@ public class DefaultUpdateCheckManagerTest
updateCheckManager = new DefaultUpdateCheckManager( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) );
}
+ @Test
public void testArtifact() throws Exception
{
ArtifactRepository remoteRepository = remoteRepository();
@@ -81,6 +95,7 @@ public class DefaultUpdateCheckManagerTest
assertFalse( updateCheckManager.getTouchfile( a ).exists() );
}
+ @Test
public void testMissingArtifact()
throws Exception
{
@@ -108,6 +123,7 @@ public class DefaultUpdateCheckManagerTest
updateCheckManager.getRepositoryKey( remoteRepository ) ) );
}
+ @Test
public void testPom() throws Exception
{
ArtifactRepository remoteRepository = remoteRepository();
@@ -137,6 +153,7 @@ public class DefaultUpdateCheckManagerTest
assertFalse( updateCheckManager.getTouchfile( a ).exists() );
}
+ @Test
public void testMissingPom()
throws Exception
{
@@ -164,6 +181,7 @@ public class DefaultUpdateCheckManagerTest
updateCheckManager.getRepositoryKey( remoteRepository ) ) );
}
+ @Test
public void testMetadata() throws Exception
{
ArtifactRepository remoteRepository = remoteRepository();
@@ -191,6 +209,7 @@ public class DefaultUpdateCheckManagerTest
assertNotNull( updateCheckManager.readLastUpdated( touchFile, updateCheckManager.getMetadataKey( remoteRepository, file ) ) );
}
+ @Test
public void testMissingMetadata() throws Exception
{
ArtifactRepository remoteRepository = remoteRepository();
@@ -216,10 +235,9 @@ public class DefaultUpdateCheckManagerTest
assertNotNull( updateCheckManager.readLastUpdated( touchFile, updateCheckManager.getMetadataKey( remoteRepository, file ) ) );
}
+ @Test
public void testArtifactTouchFileName() throws Exception
{
- ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
-
ArtifactRepository localRepository = localRepository();
Artifact a = artifactFactory.createArtifactWithClassifier( "groupdId", "a", "0.0.1-SNAPSHOT", "jar", null );
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java
index 9ddbe32ab9..e6177c722a 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java
@@ -22,7 +22,6 @@ package org.apache.maven.repository.legacy;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.apache.maven.artifact.Artifact;
@@ -30,25 +29,32 @@ import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.UnsupportedProtocolException;
import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.events.TransferEvent;
import org.apache.maven.wagon.events.TransferListener;
import org.apache.maven.wagon.observers.AbstractTransferListener;
import org.apache.maven.wagon.observers.Debug;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.inject.Inject;
@@ -69,25 +75,7 @@ public class DefaultWagonManagerTest
@Inject
private ArtifactRepositoryFactory artifactRepositoryFactory;
- @Override
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- super.customizeContainerConfiguration( containerConfiguration );
- containerConfiguration.setAutoWiring( true );
- containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
- }
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- ((DefaultPlexusContainer)getContainer())
- .addPlexusInjector( Collections.emptyList(),
- binder -> binder.requestInjection( this ) );
- }
-
+ @Test
public void testUnnecessaryRepositoryLookup()
throws Exception
{
@@ -123,46 +111,33 @@ public class DefaultWagonManagerTest
assertEquals( 1, listener.events.size() );
}
+ @Test
public void testGetMissingJar() throws TransferFailedException, UnsupportedProtocolException, IOException
{
Artifact artifact = createTestArtifact( "target/test-data/get-missing-jar", "jar" );
ArtifactRepository repo = createStringRepo();
- try
- {
- wagonManager.getArtifact( artifact, repo, null, false );
-
- fail();
- }
- catch ( ResourceDoesNotExistException e )
- {
- assertTrue( true );
- }
+ assertThrows( ResourceDoesNotExistException.class,
+ () -> wagonManager.getArtifact( artifact, repo, null, false ) );
assertFalse( artifact.getFile().exists() );
}
+ @Test
public void testGetMissingJarForced() throws TransferFailedException, UnsupportedProtocolException, IOException
{
Artifact artifact = createTestArtifact( "target/test-data/get-missing-jar", "jar" );
ArtifactRepository repo = createStringRepo();
- try
- {
- wagonManager.getArtifact( artifact, repo, null, true );
-
- fail();
- }
- catch ( ResourceDoesNotExistException e )
- {
- assertTrue( true );
- }
+ assertThrows( ResourceDoesNotExistException.class,
+ () -> wagonManager.getArtifact( artifact, repo, null, true ) );
assertFalse( artifact.getFile().exists() );
}
+ @Test
public void testGetRemoteJar()
throws TransferFailedException, ResourceDoesNotExistException, UnsupportedProtocolException, IOException
{
@@ -240,6 +215,7 @@ public class DefaultWagonManagerTest
return getRepo( id, "http://something" );
}
+ @Test
public void testDefaultWagonManager()
throws Exception
{
@@ -251,22 +227,13 @@ public class DefaultWagonManagerTest
assertWagon( "string" );
- try
- {
- assertWagon( "d" );
-
- fail( "Expected :" + UnsupportedProtocolException.class.getName() );
- }
- catch ( UnsupportedProtocolException e )
- {
- // ok
- assertTrue( true );
- }
+ assertThrows( UnsupportedProtocolException.class, () -> assertWagon( "d" ) );
}
/**
* Check that transfer listeners are properly removed after getArtifact and putArtifact
*/
+ @Test
public void testWagonTransferListenerRemovedAfterGetArtifactAndPutArtifact()
throws Exception
{
@@ -277,25 +244,29 @@ public class DefaultWagonManagerTest
wagon.addExpectedContent( repo.getLayout().pathOf( artifact ) + ".md5", "cd26d9e10ce691cc69aa2b90dcebbdac" );
/* getArtifact */
- assertFalse( "Transfer listener is registered before test",
- wagon.getTransferEventSupport().hasTransferListener( transferListener ) );
+ assertFalse( wagon.getTransferEventSupport().hasTransferListener( transferListener ),
+ "Transfer listener is registered before test" );
wagonManager.getArtifact( artifact, repo, transferListener, false );
- assertFalse( "Transfer listener still registered after getArtifact",
- wagon.getTransferEventSupport().hasTransferListener( transferListener ) );
+ assertFalse( wagon.getTransferEventSupport().hasTransferListener( transferListener ),
+ "Transfer listener still registered after getArtifact" );
/* putArtifact */
File sampleFile = getTestFile( "target/test-file" );
FileUtils.fileWrite( sampleFile.getAbsolutePath(), "sample file" );
- assertFalse( "Transfer listener is registered before test", wagon.getTransferEventSupport().hasTransferListener( transferListener ) );
+ assertFalse( wagon.getTransferEventSupport().hasTransferListener( transferListener ),
+ "Transfer listener is registered before test" );
wagonManager.putArtifact( sampleFile, artifact, repo, transferListener );
- assertFalse( "Transfer listener still registered after putArtifact", wagon.getTransferEventSupport().hasTransferListener( transferListener ) );
+ assertFalse( wagon.getTransferEventSupport().hasTransferListener( transferListener ),
+ "Transfer listener still registered after putArtifact" );
}
/**
* Checks the verification of checksums.
*/
- public void xtestChecksumVerification()
+ @Disabled
+ @Test
+ public void testChecksumVerification()
throws Exception
{
ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
@@ -312,84 +283,41 @@ public class DefaultWagonManagerTest
wagon.clearExpectedContent();
wagon.addExpectedContent( "path", "lower-case-checksum" );
wagon.addExpectedContent( "path.sha1", "2a25dc564a3b34f68237fc849066cbc7bb7a36a1" );
-
- try
- {
- wagonManager.getArtifact( artifact, repo, null, false );
- }
- catch ( ChecksumFailedException e )
- {
- fail( "Checksum verification did not pass: " + e.getMessage() );
- }
+ wagonManager.getArtifact( artifact, repo, null, false );
wagon.clearExpectedContent();
wagon.addExpectedContent( "path", "upper-case-checksum" );
wagon.addExpectedContent( "path.sha1", "B7BB97D7D0B9244398D9B47296907F73313663E6" );
-
- try
- {
- wagonManager.getArtifact( artifact, repo, null, false );
- }
- catch ( ChecksumFailedException e )
- {
- fail( "Checksum verification did not pass: " + e.getMessage() );
- }
+ wagonManager.getArtifact( artifact, repo, null, false );
wagon.clearExpectedContent();
wagon.addExpectedContent( "path", "expected-failure" );
wagon.addExpectedContent( "path.sha1", "b7bb97d7d0b9244398d9b47296907f73313663e6" );
-
- try
- {
- wagonManager.getArtifact( artifact, repo, null, false );
- fail( "Checksum verification did not fail" );
- }
- catch ( ChecksumFailedException e )
- {
- // expected
- }
+ assertThrows(
+ ChecksumFailedException.class, () ->
+ wagonManager.getArtifact( artifact, repo, null, false ),
+ "Checksum verification did not fail" );
wagon.clearExpectedContent();
wagon.addExpectedContent( "path", "lower-case-checksum" );
wagon.addExpectedContent( "path.md5", "50b2cf50a103a965efac62b983035cac" );
-
- try
- {
- wagonManager.getArtifact( artifact, repo, null, false );
- }
- catch ( ChecksumFailedException e )
- {
- fail( "Checksum verification did not pass: " + e.getMessage() );
- }
+ wagonManager.getArtifact( artifact, repo, null, false );
wagon.clearExpectedContent();
wagon.addExpectedContent( "path", "upper-case-checksum" );
wagon.addExpectedContent( "path.md5", "842F568FCCFEB7E534DC72133D42FFDC" );
-
- try
- {
- wagonManager.getArtifact( artifact, repo, null, false );
- }
- catch ( ChecksumFailedException e )
- {
- fail( "Checksum verification did not pass: " + e.getMessage() );
- }
+ wagonManager.getArtifact( artifact, repo, null, false );
wagon.clearExpectedContent();
wagon.addExpectedContent( "path", "expected-failure" );
wagon.addExpectedContent( "path.md5", "b7bb97d7d0b9244398d9b47296907f73313663e6" );
-
- try
- {
- wagonManager.getArtifact( artifact, repo, null, false );
- fail( "Checksum verification did not fail" );
- }
- catch ( ChecksumFailedException e )
- {
- // expected
- }
+ assertThrows(
+ ChecksumFailedException.class,
+ () -> wagonManager.getArtifact( artifact, repo, null, false ),
+ "Checksum verification did not fail" );
}
+ @Test
public void testPerLookupInstantiation()
throws Exception
{
@@ -406,7 +334,7 @@ public class DefaultWagonManagerTest
{
Wagon wagon = wagonManager.getWagon( protocol );
- assertNotNull( "Check wagon, protocol=" + protocol, wagon );
+ assertNotNull( wagon, "Check wagon, protocol=" + protocol );
}
private final class ArtifactRepositoryLayoutStub
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java
index d5f281fba5..61f16cceb1 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java
@@ -17,16 +17,18 @@ package org.apache.maven.repository.legacy;
import java.io.File;
import java.util.Arrays;
-import java.util.Collections;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.Authentication;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.settings.Server;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import javax.inject.Inject;
@@ -41,25 +43,7 @@ public class LegacyRepositorySystemTest
@Inject
private RepositorySystem repositorySystem;
- @Override
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- super.customizeContainerConfiguration( containerConfiguration );
- containerConfiguration.setAutoWiring( true );
- containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
- }
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- ((DefaultPlexusContainer)getContainer())
- .addPlexusInjector( Collections.emptyList(),
- binder -> binder.requestInjection( this ) );
- }
-
+ @Test
public void testThatLocalRepositoryWithSpacesIsProperlyHandled()
throws Exception
{
@@ -68,6 +52,7 @@ public class LegacyRepositorySystemTest
assertEquals( basedir, new File( repo.getBasedir() ) );
}
+ @Test
public void testAuthenticationHandling()
{
Server server = new Server();
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java
index 5d88702136..0ef67d9be4 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/DefaultArtifactCollectorTest.java
@@ -19,6 +19,18 @@ package org.apache.maven.repository.legacy.resolver;
* under the License.
*/
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
@@ -37,19 +49,16 @@ import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test the default artifact collector.
@@ -59,8 +68,10 @@ import java.util.Set;
public class DefaultArtifactCollectorTest
extends PlexusTestCase
{
+ @Inject
private LegacyArtifactCollector artifactCollector;
+ @Inject
private ArtifactFactory artifactFactory;
private ArtifactSpec projectArtifact;
@@ -69,72 +80,47 @@ public class DefaultArtifactCollectorTest
private static final String GROUP_ID = "test";
+ @BeforeEach
@Override
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- super.customizeContainerConfiguration( containerConfiguration );
- containerConfiguration.setAutoWiring( true );
- containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
- }
-
- @Override
- protected void setUp()
+ public void setUp()
throws Exception
{
super.setUp();
source = new Source();
- artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
- artifactCollector = lookup( LegacyArtifactCollector.class );
projectArtifact = createArtifactSpec( "project", "1.0", null );
}
- @Override
- protected void tearDown()
- throws Exception
- {
- artifactCollector = null;
- artifactFactory = null;
- super.tearDown();
- }
-
- // works, but we don't fail on cycles presently
- public void disabledtestCircularDependencyNotIncludingCurrentProject()
+ @Test
+ @Disabled("works, but we don't fail on cycles presently")
+ public void testCircularDependencyNotIncludingCurrentProject()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
ArtifactSpec a = createArtifactSpec( "a", "1.0" );
ArtifactSpec b = a.addDependency( "b", "1.0" );
b.addDependency( "a", "1.0" );
- try
- {
- collect( a );
- fail( "Should have failed on cyclic dependency not involving project" );
- }
- catch ( CyclicDependencyException expected )
- {
- assertTrue( true );
- }
+ assertThrows(
+ CyclicDependencyException.class,
+ () -> collect( a ),
+ "Should have failed on cyclic dependency not involving project" );
}
- // works, but we don't fail on cycles presently
- public void disabledtestCircularDependencyIncludingCurrentProject()
+ @Test
+ @Disabled("works, but we don't fail on cycles presently")
+ public void testCircularDependencyIncludingCurrentProject()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
ArtifactSpec a = createArtifactSpec( "a", "1.0" );
ArtifactSpec b = a.addDependency( "b", "1.0" );
b.addDependency( "project", "1.0" );
- try
- {
- collect( a );
- fail( "Should have failed on cyclic dependency involving project" );
- }
- catch ( CyclicDependencyException expected )
- {
- assertTrue( true );
- }
+ assertThrows(
+ CyclicDependencyException.class,
+ () -> collect( a ),
+ "Should have failed on cyclic dependency not involving project" );
}
+ @Test
public void testResolveWithFilter()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -146,14 +132,15 @@ public class DefaultArtifactCollectorTest
ArtifactSpec d = b.addDependency( "d", "4.0" );
ArtifactResolutionResult res = collect( a );
- assertEquals( "Check artifact list",
- createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact } ), res.getArtifacts() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact } ), res.getArtifacts(),
+ "Check artifact list" );
ArtifactFilter filter = new ExclusionSetFilter( new String[] { "b" } );
res = collect( a, filter );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts() );
+ assertEquals( createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts(), "Check artifact list" );
}
+ @Test
public void testResolveCorrectDependenciesWhenDifferentDependenciesOnNearest()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -167,12 +154,14 @@ public class DefaultArtifactCollectorTest
ArtifactSpec f = c1.addDependency( "f", "1.0" );
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, e.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, e.artifact, c1.artifact,
- f.artifact } ), res.getArtifacts() );
- assertEquals( "Check version", "1.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact, e.artifact, c1.artifact, f.artifact } ),
+ res.getArtifacts(), "Check artifact list" );
+ assertEquals( "1.0", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" );
}
- public void disabledtestResolveCorrectDependenciesWhenDifferentDependenciesOnNewest()
+ @Test
+ @Disabled
+ public void testResolveCorrectDependenciesWhenDifferentDependenciesOnNewest()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
// TODO use newest conflict resolver
@@ -186,12 +175,13 @@ public class DefaultArtifactCollectorTest
c1.addDependency( "f", "1.0" );
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, e.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, e.artifact, c2.artifact,
- d.artifact } ), res.getArtifacts() );
- assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact, e.artifact, c2.artifact, d.artifact } ), res.getArtifacts(), "Check artifact list" );
+ assertEquals( "2.0", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" );
}
- public void disabledtestResolveCorrectDependenciesWhenDifferentDependenciesOnNewestVersionReplaced()
+ @Test
+ @Disabled
+ public void testResolveCorrectDependenciesWhenDifferentDependenciesOnNewestVersionReplaced()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
// TODO use newest conflict resolver
@@ -207,11 +197,12 @@ public class DefaultArtifactCollectorTest
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact } ) );
Object[] artifacts = new Object[] { a.artifact, c.artifact, d1.artifact, b2.artifact, e.artifact, g.artifact };
- assertEquals( "Check artifact list", createSet( artifacts ), res.getArtifacts() );
- assertEquals( "Check version", "1.0", getArtifact( "d", res.getArtifacts() ).getVersion() );
- assertEquals( "Check version", "2.0", getArtifact( "b", res.getArtifacts() ).getVersion() );
+ assertEquals( createSet( artifacts ), res.getArtifacts(), "Check artifact list" );
+ assertEquals( "1.0", getArtifact( "d", res.getArtifacts() ).getVersion(), "Check version" );
+ assertEquals( "2.0", getArtifact( "b", res.getArtifacts() ).getVersion(), "Check version" );
}
+ @Test
public void testResolveNearestNewestIsNearest()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -222,11 +213,11 @@ public class DefaultArtifactCollectorTest
b.addDependency( "c", "2.0" );
ArtifactResolutionResult res = collect( a );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ),
- res.getArtifacts() );
- assertEquals( "Check version", "3.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact, c.artifact } ), res.getArtifacts(), "Check artifact list" );
+ assertEquals( "3.0", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" );
}
+ @Test
public void testResolveNearestOldestIsNearest()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -237,11 +228,11 @@ public class DefaultArtifactCollectorTest
b.addDependency( "c", "3.0" );
ArtifactResolutionResult res = collect( a );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ),
- res.getArtifacts() );
- assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact, c.artifact } ), res.getArtifacts(), "Check artifact list" );
+ assertEquals( "2.0", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" );
}
+ @Test
public void testResolveLocalNewestIsLocal()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -250,10 +241,11 @@ public class DefaultArtifactCollectorTest
ArtifactSpec b = createArtifactSpec( "b", "3.0" );
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
- assertEquals( "Check version", "3.0", getArtifact( "b", res.getArtifacts() ).getVersion() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" );
+ assertEquals( "3.0", getArtifact( "b", res.getArtifacts() ).getVersion(), "Check version" );
}
+ @Test
public void testResolveLocalOldestIsLocal()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -262,10 +254,11 @@ public class DefaultArtifactCollectorTest
ArtifactSpec b = createArtifactSpec( "b", "2.0" );
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
- assertEquals( "Check version", "2.0", getArtifact( "b", res.getArtifacts() ).getVersion() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" );
+ assertEquals( "2.0", getArtifact( "b", res.getArtifacts() ).getVersion(), "Check version" );
}
+ @Test
public void testResolveLocalWithNewerVersionButLesserScope()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -274,11 +267,12 @@ public class DefaultArtifactCollectorTest
ArtifactSpec b = createArtifactSpec( "junit", "3.8.1", Artifact.SCOPE_TEST );
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
- assertEquals( "Check version", "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion() );
- assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" );
+ assertEquals( "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion(), "Check version" );
+ assertEquals( Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope(), "Check artifactScope" );
}
+ @Test
public void testResolveLocalWithNewerVersionButLesserScopeResolvedFirst()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -287,11 +281,12 @@ public class DefaultArtifactCollectorTest
a.addDependency( "junit", "3.7" );
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
- assertEquals( "Check version", "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion() );
- assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" );
+ assertEquals( "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion(), "Check version" );
+ assertEquals( Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope(), "Check artifactScope" );
}
+ @Test
public void testResolveNearestWithRanges()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -302,11 +297,11 @@ public class DefaultArtifactCollectorTest
b.addDependency( "c", "[1.0,3.0]" );
ArtifactResolutionResult res = collect( a );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ),
- res.getArtifacts() );
- assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact, c.artifact } ), res.getArtifacts(), "Check artifact list" );
+ assertEquals( "2.0", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" );
}
+ @Test
public void testResolveRangeWithManagedVersion()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -316,11 +311,11 @@ public class DefaultArtifactCollectorTest
ArtifactSpec managedB = createArtifactSpec( "b", "5.0" );
ArtifactResolutionResult res = collect( a, managedB.artifact );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, managedB.artifact } ),
- res.getArtifacts() );
- assertEquals( "Check version", "5.0", getArtifact( "b", res.getArtifacts() ).getVersion() );
+ assertEquals( createSet( new Object[] { a.artifact, managedB.artifact } ), res.getArtifacts(), "Check artifact list" );
+ assertEquals( "5.0", getArtifact( "b", res.getArtifacts() ).getVersion(), "Check version" );
}
+ @Test
public void testCompatibleRanges()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -332,11 +327,11 @@ public class DefaultArtifactCollectorTest
ArtifactResolutionResult res = collect( a );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact } ),
- res.getArtifacts() );
- assertEquals( "Check version", "2.5", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact, c.artifact } ), res.getArtifacts(), "Check artifact list" );
+ assertEquals( "2.5", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" );
}
+ @Test
public void testIncompatibleRanges()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -351,6 +346,7 @@ public class DefaultArtifactCollectorTest
assertTrue( res.hasVersionRangeViolations() );
}
+ @Test
public void testUnboundedRangeWhenVersionUnavailable()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -364,6 +360,7 @@ public class DefaultArtifactCollectorTest
assertTrue( res.hasVersionRangeViolations() );
}
+ @Test
public void testUnboundedRangeBelowLastRelease()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -375,10 +372,11 @@ public class DefaultArtifactCollectorTest
ArtifactResolutionResult res = collect( a );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts() );
- assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
+ assertEquals( createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts(), "Check artifact list" );
+ assertEquals( "2.0", getArtifact( "c", res.getArtifacts() ).getVersion(), "Check version" );
}
+ @Test
public void testUnboundedRangeAboveLastRelease()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -391,6 +389,7 @@ public class DefaultArtifactCollectorTest
assertTrue( res.hasVersionRangeViolations() );
}
+ @Test
public void testResolveManagedVersion()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -401,9 +400,10 @@ public class DefaultArtifactCollectorTest
Artifact modifiedB = createArtifactSpec( "b", "5.0", Artifact.SCOPE_RUNTIME ).artifact;
ArtifactResolutionResult res = collect( a, managedVersion );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedB } ), res.getArtifacts() );
+ assertEquals( createSet( new Object[] { a.artifact, modifiedB } ), res.getArtifacts(), "Check artifact list" );
}
+ @Test
public void testCollectChangesVersionOfOriginatingArtifactIfInDependencyManagementHasDifferentVersion()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -414,13 +414,14 @@ public class DefaultArtifactCollectorTest
ArtifactResolutionResult result = collect( a, managedVersion );
- assertEquals( "collect has modified version in originating artifact", "1.0", artifact.getVersion() );
+ assertEquals( "1.0", artifact.getVersion(), "collect has modified version in originating artifact" );
Artifact resolvedArtifact = result.getArtifacts().iterator().next();
- assertEquals( "Resolved version don't match original artifact version", "1.0", resolvedArtifact.getVersion() );
+ assertEquals( "1.0", resolvedArtifact.getVersion(), "Resolved version don't match original artifact version" );
}
+ @Test
public void testResolveCompileScopeOverTestScope()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -432,13 +433,14 @@ public class DefaultArtifactCollectorTest
Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact;
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() );
+ assertEquals( createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts(), "Check artifact list" );
Artifact artifact = getArtifact( "c", res.getArtifacts() );
// local wins now, and irrelevant if not local as test/provided aren't transitive
- // assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getArtifactScope() );
- assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, artifact.getScope() );
+ // assertEquals( Artifact.SCOPE_COMPILE, artifact.getArtifactScope(), "Check artifactScope" );
+ assertEquals( Artifact.SCOPE_TEST, artifact.getScope(), "Check artifactScope" );
}
+ @Test
public void testResolveRuntimeScopeOverTestScope()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -450,13 +452,14 @@ public class DefaultArtifactCollectorTest
Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_RUNTIME ).artifact;
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() );
+ assertEquals( createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts(), "Check artifact list" );
Artifact artifact = getArtifact( "c", res.getArtifacts() );
// local wins now, and irrelevant if not local as test/provided aren't transitive
- // assertEquals( "Check artifactScope", Artifact.SCOPE_RUNTIME, artifact.getArtifactScope() );
- assertEquals( "Check artifactScope", Artifact.SCOPE_TEST, artifact.getScope() );
+ // assertEquals( Artifact.SCOPE_RUNTIME, artifact.getArtifactScope(), "Check artifactScope" );
+ assertEquals( Artifact.SCOPE_TEST, artifact.getScope(), "Check artifactScope" );
}
+ @Test
public void testResolveCompileScopeOverRuntimeScope()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -469,12 +472,12 @@ public class DefaultArtifactCollectorTest
Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact;
ArtifactResolutionResult res = collect( createSet( new Object[] { root.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, root.artifact, modifiedC } ),
- res.getArtifacts() );
+ assertEquals( createSet( new Object[] { a.artifact, root.artifact, modifiedC } ), res.getArtifacts(), "Check artifact list" );
Artifact artifact = getArtifact( "c", res.getArtifacts() );
- assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getScope() );
+ assertEquals( Artifact.SCOPE_COMPILE, artifact.getScope(), "Check artifactScope" );
}
+ @Test
public void testResolveCompileScopeOverProvidedScope()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -486,13 +489,14 @@ public class DefaultArtifactCollectorTest
Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact;
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() );
+ assertEquals( createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts(), "Check artifact list" );
Artifact artifact = getArtifact( "c", res.getArtifacts() );
// local wins now, and irrelevant if not local as test/provided aren't transitive
- // assertEquals( "Check artifactScope", Artifact.SCOPE_COMPILE, artifact.getArtifactScope() );
- assertEquals( "Check artifactScope", Artifact.SCOPE_PROVIDED, artifact.getScope() );
+ // assertEquals( Artifact.SCOPE_COMPILE, artifact.getArtifactScope(), "Check artifactScope" );
+ assertEquals( Artifact.SCOPE_PROVIDED, artifact.getScope(), "Check artifactScope" );
}
+ @Test
public void testResolveRuntimeScopeOverProvidedScope()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -504,13 +508,14 @@ public class DefaultArtifactCollectorTest
Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_RUNTIME ).artifact;
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, c.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts() );
+ assertEquals( createSet( new Object[] { a.artifact, modifiedC } ), res.getArtifacts(), "Check artifact list" );
Artifact artifact = getArtifact( "c", res.getArtifacts() );
// local wins now, and irrelevant if not local as test/provided aren't transitive
- // assertEquals( "Check artifactScope", Artifact.SCOPE_RUNTIME, artifact.getArtifactScope() );
- assertEquals( "Check artifactScope", Artifact.SCOPE_PROVIDED, artifact.getScope() );
+ // assertEquals( Artifact.SCOPE_RUNTIME, artifact.getArtifactScope(), "Check artifactScope" );
+ assertEquals( Artifact.SCOPE_PROVIDED, artifact.getScope(), "Check artifactScope" );
}
+ @Test
public void testProvidedScopeNotTransitive()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -519,9 +524,10 @@ public class DefaultArtifactCollectorTest
b.addDependency( "c", "3.0", Artifact.SCOPE_PROVIDED );
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" );
}
+ @Test
public void testOptionalNotTransitive()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -530,9 +536,10 @@ public class DefaultArtifactCollectorTest
b.addDependency( "c", "3.0", true );
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" );
}
+ @Test
public void testOptionalIncludedAtRoot()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -541,9 +548,10 @@ public class DefaultArtifactCollectorTest
ArtifactSpec b = createArtifactSpec( "b", "1.0", true );
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" );
}
+ @Test
public void testScopeUpdate()
throws InvalidVersionSpecificationException, ArtifactResolutionException
{
@@ -643,19 +651,21 @@ public class DefaultArtifactCollectorTest
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ), filter );
Artifact artifact = getArtifact( "d", res.getArtifacts() );
- assertNotNull( "MNG-1895 Dependency was not added to resolution", artifact );
- assertEquals( "Check artifactScope", expectedScope, artifact.getScope() );
- assertEquals( "Check version", expectedVersion, artifact.getVersion() );
+ assertNotNull( artifact, "MNG-1895 Dependency was not added to resolution" );
+ assertEquals( expectedScope, artifact.getScope(), "Check artifactScope" );
+ assertEquals( expectedVersion, artifact.getVersion(), "Check version" );
ArtifactSpec d = createArtifactSpec( "d", "1.0" );
res = collect( createSet( new Object[] { a.artifact, b.artifact, d.artifact } ), filter );
artifact = getArtifact( "d", res.getArtifacts() );
- assertNotNull( "MNG-1895 Dependency was not added to resolution", artifact );
- assertEquals( "Check artifactScope", d.artifact.getScope(), artifact.getScope() );
- assertEquals( "Check version", "1.0", artifact.getVersion() );
+ assertNotNull( artifact, "MNG-1895 Dependency was not added to resolution" );
+ assertEquals( d.artifact.getScope(), artifact.getScope(), "Check artifactScope" );
+ assertEquals( "1.0", artifact.getVersion(), "Check version" );
}
- public void disabledtestOptionalNotTransitiveButVersionIsInfluential()
+ @Test
+ @Disabled
+ public void testOptionalNotTransitiveButVersionIsInfluential()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
ArtifactSpec a = createArtifactSpec( "a", "1.0" );
@@ -668,12 +678,12 @@ public class DefaultArtifactCollectorTest
ArtifactSpec c = createArtifactSpec( "c", "3.0" );
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact,
- e.artifact } ), res.getArtifacts() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact, e.artifact } ), res.getArtifacts(), "Check artifact list" );
Artifact artifact = getArtifact( "c", res.getArtifacts() );
- assertEquals( "Check version", "3.0", artifact.getVersion() );
+ assertEquals( "3.0", artifact.getVersion(), "Check version" );
}
+ @Test
public void testTestScopeNotTransitive()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -682,9 +692,10 @@ public class DefaultArtifactCollectorTest
b.addDependency( "c", "3.0", Artifact.SCOPE_TEST );
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, b.artifact } ) );
- assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts() );
+ assertEquals( createSet( new Object[] { a.artifact, b.artifact } ), res.getArtifacts(), "Check artifact list" );
}
+ @Test
public void testSnapshotNotIncluded()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -703,6 +714,8 @@ public class DefaultArtifactCollectorTest
*/
}
+ @Test
+ @Disabled("that one does not work")
public void testOverConstrainedVersionException()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
@@ -715,15 +728,11 @@ public class DefaultArtifactCollectorTest
ArtifactSpec c = createArtifactSpec( "c", "3.2.1-v3235e" );
- try
- {
- ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact } ) );
- }
- catch ( OverConstrainedVersionException e )
- {
- assertTrue( "Versions unordered", e.getMessage().contains( "[3.2.1-v3235e, 3.3.0-v3346]" ) );
- assertTrue( "DependencyTrail unresolved", e.getMessage().contains( "Path to dependency:" ) );
- }
+ OverConstrainedVersionException e = assertThrows(
+ OverConstrainedVersionException.class,
+ () -> collect( createSet( new Object[] { a.artifact } ) ) );
+ assertTrue( e.getMessage().contains( "[3.2.1-v3235e, 3.3.0-v3346]" ), "Versions unordered" );
+ assertTrue( e.getMessage().contains( "Path to dependency:" ), "DependencyTrail unresolved" );
}
private Artifact getArtifact( String id, Set artifacts )
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java
index 54ae26a1f6..fbb2531a7b 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java
@@ -19,20 +19,22 @@ package org.apache.maven.repository.legacy.resolver.conflict;
* under the License.
*/
+import java.util.Collections;
+
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ResolutionNode;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver;
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import javax.inject.Inject;
-import java.util.Collections;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Provides a basis for testing conflict resolvers.
@@ -71,25 +73,17 @@ public abstract class AbstractConflictResolverTest
// TestCase methods -------------------------------------------------------
+ /*
+ * @see junit.framework.TestCase#setUp()
+ */
+ @BeforeEach
@Override
- protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
- {
- super.customizeContainerConfiguration( containerConfiguration );
- containerConfiguration.setAutoWiring( true );
- containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
- }
-
- @Override
- protected void setUp()
+ public void setUp()
throws Exception
{
super.setUp();
- ((DefaultPlexusContainer)getContainer())
- .addPlexusInjector( Collections.emptyList(),
- binder -> binder.requestInjection( this ) );
-
- conflictResolver = (ConflictResolver) lookup( ConflictResolver.ROLE, roleHint );
+ conflictResolver = lookup( ConflictResolver.ROLE, roleHint );
a1 = createArtifact( "a", "1.0" );
a2 = createArtifact( "a", "2.0" );
@@ -99,7 +93,9 @@ public abstract class AbstractConflictResolverTest
/*
* @see org.codehaus.plexus.PlexusTestCase#tearDown()
*/
- protected void tearDown() throws Exception
+ @AfterEach
+ @Override
+ public void tearDown() throws Exception
{
a1 = null;
a2 = null;
@@ -121,8 +117,8 @@ public abstract class AbstractConflictResolverTest
{
ResolutionNode resolvedNode = getConflictResolver().resolveConflict( actualNode1, actualNode2 );
- assertNotNull( "Expected resolvable", resolvedNode );
- assertEquals( "Resolution node", expectedNode, resolvedNode );
+ assertNotNull( resolvedNode, "Expected resolvable" );
+ assertEquals( expectedNode, resolvedNode, "Resolution node" );
}
protected Artifact createArtifact( String id, String version ) throws InvalidVersionSpecificationException
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java
index 363c7a2481..7b46ee342d 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/FarthestConflictResolverTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.repository.legacy.resolver.conflict;
*/
import org.apache.maven.artifact.resolver.ResolutionNode;
+import org.junit.jupiter.api.Test;
/**
* Tests FarthestConflictResolver
.
@@ -47,6 +48,7 @@ public class FarthestConflictResolverTest
* b:1.0 -> a:2.0
*
*/
+ @Test
public void testDepth()
{
ResolutionNode a1n = createResolutionNode( a1);
@@ -63,6 +65,7 @@ public class FarthestConflictResolverTest
* a:1.0
*
*/
+ @Test
public void testDepthReversed()
{
ResolutionNode b1n = createResolutionNode( b1 );
@@ -79,6 +82,7 @@ public class FarthestConflictResolverTest
* a:2.0
*
*/
+ @Test
public void testEqual()
{
ResolutionNode a1n = createResolutionNode( a1 );
@@ -94,6 +98,7 @@ public class FarthestConflictResolverTest
* a:1.0
*
*/
+ @Test
public void testEqualReversed()
{
ResolutionNode a2n = createResolutionNode( a2);
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java
index 23683d56df..34026bc289 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NearestConflictResolverTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.repository.legacy.resolver.conflict;
*/
import org.apache.maven.artifact.resolver.ResolutionNode;
+import org.junit.jupiter.api.Test;
/**
* Tests NearestConflictResolver
.
@@ -47,6 +48,7 @@ public class NearestConflictResolverTest
* b:1.0 -> a:2.0
*
*/
+ @Test
public void testDepth()
{
ResolutionNode a1n = createResolutionNode( a1);
@@ -63,6 +65,7 @@ public class NearestConflictResolverTest
* a:1.0
*
*/
+ @Test
public void testDepthReversed()
{
ResolutionNode b1n = createResolutionNode( b1 );
@@ -79,6 +82,7 @@ public class NearestConflictResolverTest
* a:2.0
*
*/
+ @Test
public void testEqual()
{
ResolutionNode a1n = createResolutionNode( a1 );
@@ -94,6 +98,7 @@ public class NearestConflictResolverTest
* a:1.0
*
*/
+ @Test
public void testEqualReversed()
{
ResolutionNode a2n = createResolutionNode( a2);
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java
index 4cfffc67e1..874644a9c0 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/NewestConflictResolverTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.repository.legacy.resolver.conflict;
*/
import org.apache.maven.artifact.resolver.ResolutionNode;
+import org.junit.jupiter.api.Test;
/**
* Tests NewestConflictResolver
.
@@ -47,6 +48,7 @@ public class NewestConflictResolverTest
* b:1.0 -> a:2.0
*
*/
+ @Test
public void testDepth()
{
ResolutionNode a1n = createResolutionNode( a1 );
@@ -63,6 +65,7 @@ public class NewestConflictResolverTest
* a:1.0
*
*/
+ @Test
public void testDepthReversed()
{
ResolutionNode b1n = createResolutionNode( b1 );
@@ -79,6 +82,7 @@ public class NewestConflictResolverTest
* a:2.0
*
*/
+ @Test
public void testEqual()
{
ResolutionNode a1n = createResolutionNode( a1 );
@@ -94,6 +98,7 @@ public class NewestConflictResolverTest
* a:1.0
*
*/
+ @Test
public void testEqualReversed()
{
ResolutionNode a2n = createResolutionNode( a2 );
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java
index 8744de2b05..76335f26af 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/OldestConflictResolverTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.repository.legacy.resolver.conflict;
*/
import org.apache.maven.artifact.resolver.ResolutionNode;
+import org.junit.jupiter.api.Test;
/**
* Tests OldestConflictResolver
.
@@ -47,6 +48,7 @@ public class OldestConflictResolverTest
* b:1.0 -> a:2.0
*
*/
+ @Test
public void testDepth()
{
ResolutionNode a1n = createResolutionNode( a1 );
@@ -64,6 +66,7 @@ public class OldestConflictResolverTest
* a:1.0
*
*/
+ @Test
public void testDepthReversed()
{
ResolutionNode b1n = createResolutionNode( b1 );
@@ -80,6 +83,7 @@ public class OldestConflictResolverTest
* a:2.0
*
*/
+ @Test
public void testEqual()
{
ResolutionNode a1n = createResolutionNode( a1 );
@@ -95,6 +99,7 @@ public class OldestConflictResolverTest
* a:1.0
*
*/
+ @Test
public void testEqualReversed()
{
ResolutionNode a2n = createResolutionNode( a2);
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java b/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java
index 339ce24c3e..ebe0fd50aa 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultClasspathTransformationTest.java
@@ -15,14 +15,15 @@ package org.apache.maven.repository.metadata;
* the License.
*/
+import javax.inject.Inject;
+
import org.apache.maven.artifact.ArtifactScopeEnum;
-import org.apache.maven.repository.metadata.ArtifactMetadata;
-import org.apache.maven.repository.metadata.ClasspathContainer;
-import org.apache.maven.repository.metadata.ClasspathTransformation;
-import org.apache.maven.repository.metadata.MetadataGraph;
-import org.apache.maven.repository.metadata.MetadataGraphEdge;
-import org.apache.maven.repository.metadata.MetadataGraphVertex;
-import org.codehaus.plexus.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.BeforeEach;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
*
@@ -33,6 +34,7 @@ import org.codehaus.plexus.PlexusTestCase;
public class DefaultClasspathTransformationTest
extends PlexusTestCase
{
+ @Inject
ClasspathTransformation transform;
MetadataGraph graph;
@@ -42,11 +44,11 @@ extends PlexusTestCase
MetadataGraphVertex v3;
MetadataGraphVertex v4;
//------------------------------------------------------------------------------------------
+ @BeforeEach
@Override
- protected void setUp() throws Exception
+ public void setUp() throws Exception
{
super.setUp();
- transform = (ClasspathTransformation) lookup( ClasspathTransformation.ROLE, "default" );
graph = new MetadataGraph( 4, 3 );
/*
@@ -74,6 +76,7 @@ extends PlexusTestCase
graph.addEdge(v3, v4, new MetadataGraphEdge( "1.2", true, ArtifactScopeEnum.test, null, 2, 2 ) );
}
//------------------------------------------------------------------------------------------
+ @Test
public void testCompileClasspathTransform()
throws Exception
{
@@ -81,11 +84,12 @@ extends PlexusTestCase
res = transform.transform( graph, ArtifactScopeEnum.compile, false );
- assertNotNull("null classpath container after compile transform", res );
- assertNotNull("null classpath after compile transform", res.getClasspath() );
- assertEquals("compile classpath should have 3 entries", 3, res.getClasspath().size() );
+ assertNotNull( res, "null classpath container after compile transform" );
+ assertNotNull( res.getClasspath(), "null classpath after compile transform" );
+ assertEquals( 3, res.getClasspath().size(), "compile classpath should have 3 entries" );
}
//------------------------------------------------------------------------------------------
+ @Test
public void testRuntimeClasspathTransform()
throws Exception
{
@@ -93,14 +97,15 @@ extends PlexusTestCase
res = transform.transform( graph, ArtifactScopeEnum.runtime, false );
- assertNotNull("null classpath container after runtime transform", res );
- assertNotNull("null classpath after runtime transform", res.getClasspath() );
- assertEquals("runtime classpath should have 4 entries", 4, res.getClasspath().size() );
+ assertNotNull( res, "null classpath container after runtime transform" );
+ assertNotNull( res.getClasspath(), "null classpath after runtime transform" );
+ assertEquals( 4, res.getClasspath().size(), "runtime classpath should have 4 entries" );
ArtifactMetadata md = res.getClasspath().get(3);
- assertEquals("runtime artifact version should be 1.1", "1.1", md.getVersion() );
+ assertEquals("1.1", md.getVersion(), "runtime artifact version should be 1.1" );
}
//------------------------------------------------------------------------------------------
+ @Test
public void testTestClasspathTransform()
throws Exception
{
@@ -108,12 +113,12 @@ extends PlexusTestCase
res = transform.transform( graph, ArtifactScopeEnum.test, false );
- assertNotNull("null classpath container after runtime transform", res );
- assertNotNull("null classpath after runtime transform", res.getClasspath() );
- assertEquals("runtime classpath should have 4 entries", 4, res.getClasspath().size() );
+ assertNotNull( res, "null classpath container after test transform" );
+ assertNotNull( res.getClasspath(), "null classpath after test transform" );
+ assertEquals( 4, res.getClasspath().size(), "test classpath should have 4 entries" );
ArtifactMetadata md = res.getClasspath().get(3);
- assertEquals("test artifact version should be 1.2", "1.2", md.getVersion() );
+ assertEquals("1.2", md.getVersion(), "test artifact version should be 1.2" );
}
//------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicyTest.java b/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicyTest.java
index 472f018b2a..ea4352e504 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicyTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolutionPolicyTest.java
@@ -15,10 +15,10 @@ package org.apache.maven.repository.metadata;
* the License.
*/
-import org.apache.maven.repository.metadata.GraphConflictResolutionPolicy;
-import org.apache.maven.repository.metadata.MetadataGraphEdge;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import junit.framework.TestCase;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
*
@@ -27,33 +27,32 @@ import junit.framework.TestCase;
*/
public class DefaultGraphConflictResolutionPolicyTest
- extends TestCase
{
GraphConflictResolutionPolicy policy;
MetadataGraphEdge e1;
MetadataGraphEdge e2;
MetadataGraphEdge e3;
//------------------------------------------------------------------------------------------
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- policy = new DefaultGraphConflictResolutionPolicy();
- e1 = new MetadataGraphEdge( "1.1", true, null, null, 2, 1 );
- e2 = new MetadataGraphEdge( "1.2", true, null, null, 3, 2 );
- e3 = new MetadataGraphEdge( "1.2", true, null, null, 2, 3 );
- }
+ @BeforeEach
+ public void setUp() throws Exception
+ {
+ policy = new DefaultGraphConflictResolutionPolicy();
+ e1 = new MetadataGraphEdge( "1.1", true, null, null, 2, 1 );
+ e2 = new MetadataGraphEdge( "1.2", true, null, null, 3, 2 );
+ e3 = new MetadataGraphEdge( "1.2", true, null, null, 2, 3 );
+ }
//------------------------------------------------------------------------------------------
+ @Test
public void testDefaultPolicy()
throws Exception
{
MetadataGraphEdge res;
res = policy.apply( e1, e2 );
- assertEquals( "Wrong depth edge selected", "1.1", res.getVersion() );
+ assertEquals( "1.1", res.getVersion(), "Wrong depth edge selected" );
res = policy.apply( e1, e3 );
- assertEquals( "Wrong version edge selected", "1.2", res.getVersion() );
+ assertEquals( "1.2", res.getVersion(), "Wrong version edge selected" );
}
//------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java
index ccd25b43bc..a41464a1c3 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/metadata/DefaultGraphConflictResolverTest.java
@@ -15,14 +15,15 @@ package org.apache.maven.repository.metadata;
* the License.
*/
+import javax.inject.Inject;
+
import org.apache.maven.artifact.ArtifactScopeEnum;
-import org.apache.maven.repository.metadata.ArtifactMetadata;
-import org.apache.maven.repository.metadata.GraphConflictResolver;
-import org.apache.maven.repository.metadata.MetadataGraph;
-import org.apache.maven.repository.metadata.MetadataGraphEdge;
-import org.apache.maven.repository.metadata.MetadataGraphVertex;
-import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.logging.Logger;
+import org.apache.maven.test.PlexusTestCase;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
*
@@ -33,8 +34,7 @@ import org.codehaus.plexus.logging.Logger;
public class DefaultGraphConflictResolverTest
extends PlexusTestCase
{
- Logger log;
-
+ @Inject
GraphConflictResolver resolver;
MetadataGraph graph;
@@ -44,11 +44,11 @@ extends PlexusTestCase
MetadataGraphVertex v3;
MetadataGraphVertex v4;
//------------------------------------------------------------------------------------------
+ @BeforeEach
@Override
- protected void setUp() throws Exception
+ public void setUp() throws Exception
{
super.setUp();
- resolver = (GraphConflictResolver) lookup( GraphConflictResolver.ROLE, "default" );
/*
* v2
@@ -76,6 +76,7 @@ extends PlexusTestCase
graph.addEdge(v3, v4, new MetadataGraphEdge( "1.2", true, ArtifactScopeEnum.provided, null, 2, 2 ) );
}
//------------------------------------------------------------------------------------------
+ @Test
public void testCompileResolution()
throws Exception
{
@@ -83,24 +84,25 @@ extends PlexusTestCase
res = resolver.resolveConflicts( graph, ArtifactScopeEnum.compile );
- assertNotNull("null graph after resolver", res );
- assertNotNull("no vertices in the resulting graph after resolver", res.getVertices() );
+ assertNotNull( res, "null graph after resolver" );
+ assertNotNull( res.getVertices(), "no vertices in the resulting graph after resolver" );
- assertNotNull("no edges in the resulting graph after resolver", res.getExcidentEdges(v1) );
+ assertNotNull( res.getExcidentEdges(v1), "no edges in the resulting graph after resolver" );
- assertEquals( "wrong # of vertices in the resulting graph after resolver", 4, res.getVertices().size() );
- assertEquals( "wrong # of excident edges in the resulting graph entry after resolver", 2, res.getExcidentEdges(v1).size() );
+ assertEquals( 4, res.getVertices().size(), "wrong # of vertices in the resulting graph after resolver" );
+ assertEquals( 2, res.getExcidentEdges(v1).size(), "wrong # of excident edges in the resulting graph entry after resolver" );
- assertEquals( "wrong # of v2 incident edges in the resulting graph after resolver", 1, res.getIncidentEdges(v2).size() );
- assertEquals( "wrong edge v1-v2 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v2).get(0).getVersion() );
+ assertEquals( 1, res.getIncidentEdges(v2).size(), "wrong # of v2 incident edges in the resulting graph after resolver" );
+ assertEquals( "1.2", res.getIncidentEdges(v2).get(0).getVersion(), "wrong edge v1-v2 in the resulting graph after resolver" );
- assertEquals( "wrong # of edges v1-v3 in the resulting graph after resolver", 1, res.getIncidentEdges(v3).size() );
- assertEquals( "wrong edge v1-v3 in the resulting graph after resolver", "1.1", res.getIncidentEdges(v3).get(0).getVersion() );
+ assertEquals( 1, res.getIncidentEdges(v3).size(), "wrong # of edges v1-v3 in the resulting graph after resolver" );
+ assertEquals( "1.1", res.getIncidentEdges(v3).get(0).getVersion(), "wrong edge v1-v3 in the resulting graph after resolver" );
- assertEquals( "wrong # of edges v3-v4 in the resulting graph after resolver", 1, res.getIncidentEdges(v4).size() );
- assertEquals( "wrong edge v3-v4 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v4).get(0).getVersion() );
+ assertEquals( 1, res.getIncidentEdges(v4).size(), "wrong # of edges v3-v4 in the resulting graph after resolver" );
+ assertEquals( "1.2", res.getIncidentEdges(v4).get(0).getVersion(), "wrong edge v3-v4 in the resulting graph after resolver" );
}
//------------------------------------------------------------------------------------------
+ @Test
public void testRuntimeResolution()
throws Exception
{
@@ -108,23 +110,24 @@ extends PlexusTestCase
res = resolver.resolveConflicts( graph, ArtifactScopeEnum.runtime );
- assertNotNull("null graph after resolver", res );
- assertNotNull("no vertices in the resulting graph after resolver", res.getVertices() );
- assertNotNull("no edges in the resulting graph after resolver", res.getExcidentEdges(v1) );
+ assertNotNull( res, "null graph after resolver" );
+ assertNotNull( res.getVertices(), "no vertices in the resulting graph after resolver" );
+ assertNotNull( res.getExcidentEdges(v1), "no edges in the resulting graph after resolver" );
- assertEquals( "wrong # of vertices in the resulting graph after resolver", 4, res.getVertices().size() );
- assertEquals( "wrong # of excident edges in the resulting graph entry after resolver", 2, res.getExcidentEdges(v1).size() );
+ assertEquals( 4, res.getVertices().size(), "wrong # of vertices in the resulting graph after resolver" );
+ assertEquals( 2, res.getExcidentEdges(v1).size(), "wrong # of excident edges in the resulting graph entry after resolver" );
- assertEquals( "wrong # of v2 incident edges in the resulting graph after resolver", 1, res.getIncidentEdges(v2).size() );
- assertEquals( "wrong edge v1-v2 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v2).get(0).getVersion() );
+ assertEquals( 1, res.getIncidentEdges(v2).size(), "wrong # of v2 incident edges in the resulting graph after resolver" );
+ assertEquals( "1.2", res.getIncidentEdges(v2).get(0).getVersion(), "wrong edge v1-v2 in the resulting graph after resolver" );
- assertEquals( "wrong # of edges v1-v3 in the resulting graph after resolver", 1, res.getIncidentEdges(v3).size() );
- assertEquals( "wrong edge v1-v3 in the resulting graph after resolver", "1.1", res.getIncidentEdges(v3).get(0).getVersion() );
+ assertEquals( 1, res.getIncidentEdges(v3).size(), "wrong # of edges v1-v3 in the resulting graph after resolver" );
+ assertEquals( "1.1", res.getIncidentEdges(v3).get(0).getVersion(), "wrong edge v1-v3 in the resulting graph after resolver" );
- assertEquals( "wrong # of edges v3-v4 in the resulting graph after resolver", 1, res.getIncidentEdges(v4).size() );
- assertEquals( "wrong edge v3-v4 in the resulting graph after resolver", "1.1", res.getIncidentEdges(v4).get(0).getVersion() );
+ assertEquals( 1, res.getIncidentEdges(v4).size(), "wrong # of edges v3-v4 in the resulting graph after resolver" );
+ assertEquals( "1.1", res.getIncidentEdges(v4).get(0).getVersion(), "wrong edge v3-v4 in the resulting graph after resolver" );
}
//------------------------------------------------------------------------------------------
+ @Test
public void testTestResolution()
throws Exception
{
@@ -132,21 +135,21 @@ extends PlexusTestCase
res = resolver.resolveConflicts( graph, ArtifactScopeEnum.test );
- assertNotNull("null graph after resolver", res );
- assertNotNull("no vertices in the resulting graph after resolver", res.getVertices() );
- assertNotNull("no edges in the resulting graph after resolver", res.getExcidentEdges(v1) );
+ assertNotNull( res, "null graph after resolver" );
+ assertNotNull( res.getVertices(), "no vertices in the resulting graph after resolver" );
+ assertNotNull( res.getExcidentEdges(v1), "no edges in the resulting graph after resolver" );
- assertEquals( "wrong # of vertices in the resulting graph after resolver", 4, res.getVertices().size() );
- assertEquals( "wrong # of excident edges in the resulting graph entry after resolver", 2, res.getExcidentEdges(v1).size() );
+ assertEquals( 4, res.getVertices().size(), "wrong # of vertices in the resulting graph after resolver" );
+ assertEquals( 2, res.getExcidentEdges(v1).size(), "wrong # of excident edges in the resulting graph entry after resolver" );
- assertEquals( "wrong # of v2 incident edges in the resulting graph after resolver", 1, res.getIncidentEdges(v2).size() );
- assertEquals( "wrong edge v1-v2 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v2).get(0).getVersion() );
+ assertEquals( 1, res.getIncidentEdges(v2).size(), "wrong # of v2 incident edges in the resulting graph after resolver" );
+ assertEquals( "1.2", res.getIncidentEdges(v2).get(0).getVersion(), "wrong edge v1-v2 in the resulting graph after resolver" );
- assertEquals( "wrong # of edges v1-v3 in the resulting graph after resolver", 1, res.getIncidentEdges(v3).size() );
- assertEquals( "wrong edge v1-v3 in the resulting graph after resolver", "1.1", res.getIncidentEdges(v3).get(0).getVersion() );
+ assertEquals( 1, res.getIncidentEdges(v3).size(), "wrong # of edges v1-v3 in the resulting graph after resolver" );
+ assertEquals( "1.1", res.getIncidentEdges(v3).get(0).getVersion(), "wrong edge v1-v3 in the resulting graph after resolver" );
- assertEquals( "wrong # of edges v3-v4 in the resulting graph after resolver", 1, res.getIncidentEdges(v4).size() );
- assertEquals( "wrong edge v3-v4 in the resulting graph after resolver", "1.2", res.getIncidentEdges(v4).get(0).getVersion() );
+ assertEquals( 1, res.getIncidentEdges(v4).size(), "wrong # of edges v3-v4 in the resulting graph after resolver" );
+ assertEquals( "1.2", res.getIncidentEdges(v4).get(0).getVersion(), "wrong edge v3-v4 in the resulting graph after resolver" );
}
//------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------
diff --git a/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java b/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java
index fbb9035830..efec2e6ea7 100644
--- a/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java
+++ b/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java
@@ -19,6 +19,10 @@ package org.apache.maven.repository.metadata;
* under the License.
*/
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -31,9 +35,6 @@ import org.apache.maven.repository.legacy.metadata.ResolutionGroup;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
@Named
@Singleton
diff --git a/maven-core/pom.xml b/maven-core/pom.xml
index 661ae9bf12..4316ff7ed4 100644
--- a/maven-core/pom.xml
+++ b/maven-core/pom.xml
@@ -156,6 +156,11 @@ under the License.
xmlunit-assertj
test
+
+ org.apache.maven
+ maven-test-support
+ test
+
diff --git a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
index de0f99beef..3b5b7a6bd4 100644
--- a/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
+++ b/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
@@ -22,7 +22,6 @@ package org.apache.maven;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Properties;
@@ -45,14 +44,14 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
+import org.apache.maven.test.PlexusTestCase;
import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
+import org.junit.jupiter.api.BeforeEach;
import javax.inject.Inject;
@@ -65,22 +64,6 @@ public abstract class AbstractCoreMavenComponentTestCase
@Inject
protected org.apache.maven.project.ProjectBuilder projectBuilder;
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- getContainer();
- }
-
- @Override
- protected synchronized void setupContainer()
- {
- super.setupContainer();
-
- ( (DefaultPlexusContainer) getContainer() ).addPlexusInjector( Collections.emptyList(),
- binder -> binder.requestInjection( this ) );
- }
-
abstract protected String getProjectsDirectory();
protected File getProject( String name )
diff --git a/maven-core/src/test/java/org/apache/maven/DefaultMavenTest.java b/maven-core/src/test/java/org/apache/maven/DefaultMavenTest.java
index c63acbc146..3a85ea4ad6 100644
--- a/maven-core/src/test/java/org/apache/maven/DefaultMavenTest.java
+++ b/maven-core/src/test/java/org/apache/maven/DefaultMavenTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,12 @@ package org.apache.maven;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven;
+
+import java.io.File;
+import java.nio.file.Files;
+
+import javax.inject.Inject;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
@@ -25,13 +29,10 @@ import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
-
-import java.io.File;
-import java.nio.file.Files;
-
-import javax.inject.Inject;
+import org.junit.jupiter.api.Test;
import static java.util.Arrays.asList;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class DefaultMavenTest
extends AbstractCoreMavenComponentTestCase
@@ -40,6 +41,14 @@ public class DefaultMavenTest
@Inject
private Maven maven;
+ @Override
+ protected String getProjectsDirectory()
+ {
+ return "src/test/projects/default-maven";
+ }
+
+
+ @Test
public void testThatErrorDuringProjectDependencyGraphCreationAreStored()
throws Exception
{
@@ -50,13 +59,7 @@ public class DefaultMavenTest
assertEquals( ProjectCycleException.class, result.getExceptions().get( 0 ).getClass() );
}
- @Override
- protected String getProjectsDirectory()
- {
- return "src/test/projects/default-maven";
- }
-
-
+ @Test
public void testMavenProjectNoDuplicateArtifacts()
throws Exception
{
diff --git a/maven-core/src/test/java/org/apache/maven/MavenLifecycleParticipantTest.java b/maven-core/src/test/java/org/apache/maven/MavenLifecycleParticipantTest.java
index 7d02856640..13ff67a1d6 100644
--- a/maven-core/src/test/java/org/apache/maven/MavenLifecycleParticipantTest.java
+++ b/maven-core/src/test/java/org/apache/maven/MavenLifecycleParticipantTest.java
@@ -29,6 +29,10 @@ import org.apache.maven.model.Dependency;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
public class MavenLifecycleParticipantTest
extends AbstractCoreMavenComponentTestCase
@@ -109,6 +113,7 @@ public class MavenLifecycleParticipantTest
return "src/test/projects/lifecycle-listener";
}
+ @Test
public void testDependencyInjection()
throws Exception
{
@@ -126,7 +131,7 @@ public class MavenLifecycleParticipantTest
request.setGoals( Arrays.asList( "validate" ) );
MavenExecutionResult result = maven.execute( request );
- assertFalse( result.getExceptions().toString(), result.hasExceptions() );
+ assertFalse( result.hasExceptions(), result.getExceptions().toString() );
MavenProject project = result.getProject();
@@ -138,6 +143,7 @@ public class MavenLifecycleParticipantTest
assertEquals( INJECTED_ARTIFACT_ID, artifacts.get( 0 ).getArtifactId() );
}
+ @Test
public void testReactorDependencyInjection()
throws Exception
{
@@ -161,7 +167,7 @@ public class MavenLifecycleParticipantTest
request.setGoals( Arrays.asList( "validate" ) );
MavenExecutionResult result = maven.execute( request );
- assertFalse( result.getExceptions().toString(), result.hasExceptions() );
+ assertFalse( result.hasExceptions(), result.getExceptions().toString() );
List order = new ArrayList<>();
for ( MavenProject project : result.getTopologicallySortedProjects() )
diff --git a/maven-core/src/test/java/org/apache/maven/MavenTest.java b/maven-core/src/test/java/org/apache/maven/MavenTest.java
index 711199a9de..991e61d0a7 100644
--- a/maven-core/src/test/java/org/apache/maven/MavenTest.java
+++ b/maven-core/src/test/java/org/apache/maven/MavenTest.java
@@ -17,14 +17,9 @@ package org.apache.maven;
import org.apache.maven.exception.ExceptionHandler;
-import org.apache.maven.exception.ExceptionSummary;
-import org.apache.maven.execution.MavenExecutionRequest;
-import org.apache.maven.execution.MavenExecutionResult;
-import org.codehaus.plexus.DefaultPlexusContainer;
+import org.junit.jupiter.api.Test;
import javax.inject.Inject;
-import java.io.File;
-import java.util.Collections;
public class MavenTest
extends AbstractCoreMavenComponentTestCase
@@ -35,20 +30,12 @@ public class MavenTest
@Inject
private ExceptionHandler exceptionHandler;
- @Override
- protected synchronized void setupContainer()
- {
- super.setupContainer();
-
- ( (DefaultPlexusContainer) getContainer() ).addPlexusInjector( Collections.emptyList(),
- binder -> binder.requestInjection( this ) );
- }
-
protected String getProjectsDirectory()
{
return "src/test/projects/lifecycle-executor";
}
+ @Test
public void testLifecycleExecutionUsingADefaultLifecyclePhase()
throws Exception
{
diff --git a/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java b/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java
index d3b2eaa5b6..777bae5a8b 100644
--- a/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java
+++ b/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java
@@ -15,9 +15,6 @@ package org.apache.maven;
* the License.
*/
-import static org.hamcrest.Matchers.endsWith;
-import static org.junit.Assert.assertThat;
-
import java.io.File;
import java.util.Collections;
import java.util.List;
@@ -29,6 +26,11 @@ import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import javax.inject.Inject;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.endsWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.hamcrest.MatcherAssert.assertThat;
public class ProjectDependenciesResolverTest
extends AbstractCoreMavenComponentTestCase
@@ -42,6 +44,7 @@ public class ProjectDependenciesResolverTest
}
/*
+ @Test
public void testExclusionsInDependencies()
throws Exception
{
@@ -65,6 +68,7 @@ public class ProjectDependenciesResolverTest
}
*/
+ @Test
public void testSystemScopeDependencies()
throws Exception
{
@@ -79,6 +83,7 @@ public class ProjectDependenciesResolverTest
assertEquals( 1, artifactDependencies.size() );
}
+ @Test
public void testSystemScopeDependencyIsPresentInTheCompileClasspathElements()
throws Exception
{
diff --git a/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java b/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java
index 2803d8d80a..6dba994a39 100644
--- a/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java
+++ b/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java
@@ -22,12 +22,16 @@ package org.apache.maven.artifact.handler;
import java.io.File;
import java.util.List;
-import org.codehaus.plexus.PlexusTestCase;
+import org.apache.maven.test.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ArtifactHandlerTest
extends PlexusTestCase
{
+ @Test
public void testAptConsistency()
throws Exception
{
@@ -47,7 +51,7 @@ public class ArtifactHandlerTest
int i = 0;
for ( String col : cols )
{
- assertEquals( "Wrong column header", expected[i++], col.trim() );
+ assertEquals( expected[i++], col.trim(), "Wrong column header" );
}
}
else if ( line.startsWith( "|" ) )
@@ -63,12 +67,12 @@ public class ArtifactHandlerTest
String includesDependencies = trimApt( cols[7] );
ArtifactHandler handler = lookup( ArtifactHandler.class, type );
- assertEquals( type + " extension", handler.getExtension(), extension );
- assertEquals( type + " packaging", handler.getPackaging(), packaging );
- assertEquals( type + " classifier", handler.getClassifier(), classifier );
- assertEquals( type + " language", handler.getLanguage(), language );
- assertEquals( type + " addedToClasspath", handler.isAddedToClasspath() ? "true" : null, addedToClasspath );
- assertEquals( type + " includesDependencies", handler.isIncludesDependencies() ? "true" : null, includesDependencies );
+ assertEquals( handler.getExtension(), extension, type + " extension" );
+ assertEquals( handler.getPackaging(), packaging, type + " packaging" );
+ assertEquals( handler.getClassifier(), classifier, type + " classifier" );
+ assertEquals( handler.getLanguage(), language, type + " language" );
+ assertEquals( handler.isAddedToClasspath() ? "true" : null, addedToClasspath, type + " addedToClasspath" );
+ assertEquals( handler.isIncludesDependencies() ? "true" : null, includesDependencies, type + " includesDependencies" );
}
}
}
diff --git a/maven-core/src/test/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilterTest.java b/maven-core/src/test/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilterTest.java
index c504c96bb9..76b1654644 100644
--- a/maven-core/src/test/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilterTest.java
+++ b/maven-core/src/test/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilterTest.java
@@ -21,14 +21,14 @@ package org.apache.maven.artifact.resolver.filter;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Exclusion;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.BeforeEach;
import java.util.Arrays;
import java.util.Collections;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -36,7 +36,7 @@ public class ExclusionArtifactFilterTest
{
private Artifact artifact;
- @Before
+ @BeforeEach
public void setup()
{
artifact = mock( Artifact.class );
diff --git a/maven-core/src/test/java/org/apache/maven/configuration/DefaultBeanConfiguratorTest.java b/maven-core/src/test/java/org/apache/maven/configuration/DefaultBeanConfiguratorTest.java
index a0588a2c9e..3dd3eff7f5 100644
--- a/maven-core/src/test/java/org/apache/maven/configuration/DefaultBeanConfiguratorTest.java
+++ b/maven-core/src/test/java/org/apache/maven/configuration/DefaultBeanConfiguratorTest.java
@@ -27,34 +27,32 @@ import org.apache.maven.configuration.internal.DefaultBeanConfigurator;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import junit.framework.TestCase;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Benjamin Bentmann
*/
public class DefaultBeanConfiguratorTest
- extends TestCase
{
private BeanConfigurator configurator;
- @Override
- protected void setUp()
+ @BeforeEach
+ public void setUp()
throws Exception
{
- super.setUp();
-
configurator = new DefaultBeanConfigurator();
}
- @Override
- protected void tearDown()
+ @AfterEach
+ public void tearDown()
throws Exception
{
configurator = null;
-
- super.tearDown();
}
private Xpp3Dom toConfig( String xml )
@@ -69,6 +67,7 @@ public class DefaultBeanConfiguratorTest
}
}
+ @Test
public void testMinimal()
throws BeanConfigurationException
{
@@ -84,6 +83,7 @@ public class DefaultBeanConfiguratorTest
assertEquals( new File( "test" ), bean.file );
}
+ @Test
public void testPreAndPostProcessing()
throws BeanConfigurationException
{
@@ -111,6 +111,7 @@ public class DefaultBeanConfiguratorTest
assertEquals( new File( "base/test" ).getAbsoluteFile(), bean.file );
}
+ @Test
public void testChildConfigurationElement()
throws BeanConfigurationException
{
diff --git a/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java b/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java
index 9fe6d4f30f..48cdb2fba1 100644
--- a/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java
+++ b/maven-core/src/test/java/org/apache/maven/exception/DefaultExceptionHandlerTest.java
@@ -30,9 +30,9 @@ import org.apache.maven.plugin.PluginContainerException;
import org.apache.maven.plugin.PluginExecutionException;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
-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 Barrie Treloar
diff --git a/maven-core/src/test/java/org/apache/maven/execution/DefaultBuildResumptionAnalyzerTest.java b/maven-core/src/test/java/org/apache/maven/execution/DefaultBuildResumptionAnalyzerTest.java
index 6e037763e2..df4941c434 100644
--- a/maven-core/src/test/java/org/apache/maven/execution/DefaultBuildResumptionAnalyzerTest.java
+++ b/maven-core/src/test/java/org/apache/maven/execution/DefaultBuildResumptionAnalyzerTest.java
@@ -22,8 +22,8 @@ package org.apache.maven.execution;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.model.Dependency;
import org.apache.maven.project.MavenProject;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.Optional;
@@ -40,7 +40,7 @@ public class DefaultBuildResumptionAnalyzerTest
private MavenExecutionResult executionResult;
- @Before
+ @BeforeEach
public void before() {
executionResult = new DefaultMavenExecutionResult();
}
diff --git a/maven-core/src/test/java/org/apache/maven/execution/DefaultBuildResumptionDataRepositoryTest.java b/maven-core/src/test/java/org/apache/maven/execution/DefaultBuildResumptionDataRepositoryTest.java
index 697c74f9a0..e1e1fa41ac 100644
--- a/maven-core/src/test/java/org/apache/maven/execution/DefaultBuildResumptionDataRepositoryTest.java
+++ b/maven-core/src/test/java/org/apache/maven/execution/DefaultBuildResumptionDataRepositoryTest.java
@@ -21,9 +21,7 @@ package org.apache.maven.execution;
import org.apache.maven.model.Build;
import org.apache.maven.project.MavenProject;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
@@ -34,7 +32,6 @@ import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
-@RunWith( MockitoJUnitRunner.class )
public class DefaultBuildResumptionDataRepositoryTest
{
private final DefaultBuildResumptionDataRepository repository = new DefaultBuildResumptionDataRepository();
diff --git a/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java
index bcc5895b7b..e57e79133f 100644
--- a/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java
+++ b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java
@@ -8,7 +8,10 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.settings.Profile;
import org.apache.maven.settings.Repository;
import org.apache.maven.settings.Settings;
-import org.eclipse.sisu.launch.InjectedTestCase;
+import org.apache.maven.test.PlexusTestCase;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -30,11 +33,12 @@ import org.eclipse.sisu.launch.InjectedTestCase;
*/
public class DefaultMavenExecutionRequestPopulatorTest
- extends InjectedTestCase
+ extends PlexusTestCase
{
@Inject
MavenExecutionRequestPopulator testee;
+ @Test
public void testPluginRepositoryInjection()
throws Exception
{
diff --git a/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java
index 237362e451..9a363eeeaf 100644
--- a/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java
+++ b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java
@@ -20,14 +20,14 @@ package org.apache.maven.execution;
*/
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.hamcrest.MatcherAssert.assertThat;
import java.util.List;
import org.apache.maven.project.MavenProject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* @author Benjamin Bentmann
diff --git a/maven-core/src/test/java/org/apache/maven/execution/scope/internal/MojoExecutionScopeTest.java b/maven-core/src/test/java/org/apache/maven/execution/scope/internal/MojoExecutionScopeTest.java
index c7db866bff..0dda0501b0 100644
--- a/maven-core/src/test/java/org/apache/maven/execution/scope/internal/MojoExecutionScopeTest.java
+++ b/maven-core/src/test/java/org/apache/maven/execution/scope/internal/MojoExecutionScopeTest.java
@@ -16,17 +16,19 @@ package org.apache.maven.execution.scope.internal;
import java.util.concurrent.atomic.AtomicInteger;
+import com.google.inject.Key;
import org.apache.maven.execution.MojoExecutionEvent;
import org.apache.maven.execution.scope.WeakMojoExecutionListener;
import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.jupiter.api.Test;
-import junit.framework.TestCase;
-
-import com.google.inject.Key;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class MojoExecutionScopeTest
- extends TestCase
{
+ @Test
public void testNestedEnter()
throws Exception
{
@@ -48,16 +50,10 @@ public class MojoExecutionScopeTest
scope.exit();
- try
- {
- scope.exit();
- fail();
- }
- catch ( IllegalStateException expected )
- {
- }
+ assertThrows( IllegalStateException.class, () -> scope.exit() );
}
+ @Test
public void testMultiKeyInstance()
throws Exception
{
diff --git a/maven-core/src/test/java/org/apache/maven/graph/DefaultGraphBuilderTest.java b/maven-core/src/test/java/org/apache/maven/graph/DefaultGraphBuilderTest.java
index 6a8320bae1..d2f29e2dee 100644
--- a/maven-core/src/test/java/org/apache/maven/graph/DefaultGraphBuilderTest.java
+++ b/maven-core/src/test/java/org/apache/maven/graph/DefaultGraphBuilderTest.java
@@ -37,12 +37,12 @@ import org.apache.maven.project.collector.MultiModuleCollectionStrategy;
import org.apache.maven.project.collector.PomlessCollectionStrategy;
import org.apache.maven.project.collector.ProjectsSelector;
import org.apache.maven.project.collector.RequestPomCollectionStrategy;
+import org.apache.maven.test.Parameter;
+import org.apache.maven.test.Parameterized;
+import org.apache.maven.test.Parameters;
+import org.apache.maven.test.Test;
import org.codehaus.plexus.util.StringUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeEach;
import java.io.File;
import java.util.ArrayList;
@@ -56,15 +56,15 @@ import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static java.util.function.Function.identity;
-import static junit.framework.TestCase.assertEquals;
import static org.apache.maven.execution.MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM;
import static org.apache.maven.execution.MavenExecutionRequest.REACTOR_MAKE_UPSTREAM;
import static org.apache.maven.graph.DefaultGraphBuilderTest.ScenarioBuilder.scenario;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-@RunWith( Parameterized.class )
+@Parameterized
public class DefaultGraphBuilderTest
{
/*
@@ -104,13 +104,20 @@ public class DefaultGraphBuilderTest
private Map artifactIdProjectMap;
// Parameters for the test
- private final String parameterDescription;
- private final List parameterSelectedProjects;
- private final List parameterExcludedProjects;
- private final String parameterResumeFrom;
- private final String parameterMakeBehavior;
- private final List parameterExpectedResult;
- private final File parameterRequestedPom;
+ @Parameter( 0 )
+ private String parameterDescription;
+ @Parameter( 1 )
+ private List parameterSelectedProjects;
+ @Parameter( 2 )
+ private List parameterExcludedProjects;
+ @Parameter( 3 )
+ private String parameterResumeFrom;
+ @Parameter( 4 )
+ private String parameterMakeBehavior;
+ @Parameter( 5 )
+ private List parameterExpectedResult;
+ @Parameter( 6 )
+ private File parameterRequestedPom;
@Parameters(name = "{index}. {0}")
public static Collection