maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1353035 - in /maven/release/trunk/maven-release-manager/src: main/java/org/apache/maven/shared/release/config/ReleaseUtils.java test/java/org/apache/maven/shared/release/config/ReleaseUtilsTest.java
Date Fri, 22 Jun 2012 21:33:13 GMT
Author: rfscholte
Date: Fri Jun 22 21:33:12 2012
New Revision: 1353035

URL: http://svn.apache.org/viewvc?rev=1353035&view=rev
Log:
Fix MRELEASE-750: String index out of range exception.
Actually it looks like ReleaseDescriptor.getResolvedDependencies() could have never worked
at all!

Modified:
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
    maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/ReleaseUtilsTest.java

Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java?rev=1353035&r1=1353034&r2=1353035&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
(original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
Fri Jun 22 21:33:12 2012
@@ -230,27 +230,26 @@ public class ReleaseUtils
         while ( iterator.hasNext() )
         {
             currentEntry = iterator.next();
-            propertyName = (String) currentEntry.getKey();
+            propertyName = currentEntry.getKey();
 
             if ( propertyName.startsWith( "dependency." ) )
             {
                 Map<String, String> versionMap;
                 String artifactVersionlessKey;
-                int startIndex;
+                int startIndex = "dependency.".length();
                 int endIndex;
                 String versionType;
 
                 versionMap = new HashMap<String, String>();
-                startIndex = propertyName.lastIndexOf( "dependency." );
 
                 if ( propertyName.indexOf( ".development" ) != -1 )
                 {
-                    endIndex = propertyName.indexOf( ".development" );
+                    endIndex = propertyName.lastIndexOf( ".development" );
                     versionType = ReleaseDescriptor.DEVELOPMENT_KEY;
                 }
                 else
                 {
-                    endIndex = propertyName.indexOf( ".release" );
+                    endIndex = propertyName.lastIndexOf( ".release" );
                     versionType = ReleaseDescriptor.RELEASE_KEY;
                 }
 

Modified: maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/ReleaseUtilsTest.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/ReleaseUtilsTest.java?rev=1353035&r1=1353034&r2=1353035&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/ReleaseUtilsTest.java
(original)
+++ maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/ReleaseUtilsTest.java
Fri Jun 22 21:33:12 2012
@@ -20,11 +20,15 @@ package org.apache.maven.shared.release.
  */
 
 import junit.framework.TestCase;
+
+import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.model.Scm;
 import org.apache.maven.shared.release.phase.AbstractReleaseTestCase;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
 
 /**
  * ReleaseDescriptor Tester.
@@ -250,6 +254,36 @@ public class ReleaseUtilsTest
                       createReleaseDescriptor( releaseDescriptor.getWorkingDirectory() ).hashCode()
);
     }
 
+    public void testLoadResolvedDependencies()
+    {
+        Properties properties = new Properties();
+        String dependencyKey = ArtifactUtils.versionlessKey( "com.groupId", "artifactId"
);
+        properties.put( "dependency." + dependencyKey  + ".release", "1.3" );
+        properties.put( "dependency." + dependencyKey + ".development", "1.3-SNAPSHOT" );
+        ReleaseDescriptor descriptor = ReleaseUtils.copyPropertiesToReleaseDescriptor( properties
);
+        
+        Map<String, String> versionMap = (Map<String, String>) descriptor.getResolvedSnapshotDependencies().get(
dependencyKey );
+        assertEquals( "1.3", versionMap.get( ReleaseDescriptor.RELEASE_KEY ) );
+        assertEquals( "1.3-SNAPSHOT", versionMap.get( ReleaseDescriptor.DEVELOPMENT_KEY)
);
+    }
+
+    // MRELEASE-750
+    public void testArtifactIdEndswithDependency()
+    {
+        Properties properties = new Properties();
+        String relDependencyKey = ArtifactUtils.versionlessKey( "com.release.magic", "dependency"
);
+        properties.put( "dependency." + relDependencyKey  + ".release", "1.3" );
+        String devDependencyKey = ArtifactUtils.versionlessKey( "com.development.magic",
"dependency" );
+        properties.put( "dependency." + devDependencyKey + ".development", "1.3-SNAPSHOT"
);
+        ReleaseDescriptor descriptor = ReleaseUtils.copyPropertiesToReleaseDescriptor( properties
);
+        
+        Map<String, String> versionMap = (Map<String, String>) descriptor.getResolvedSnapshotDependencies().get(
relDependencyKey );
+        assertEquals( "1.3", versionMap.get( ReleaseDescriptor.RELEASE_KEY ) );
+        
+        versionMap = (Map<String, String>) descriptor.getResolvedSnapshotDependencies().get(
devDependencyKey );
+        assertEquals( "1.3-SNAPSHOT", versionMap.get( ReleaseDescriptor.DEVELOPMENT_KEY)
);
+    }
+
     private static ReleaseDescriptor copyReleaseDescriptor( ReleaseDescriptor originalReleaseDescriptor
)
     {
         return createReleaseDescriptor( originalReleaseDescriptor.getWorkingDirectory() );



Mime
View raw message