]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1312] mda5 and sha are not generated for snapshot jars
authorMaria Odea B. Ching <oching@apache.org>
Thu, 25 Feb 2010 09:32:12 +0000 (09:32 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Thu, 25 Feb 2010 09:32:12 +0000 (09:32 +0000)
submitted by Maria Catherine Tan

o use the actual file, which has a timestamp + build number version, when creating a repository task for a snapshot artifact

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-1.3.x@916197 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java

index 0796850c96d632d11095e3978e2dd95bcaf7b9ef..57f71d6126d8395048c5202793ed14dcc07f19bf 100644 (file)
@@ -360,7 +360,7 @@ public class UploadAction
                 else
                 {
                     copyFile( artifactFile, targetPath, filename, fixChecksums );
-                    queueRepositoryTask( repository.getId(), repository.toFile( artifactReference ) );                    
+                    queueRepositoryTask( repository.getId(), targetFile );                    
                 }
             }
             catch ( IOException ie )
index 1af6eda88c24c5dba8f3489585029080b158e02b..4ffa8e1b7b6c240de19f4c556c994b871d3c050e 100644 (file)
@@ -411,13 +411,88 @@ public class UploadActionTest
         auditLogsDaoControl.verify();
 
         String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
-        assertEquals( 6, new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" ).list().length );
+        String[] artifactsList = new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" ).list();
+
+        assertEquals( 6, artifactsList.length );
 
         assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA ).exists() );
         assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA +
             ".sha1" ).exists() );
         assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/" + MetadataTools.MAVEN_METADATA +
             ".md5" ).exists() );
+
+        int startIndex = "artifact-upload-1.0-".length();
+        int endIndex = -1; 
+
+        if ( artifactsList[0].contains( "jar" ) )
+        {
+            endIndex = artifactsList[0].indexOf( ".jar" );
+        }
+        else
+        {
+            endIndex = artifactsList[0].indexOf( ".pom" );
+        }
+
+        String timestamp = artifactsList[0].substring( startIndex, endIndex );
+
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + ".jar" ).exists()  );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + ".jar.md5" ).exists()  );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + ".jar.sha1" ).exists()  );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + ".pom" ).exists()  );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + ".pom.md5" ).exists()  );
+        assertTrue( new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + ".pom.sha1" ).exists()  );
+
+        // verify checksums of jar file
+        ChecksummedFile checksum =
+            new ChecksummedFile( new File( repoLocation,
+                                           "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + ".jar" ) );
+        String sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
+        String md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
+
+        String contents =
+            FileUtils.readFileToString( new File( repoLocation,
+                                                  "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + ".jar.sha1" ) );
+        assertTrue( StringUtils.contains( contents, sha1 ) );
+
+        contents =
+            FileUtils.readFileToString( new File( repoLocation,
+                                                  "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + ".jar.md5" ) );
+        assertTrue( StringUtils.contains( contents, md5 ) );
+
+        // verify checksums of pom file
+        checksum =
+            new ChecksummedFile( new File( repoLocation,
+                                           "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + ".pom" ) );
+        sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
+        md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
+
+        contents =
+            FileUtils.readFileToString( new File( repoLocation,
+                                                  "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + ".pom.sha1" ) );
+        assertTrue( StringUtils.contains( contents, sha1 ) );
+
+        contents =
+            FileUtils.readFileToString( new File( repoLocation,
+                                                  "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/artifact-upload-1.0-" + timestamp + ".pom.md5" ) );
+        assertTrue( StringUtils.contains( contents, md5 ) );
+
+        
+        // verify checksums of metadata file
+        checksum =
+            new ChecksummedFile( new File( repoLocation, "/org/apache/archiva/artifact-upload/" +
+                MetadataTools.MAVEN_METADATA ) );
+        sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
+        md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
+
+        contents =
+            FileUtils.readFileToString( new File( repoLocation, "/org/apache/archiva/artifact-upload/" +
+                MetadataTools.MAVEN_METADATA + ".sha1" ) );
+        assertTrue( StringUtils.contains( contents, sha1 ) );
+
+        contents =
+            FileUtils.readFileToString( new File( repoLocation, "/org/apache/archiva/artifact-upload/" +
+                MetadataTools.MAVEN_METADATA + ".md5" ) );
+        assertTrue( StringUtils.contains( contents, md5 ) );
     }
 
     public void testChecksumIsCorrectWhenArtifactIsReUploaded()