You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2009/01/31 00:34:41 UTC

svn commit: r739450 - in /maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src: main/java/org/apache/maven/it/ test/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/maven/ test/java/org/apache/maven/it/

Author: brett
Date: Fri Jan 30 23:34:41 2009
New Revision: 739450

URL: http://svn.apache.org/viewvc?rev=739450&view=rev
Log:
also strip -RCx by default to match Maven convention where they are candidates for a release, not releases themselves

Added:
    maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/test/
    maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/test/java/
    maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/test/java/org/
    maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/test/java/org/apache/
    maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/test/java/org/apache/maven/
    maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/test/java/org/apache/maven/it/
    maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/test/java/org/apache/maven/it/MavenIntegrationTestCaseTest.java   (with props)
Modified:
    maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java

Modified: maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java?rev=739450&r1=739449&r2=739450&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java (original)
+++ maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java Fri Jan 30 23:34:41 2009
@@ -31,6 +31,8 @@
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import junit.framework.TestCase;
 
@@ -63,12 +65,21 @@
 
     private VersionRange versionRange;
 
+    private String matchPattern;
+
     protected AbstractMavenIntegrationTestCase()
     {
     }
 
     protected AbstractMavenIntegrationTestCase( String versionRangeStr )
     {
+        this( versionRangeStr, "(.*?)-(RC[0-9]+|SNAPSHOT|RC[0-9]+-SNAPSHOT)" );
+    }
+
+    protected AbstractMavenIntegrationTestCase( String versionRangeStr, String matchPattern )
+    {
+        this.matchPattern = matchPattern;
+
         try
         {
             versionRange = VersionRange.createFromVersionSpec( versionRangeStr );
@@ -81,7 +92,7 @@
         ArtifactVersion version = getMavenVersion();
         if ( version != null )
         {
-            skip = !versionRange.containsVersion( removeSnapshot( version ) );
+            skip = !versionRange.containsVersion( removePattern( version ) );
         }
         else
         {
@@ -129,7 +140,7 @@
         ArtifactVersion version = getMavenVersion();
         if ( version != null )
         {
-            return versionRange.containsVersion( removeSnapshot( version ) );
+            return versionRange.containsVersion( removePattern( version ) );
         }
         else
         {
@@ -226,12 +237,15 @@
         return localRepo;
     }
 
-    private static ArtifactVersion removeSnapshot( ArtifactVersion version )
+    protected ArtifactVersion removePattern( ArtifactVersion version )
     {
         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;
     }

Added: maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/test/java/org/apache/maven/it/MavenIntegrationTestCaseTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/test/java/org/apache/maven/it/MavenIntegrationTestCaseTest.java?rev=739450&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/test/java/org/apache/maven/it/MavenIntegrationTestCaseTest.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/test/java/org/apache/maven/it/MavenIntegrationTestCaseTest.java Fri Jan 30 23:34:41 2009
@@ -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() );
+    }
+}

Propchange: maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/test/java/org/apache/maven/it/MavenIntegrationTestCaseTest.java
------------------------------------------------------------------------------
    svn:eol-style = native