mirror of https://github.com/apache/maven.git
also strip -RCx by default to match Maven convention where they are candidates for a release, not releases themselves
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@739450 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
31fd483930
commit
2c0b8db8e5
|
@ -31,6 +31,8 @@ import java.io.PrintStream;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
@ -63,12 +65,21 @@ public abstract class AbstractMavenIntegrationTestCase
|
||||||
|
|
||||||
private VersionRange versionRange;
|
private VersionRange versionRange;
|
||||||
|
|
||||||
|
private String matchPattern;
|
||||||
|
|
||||||
protected AbstractMavenIntegrationTestCase()
|
protected AbstractMavenIntegrationTestCase()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractMavenIntegrationTestCase( String versionRangeStr )
|
protected AbstractMavenIntegrationTestCase( String versionRangeStr )
|
||||||
{
|
{
|
||||||
|
this( versionRangeStr, "(.*?)-(RC[0-9]+|SNAPSHOT|RC[0-9]+-SNAPSHOT)" );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AbstractMavenIntegrationTestCase( String versionRangeStr, String matchPattern )
|
||||||
|
{
|
||||||
|
this.matchPattern = matchPattern;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
versionRange = VersionRange.createFromVersionSpec( versionRangeStr );
|
versionRange = VersionRange.createFromVersionSpec( versionRangeStr );
|
||||||
|
@ -81,7 +92,7 @@ public abstract class AbstractMavenIntegrationTestCase
|
||||||
ArtifactVersion version = getMavenVersion();
|
ArtifactVersion version = getMavenVersion();
|
||||||
if ( version != null )
|
if ( version != null )
|
||||||
{
|
{
|
||||||
skip = !versionRange.containsVersion( removeSnapshot( version ) );
|
skip = !versionRange.containsVersion( removePattern( version ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -129,7 +140,7 @@ public abstract class AbstractMavenIntegrationTestCase
|
||||||
ArtifactVersion version = getMavenVersion();
|
ArtifactVersion version = getMavenVersion();
|
||||||
if ( version != null )
|
if ( version != null )
|
||||||
{
|
{
|
||||||
return versionRange.containsVersion( removeSnapshot( version ) );
|
return versionRange.containsVersion( removePattern( version ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -226,12 +237,15 @@ public abstract class AbstractMavenIntegrationTestCase
|
||||||
return localRepo;
|
return localRepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArtifactVersion removeSnapshot( ArtifactVersion version )
|
protected ArtifactVersion removePattern( ArtifactVersion version )
|
||||||
{
|
{
|
||||||
String v = version.toString();
|
String v = version.toString();
|
||||||
if ( v.endsWith( "-SNAPSHOT" ) )
|
|
||||||
|
Matcher m = Pattern.compile( matchPattern ).matcher( v );
|
||||||
|
|
||||||
|
if ( m.matches() )
|
||||||
{
|
{
|
||||||
return new DefaultArtifactVersion( v.substring( 0, v.length() - 9 ) );
|
return new DefaultArtifactVersion( m.group( 1 ) );
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package org.apache.maven.it;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class MavenIntegrationTestCaseTest
|
||||||
|
extends TestCase
|
||||||
|
{
|
||||||
|
public void testRemovePattern()
|
||||||
|
{
|
||||||
|
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() );
|
||||||
|
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() );
|
||||||
|
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() );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue