mirror of
https://github.com/apache/maven.git
synced 2025-02-23 10:45:27 +00:00
o Fixed NPE
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@739544 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2c0b8db8e5
commit
dd0662ab6a
@ -67,13 +67,16 @@ public abstract class AbstractMavenIntegrationTestCase
|
|||||||
|
|
||||||
private String matchPattern;
|
private String matchPattern;
|
||||||
|
|
||||||
|
private static final String DEFAULT_MATCH_PATTERN = "(.*?)-(RC[0-9]+|SNAPSHOT|RC[0-9]+-SNAPSHOT)";
|
||||||
|
|
||||||
protected AbstractMavenIntegrationTestCase()
|
protected AbstractMavenIntegrationTestCase()
|
||||||
{
|
{
|
||||||
|
this.matchPattern = DEFAULT_MATCH_PATTERN;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractMavenIntegrationTestCase( String versionRangeStr )
|
protected AbstractMavenIntegrationTestCase( String versionRangeStr )
|
||||||
{
|
{
|
||||||
this( versionRangeStr, "(.*?)-(RC[0-9]+|SNAPSHOT|RC[0-9]+-SNAPSHOT)" );
|
this( versionRangeStr, DEFAULT_MATCH_PATTERN );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractMavenIntegrationTestCase( String versionRangeStr, String matchPattern )
|
protected AbstractMavenIntegrationTestCase( String versionRangeStr, String matchPattern )
|
||||||
@ -237,7 +240,7 @@ protected File setupLocalRepo()
|
|||||||
return localRepo;
|
return localRepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArtifactVersion removePattern( ArtifactVersion version )
|
ArtifactVersion removePattern( ArtifactVersion version )
|
||||||
{
|
{
|
||||||
String v = version.toString();
|
String v = version.toString();
|
||||||
|
|
||||||
|
@ -19,34 +19,47 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
|
||||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
|
||||||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
|
||||||
import org.apache.maven.artifact.versioning.VersionRange;
|
|
||||||
import org.apache.maven.it.util.FileUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.text.DecimalFormatSymbols;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
|
|
||||||
public class MavenIntegrationTestCaseTest
|
public class MavenIntegrationTestCaseTest
|
||||||
extends TestCase
|
extends TestCase
|
||||||
{
|
{
|
||||||
public void testRemovePattern()
|
|
||||||
|
public void testRemovePatternForTestWithVersionRange()
|
||||||
{
|
{
|
||||||
AbstractMavenIntegrationTestCase test = new AbstractMavenIntegrationTestCase( "[2.0,)" ) {};
|
AbstractMavenIntegrationTestCase test = new AbstractMavenIntegrationTestCase( "[2.0,)" )
|
||||||
assertEquals( "2.1.0-M1", test.removePattern( new DefaultArtifactVersion( "2.1.0-M1" ) ).toString() );
|
{
|
||||||
assertEquals( "2.1.0-M1", test.removePattern( new DefaultArtifactVersion( "2.1.0-M1-SNAPSHOT" ) ).toString() );
|
// test case with version range
|
||||||
assertEquals( "2.1.0-M1", test.removePattern( new DefaultArtifactVersion( "2.1.0-M1-RC1" ) ).toString() );
|
};
|
||||||
assertEquals( "2.1.0-M1", test.removePattern( new DefaultArtifactVersion( "2.1.0-M1-RC1-SNAPSHOT" ) ).toString() );
|
testRemovePattern( test );
|
||||||
assertEquals( "2.0.10", test.removePattern( new DefaultArtifactVersion( "2.0.10" ) ).toString() );
|
|
||||||
assertEquals( "2.0.10", test.removePattern( new DefaultArtifactVersion( "2.0.10-SNAPSHOT" ) ).toString() );
|
|
||||||
assertEquals( "2.0.10", test.removePattern( new DefaultArtifactVersion( "2.0.10-RC1" ) ).toString() );
|
|
||||||
assertEquals( "2.0.10", test.removePattern( new DefaultArtifactVersion( "2.0.10-RC1-SNAPSHOT" ) ).toString() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testRemovePatternForTestWithoutVersionRange()
|
||||||
|
{
|
||||||
|
AbstractMavenIntegrationTestCase test = new AbstractMavenIntegrationTestCase()
|
||||||
|
{
|
||||||
|
// test case without version range
|
||||||
|
};
|
||||||
|
testRemovePattern( test );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void testRemovePattern( AbstractMavenIntegrationTestCase test )
|
||||||
|
{
|
||||||
|
assertVersionEquals( "2.1.0-M1", "2.1.0-M1", test );
|
||||||
|
assertVersionEquals( "2.1.0-M1", "2.1.0-M1-SNAPSHOT", test );
|
||||||
|
assertVersionEquals( "2.1.0-M1", "2.1.0-M1-RC1", test );
|
||||||
|
assertVersionEquals( "2.1.0-M1", "2.1.0-M1-RC1-SNAPSHOT", test );
|
||||||
|
assertVersionEquals( "2.0.10", "2.0.10", test );
|
||||||
|
assertVersionEquals( "2.0.10", "2.0.10-SNAPSHOT", test );
|
||||||
|
assertVersionEquals( "2.0.10", "2.0.10-RC1", test );
|
||||||
|
assertVersionEquals( "2.0.10", "2.0.10-RC1-SNAPSHOT", test );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void assertVersionEquals( String expected, String version, AbstractMavenIntegrationTestCase test )
|
||||||
|
{
|
||||||
|
assertEquals( expected, test.removePattern( new DefaultArtifactVersion( version ) ).toString() );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user