maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r431275 - in /maven/repository-manager/trunk: maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/ maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/ maven-repository-proxy/src/test/repositories/manag...
Date Mon, 14 Aug 2006 00:52:44 GMT
Author: brett
Date: Sun Aug 13 17:52:42 2006
New Revision: 431275

URL: http://svn.apache.org/viewvc?rev=431275&view=rev
Log:
[MRM-138] add checksum tests and bugfixes, refactor digest utils out

Added:
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar.md5
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar.sha1
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-removed-from-proxies/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-removed-from-proxies/1.0/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-removed-from-proxies/1.0/get-removed-from-proxies-1.0.jar
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-bad-local-checksum/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-bad-local-checksum/1.0/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar.md5
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar.sha1
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar.md5
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar.sha1
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar.md5
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar.sha1
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-only/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-only/1.0/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar.md5
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar.md5
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar.sha1
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-only/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-only/1.0/
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar
    maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar.sha1
    maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/DigestUtils.java   (with props)
Modified:
    maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyRequestHandler.java
    maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/ProxyRequestHandlerTest.java
    maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/WagonDelegate.java
    maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/AbstractDigester.java

Modified: maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyRequestHandler.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyRequestHandler.java?rev=431275&r1=431274&r2=431275&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyRequestHandler.java (original)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyRequestHandler.java Sun Aug 13 17:52:42 2006
@@ -19,6 +19,8 @@
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.repository.digest.DigestUtils;
+import org.apache.maven.repository.digest.DigesterException;
 import org.apache.maven.repository.discovery.ArtifactDiscoverer;
 import org.apache.maven.repository.discovery.DiscovererException;
 import org.apache.maven.wagon.ConnectionException;
@@ -47,6 +49,7 @@
  *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @plexus.component
+ * @todo use wagonManager for cache use file:// as URL
  * @todo this currently duplicates a lot of the wagon manager, and doesn't do things like snapshot resolution, etc.
  * The checksum handling is inconsistent with that of the wagon manager.
  * Should we have a more artifact based one? This will merge metadata so should behave correctly, and it is able to
@@ -72,6 +75,11 @@
      */
     private Map/*<String,Wagon>*/ wagons;
 
+    /**
+     * @plexus.requirement role="org.apache.maven.repository.digest.Digester"
+     */
+    private Map/*<String,Digester>*/ digesters;
+
     public File get( String path, List proxiedRepositories, ArtifactRepository managedRepository )
         throws ProxyException, ResourceDoesNotExistException
     {
@@ -81,17 +89,9 @@
     public File get( String path, List proxiedRepositories, ArtifactRepository managedRepository, ProxyInfo wagonProxy )
         throws ProxyException, ResourceDoesNotExistException
     {
-        // TODO! this will prove wrong for metadata and snapshots, let tests bring it out
-        //@todo use wagonManager for cache use file:// as URL
-        File cachedFile = new File( managedRepository.getBasedir(), path );
-        if ( !cachedFile.exists() )
-        {
-            cachedFile = getAlways( path, proxiedRepositories, managedRepository, wagonProxy );
-        }
-        return cachedFile;
+        return get( managedRepository, path, proxiedRepositories, wagonProxy, false );
     }
 
-
     public File getAlways( String path, List proxiedRepositories, ArtifactRepository managedRepository )
         throws ProxyException, ResourceDoesNotExistException
     {
@@ -102,19 +102,26 @@
                            ProxyInfo wagonProxy )
         throws ResourceDoesNotExistException, ProxyException
     {
+        return get( managedRepository, path, proxiedRepositories, wagonProxy, true );
+    }
+
+    private File get( ArtifactRepository managedRepository, String path, List proxiedRepositories, ProxyInfo wagonProxy,
+                      boolean force )
+        throws ProxyException, ResourceDoesNotExistException
+    {
         File target = new File( managedRepository.getBasedir(), path );
 
         for ( Iterator i = proxiedRepositories.iterator(); i.hasNext(); )
         {
             ProxiedArtifactRepository repository = (ProxiedArtifactRepository) i.next();
 
-            if ( repository.isCachedFailure( path ) )
+            if ( !force && repository.isCachedFailure( path ) )
             {
                 processCachedRepositoryFailure( repository, "Cached failure found for: " + path );
             }
             else
             {
-                get( path, target, repository, managedRepository, wagonProxy );
+                get( path, target, repository, managedRepository, wagonProxy, force );
             }
         }
 
@@ -127,10 +134,10 @@
     }
 
     private void get( String path, File target, ProxiedArtifactRepository repository,
-                      ArtifactRepository managedRepository, ProxyInfo wagonProxy )
+                      ArtifactRepository managedRepository, ProxyInfo wagonProxy, boolean force )
         throws ProxyException
     {
-        ArtifactRepositoryPolicy policy = null;
+        ArtifactRepositoryPolicy policy;
 
         if ( path.endsWith( ".md5" ) || path.endsWith( ".sha1" ) )
         {
@@ -138,12 +145,12 @@
         }
         else if ( path.endsWith( "maven-metadata.xml" ) )
         {
-            // TODO: this is not "always" as this method expects!
             // TODO: merge the metadata!
             policy = repository.getRepository().getReleases();
-            if ( !target.exists() || isOutOfDate( policy, target ) )
+            if ( force || !target.exists() || isOutOfDate( policy, target ) )
             {
-                getFileFromRepository( path, repository, managedRepository.getBasedir(), wagonProxy, target, policy );
+                getFileFromRepository( path, repository, managedRepository.getBasedir(), wagonProxy, target, policy,
+                                       force );
             }
         }
         else
@@ -182,23 +189,21 @@
                 else
                 {
                     // Don't use releases policy, we don't want to perform updates on them (only metadata, as used earlier)
-                    // TODO: this is not "always" as this method expects!
-                    if ( !target.exists() || isOutOfDate( policy, target ) )
+                    if ( force || !target.exists() || isOutOfDate( policy, target ) )
                     {
                         getFileFromRepository( artifactRepository.pathOf( artifact ), repository,
-                                               managedRepository.getBasedir(), wagonProxy, target, policy );
+                                               managedRepository.getBasedir(), wagonProxy, target, policy, force );
                     }
                 }
             }
             else
             {
                 // Some other unknown file in the repository, proxy as is
-                // TODO: this is not "always" as this method expects!
-                if ( !target.exists() )
+                if ( force || !target.exists() )
                 {
                     policy = repository.getRepository().getReleases();
-                    getFileFromRepository( path, repository, managedRepository.getBasedir(), wagonProxy, target,
-                                           policy );
+                    getFileFromRepository( path, repository, managedRepository.getBasedir(), wagonProxy, target, policy,
+                                           force );
                 }
             }
         }
@@ -211,13 +216,17 @@
     }
 
     private void getFileFromRepository( String path, ProxiedArtifactRepository repository, String repositoryCachePath,
-                                        ProxyInfo httpProxy, File target, ArtifactRepositoryPolicy policy )
+                                        ProxyInfo httpProxy, File target, ArtifactRepositoryPolicy policy,
+                                        boolean force )
         throws ProxyException
     {
         boolean connected = false;
         Map checksums = null;
         Wagon wagon = null;
 
+        File temp = new File( target.getAbsolutePath() + ".tmp" );
+        temp.deleteOnExit();
+
         try
         {
             String protocol = repository.getRepository().getProtocol();
@@ -234,9 +243,6 @@
             connected = connectToRepository( wagon, repository, httpProxy );
             if ( connected )
             {
-                File temp = new File( target.getAbsolutePath() + ".tmp" );
-                temp.deleteOnExit();
-
                 int tries = 0;
                 boolean success;
 
@@ -246,7 +252,7 @@
 
                     getLogger().debug( "Trying " + path + " from " + repository.getName() + "..." );
 
-                    if ( !target.exists() )
+                    if ( force || !target.exists() )
                     {
                         wagon.get( path, temp );
                     }
@@ -263,14 +269,14 @@
                                                   path, policy );
                         return;
                     }
-
-                    // temp won't exist if we called getIfNewer and it was older, but its still a successful return
-                    if ( temp.exists() )
-                    {
-                        moveTempToTarget( temp, target );
-                    }
                 }
                 while ( !success );
+
+                // temp won't exist if we called getIfNewer and it was older, but its still a successful return
+                if ( temp.exists() )
+                {
+                    moveTempToTarget( temp, target );
+                }
             }
             //try next repository
         }
@@ -289,6 +295,8 @@
         }
         finally
         {
+            temp.delete();
+
             if ( wagon != null && checksums != null )
             {
                 releaseChecksumListeners( wagon, checksums );
@@ -374,70 +382,92 @@
         throws ProxyException
     {
         releaseChecksumListeners( wagon, checksumMap );
-        for ( Iterator checksums = checksumMap.keySet().iterator(); checksums.hasNext(); )
+
+        boolean correctChecksum = false;
+
+        boolean allNotFound = true;
+
+        for ( Iterator i = checksumMap.keySet().iterator(); i.hasNext() && !correctChecksum; )
         {
-            String checksumExt = (String) checksums.next();
+            String checksumExt = (String) i.next();
             ChecksumObserver checksum = (ChecksumObserver) checksumMap.get( checksumExt );
             String checksumPath = path + "." + checksumExt;
             File checksumFile = new File( repositoryCachePath, checksumPath );
 
+            File tempChecksumFile = new File( checksumFile.getAbsolutePath() + ".tmp" );
+            tempChecksumFile.deleteOnExit();
+
             try
             {
-                File tempChecksumFile = new File( checksumFile.getAbsolutePath() + ".tmp" );
-
                 wagon.get( checksumPath, tempChecksumFile );
 
-                String remoteChecksum = FileUtils.fileRead( tempChecksumFile ).trim();
-                if ( remoteChecksum.indexOf( ' ' ) > 0 )
-                {
-                    remoteChecksum = remoteChecksum.substring( 0, remoteChecksum.indexOf( ' ' ) );
-                }
+                allNotFound = false;
+
+                String remoteChecksum = DigestUtils.cleanChecksum( FileUtils.fileRead( tempChecksumFile ),
+                                                                   checksumExt.toUpperCase(),
+                                                                   path.substring( path.lastIndexOf( '/' ) ) );
 
                 String actualChecksum = checksum.getActualChecksum().toUpperCase();
                 remoteChecksum = remoteChecksum.toUpperCase();
 
-                boolean checksumCheck;
                 if ( remoteChecksum.equals( actualChecksum ) )
                 {
                     moveTempToTarget( tempChecksumFile, checksumFile );
 
-                    checksumCheck = true;
+                    correctChecksum = true;
                 }
                 else
                 {
                     getLogger().warn(
                         "The checksum '" + actualChecksum + "' did not match the remote value: " + remoteChecksum );
-                    checksumCheck = false;
                 }
-                return checksumCheck;
             }
             catch ( TransferFailedException e )
             {
                 getLogger().warn( "An error occurred during the download of " + checksumPath + ": " + e.getMessage(),
                                   e );
                 // do nothing try the next checksum
+
+                allNotFound = false;
             }
             catch ( ResourceDoesNotExistException e )
             {
                 getLogger().debug( "The checksum did not exist: " + checksumPath, e );
                 // do nothing try the next checksum
+                // remove it if it is present locally in case there is an old incorrect one
+                if ( checksumFile.exists() )
+                {
+                    checksumFile.delete();
+                }
             }
             catch ( AuthorizationException e )
             {
                 getLogger().warn( "An error occurred during the download of " + checksumPath + ": " + e.getMessage(),
                                   e );
                 // do nothing try the next checksum
+
+                allNotFound = false;
             }
             catch ( IOException e )
             {
                 getLogger().warn( "An error occurred while reading the temporary checksum file.", e );
-                return false;
-            }
-        }
+                // do nothing try the next checksum
 
-        getLogger().debug( "No remote checksums available." );
+                allNotFound = false;
+            }
+            catch ( DigesterException e )
+            {
+                getLogger().warn( "The checksum was invalid: " + checksumPath + ": " + e.getMessage(), e );
+                // do nothing try the next checksum
 
-        return true;
+                allNotFound = false;
+            }
+            finally
+            {
+                tempChecksumFile.delete();
+            }
+        }
+        return correctChecksum || allNotFound;
     }
 
     /**

Modified: maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/ProxyRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/ProxyRequestHandlerTest.java?rev=431275&r1=431274&r2=431275&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/ProxyRequestHandlerTest.java (original)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/ProxyRequestHandlerTest.java Sun Aug 13 17:52:42 2006
@@ -38,27 +38,27 @@
 /**
  * @author Brett Porter
  * @todo! tests to do vvv
- * @todo test get always
- * @todo test get always when resource is present locally but not in any proxied repos (should fail)
- * @todo test get always ignores cached failures
- * @todo test when managed repo is m1 layout (proxy is m2), including metadata
- * @todo test when one proxied repo is m1 layout (managed is m2), including metadata
- * @todo test when one proxied repo is m1 layout (managed is m1), including metadata
+ * @todo test checksum request from proxy gets from managed repo when present
+ * @todo test checksum request from proxy doesn't go to proxy when not in managed repo
  * @todo test metadata - general
  * @todo test metadata - multiple repos are merged
  * @todo test metadata - update interval
  * @todo test metadata - looking for an update and file has been removed remotely
  * @todo test snapshots - general
- * @todo test snapshots - newer version on repo2 is pulled down
- * @todo test snapshots - older version on repo2 is skipped
- * @todo test snapshots - update interval
+ * @todo test snapshots - newer version on repo1 (than local), timestamp driven
+ * @todo test snapshots - older version on repo1 skipped (than local), timestamp driven
+ * @todo test snapshots - newer version on repo2 is pulled down (no local), timestamp driven
+ * @todo test snapshots - older version on repo2 is skipped  (no local), timestamp driven
+ * @todo test snapshots - update interval (not updated if within period), timestamp driven
+ * @todo test snapshots - newer version on repo1 (than local), metadata driven
+ * @todo test snapshots - older version on repo1 skipped (than local), metadata driven
+ * @todo test snapshots - newer version on repo2 is pulled down (no local), metadata driven
+ * @todo test snapshots - older version on repo2 is skipped  (no local), metadata driven
+ * @todo test snapshots - update interval (not updated if within period), metadata driven
  * @todo test snapshots - when failure is cached but cache period is over (and check failure is cleared)
- * @todo test remote checksum only md5
- * @todo test remote checksum only sha1
- * @todo test remote checksum missing
- * @todo test remote checksum present and correct
- * @todo test remote checksum present and incorrect
- * @todo test remote checksum transfer failed
+ * @todo test when managed repo is m1 layout (proxy is m2), including metadata
+ * @todo test when one proxied repo is m1 layout (managed is m2), including metadata
+ * @todo test when one proxied repo is m1 layout (managed is m1), including metadata
  */
 public class ProxyRequestHandlerTest
     extends PlexusTestCase
@@ -451,6 +451,397 @@
         assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
 
         assertFalse( "Check failure", proxiedArtifactRepository.isCachedFailure( path ) );
+    }
+
+    public void testGetAlwaysAlreadyPresent()
+        throws ResourceDoesNotExistException, ProxyException, IOException
+    {
+        String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+        String unexpectedContents = FileUtils.fileRead( expectedFile );
+
+        assertTrue( expectedFile.exists() );
+
+        File file = requestHandler.getAlways( path, proxiedRepositories, defaultManagedRepository );
+
+        assertEquals( "Check file matches", expectedFile, file );
+        assertTrue( "Check file created", file.exists() );
+        File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
+        String expectedContents = FileUtils.fileRead( proxiedFile );
+        assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+        assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+    }
+
+    public void testGetAlwaysAlreadyPresentRemovedFromProxies()
+        throws ResourceDoesNotExistException, ProxyException, IOException
+    {
+        String path = "org/apache/maven/test/get-removed-from-proxies/1.0/get-removed-from-proxies-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+        String expectedContents = FileUtils.fileRead( expectedFile );
+
+        assertTrue( expectedFile.exists() );
+
+        File file = requestHandler.getAlways( path, proxiedRepositories, defaultManagedRepository );
+
+        assertEquals( "Check file matches", expectedFile, file );
+        assertTrue( "Check file created", file.exists() );
+        assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+
+        // TODO: is this the correct behaviour, or should it be considered removed too?
+    }
+
+    public void testGetAlwaysWithCachedFailure()
+        throws ResourceDoesNotExistException, ProxyException, IOException
+    {
+        String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+        String unexpectedContents = FileUtils.fileRead( expectedFile );
+
+        assertTrue( expectedFile.exists() );
+
+        proxiedRepositories.clear();
+        ProxiedArtifactRepository proxiedArtifactRepository = createProxiedRepository( proxiedRepository1 );
+        proxiedArtifactRepository.addFailure( path, DEFAULT_POLICY );
+        proxiedRepositories.add( proxiedArtifactRepository );
+        proxiedRepositories.add( createProxiedRepository( proxiedRepository2 ) );
+        File file = requestHandler.getAlways( path, proxiedRepositories, defaultManagedRepository );
+
+        assertEquals( "Check file matches", expectedFile, file );
+        assertTrue( "Check file created", file.exists() );
+        File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
+        String expectedContents = FileUtils.fileRead( proxiedFile );
+        assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+        assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+    }
+
+    public void testGetRemovesTemporaryFileOnSuccess()
+        throws ResourceDoesNotExistException, ProxyException, IOException
+    {
+        String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+
+        assertFalse( expectedFile.exists() );
+
+        File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
+
+        assertEquals( "Check file matches", expectedFile, file );
+        assertTrue( "Check file created", file.exists() );
+        File tempFile = new File( file.getParentFile(), file.getName() + ".tmp" );
+        assertFalse( "Check temporary file removed", tempFile.exists() );
+    }
+
+    public void testGetRemovesTemporaryFileOnError()
+        throws ResourceDoesNotExistException, ProxyException, IOException, TransferFailedException,
+        AuthorizationException
+    {
+        String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+
+        assertFalse( expectedFile.exists() );
+
+        proxiedRepository1 = createRepository( "proxied1", "test://..." );
+        proxiedRepositories.clear();
+        ProxiedArtifactRepository proxiedArtifactRepository1 = createProxiedRepository( proxiedRepository1 );
+        proxiedRepositories.add( proxiedArtifactRepository1 );
+
+        wagonMock.get( path, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) );
+        wagonMockControl.setThrowable( new TransferFailedException( "transfer failed" ) );
+
+        wagonMockControl.replay();
+
+        try
+        {
+            File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
+            fail( "Found file: " + file + "; but was expecting a failure" );
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            // as expected
+            wagonMockControl.verify();
+
+            File tempFile = new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" );
+            assertFalse( "Check temporary file removed", tempFile.exists() );
+        }
+    }
+
+    public void testGetRemovesTemporaryChecksumFileOnSuccess()
+        throws ResourceDoesNotExistException, ProxyException, IOException
+    {
+        String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+
+        assertFalse( expectedFile.exists() );
+
+        File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
+
+        assertEquals( "Check file matches", expectedFile, file );
+        assertTrue( "Check file created", file.exists() );
+        File tempFile = new File( file.getParentFile(), file.getName() + ".sha1.tmp" );
+        assertFalse( "Check temporary file removed", tempFile.exists() );
+    }
+
+    public void testGetRemovesTemporaryChecksumFileOnError()
+        throws ResourceDoesNotExistException, ProxyException, IOException, TransferFailedException,
+        AuthorizationException
+    {
+        String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+
+        assertFalse( expectedFile.exists() );
+
+        proxiedRepository1 = createRepository( "proxied1", "test://..." );
+        proxiedRepositories.clear();
+        ProxiedArtifactRepository proxiedArtifactRepository1 = createProxiedRepository( proxiedRepository1 );
+        proxiedRepositories.add( proxiedArtifactRepository1 );
+
+        wagonMock.get( path, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) );
+
+        mockFailedChecksums( path, expectedFile );
+
+        wagonMockControl.replay();
+
+        try
+        {
+            File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
+            fail( "Found file: " + file + "; but was expecting a failure" );
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            // as expected
+            wagonMockControl.verify();
+
+            File tempFile = new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" );
+            assertFalse( "Check temporary file removed", tempFile.exists() );
+
+            tempFile = new File( expectedFile.getParentFile(), expectedFile.getName() + ".sha1.tmp" );
+            assertFalse( "Check temporary file removed", tempFile.exists() );
+        }
+    }
+
+    public void testGetChecksumBothCorrect()
+        throws ResourceDoesNotExistException, ProxyException, IOException
+    {
+        String path = "org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+
+        assertFalse( expectedFile.exists() );
+
+        File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
+
+        assertEquals( "Check file matches", expectedFile, file );
+        assertTrue( "Check file created", file.exists() );
+
+        File checksumFile = getChecksumFile( file, "sha1" );
+        assertTrue( "Check file created", checksumFile.exists() );
+        assertEquals( "Check checksum", "066d76e459f7782c312c31e8a11b3c0f1e3e43a7 *get-checksum-both-right-1.0.jar",
+                      FileUtils.fileRead( checksumFile ).trim() );
+
+        assertFalse( "Check file not created", getChecksumFile( file, "md5" ).exists() );
+    }
+
+    public void testGetCorrectSha1NoMd5()
+        throws ResourceDoesNotExistException, ProxyException, IOException
+    {
+        String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+
+        assertFalse( expectedFile.exists() );
+
+        File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
+
+        assertEquals( "Check file matches", expectedFile, file );
+        assertTrue( "Check file created", file.exists() );
+
+        File checksumFile = getChecksumFile( file, "sha1" );
+        assertTrue( "Check file created", checksumFile.exists() );
+        assertEquals( "Check checksum", "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
+                      FileUtils.fileRead( checksumFile ).trim() );
+
+        assertFalse( "Check file not created", getChecksumFile( file, "md5" ).exists() );
+    }
+
+    public void testGetCorrectSha1BadMd5()
+        throws ResourceDoesNotExistException, ProxyException, IOException
+    {
+        String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+
+        assertFalse( expectedFile.exists() );
+
+        File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
+
+        assertEquals( "Check file matches", expectedFile, file );
+        assertTrue( "Check file created", file.exists() );
+
+        File checksumFile = getChecksumFile( file, "sha1" );
+        assertTrue( "Check file created", checksumFile.exists() );
+        assertEquals( "Check checksum", "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar",
+                      FileUtils.fileRead( checksumFile ).trim() );
+
+        assertFalse( "Check file not created", getChecksumFile( file, "md5" ).exists() );
+    }
+
+    public void testGetCorrectMd5NoSha1()
+        throws ResourceDoesNotExistException, ProxyException, IOException
+    {
+        String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+
+        assertFalse( expectedFile.exists() );
+
+        File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
+
+        assertEquals( "Check file matches", expectedFile, file );
+        assertTrue( "Check file created", file.exists() );
+
+        File checksumFile = getChecksumFile( file, "md5" );
+        assertTrue( "Check file created", checksumFile.exists() );
+        assertEquals( "Check checksum", "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar",
+                      FileUtils.fileRead( checksumFile ).trim() );
+
+        assertFalse( "Check file not created", getChecksumFile( file, "sha1" ).exists() );
+    }
+
+    public void testGetCorrectMd5BadSha1()
+        throws ResourceDoesNotExistException, ProxyException, IOException
+    {
+        String path = "org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+
+        assertFalse( expectedFile.exists() );
+
+        File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
+
+        assertEquals( "Check file matches", expectedFile, file );
+        assertTrue( "Check file created", file.exists() );
+
+        File checksumFile = getChecksumFile( file, "md5" );
+        assertTrue( "Check file created", checksumFile.exists() );
+        assertEquals( "Check checksum", "8a02aa67549d27b2a03cd4547439c6d3 *get-checksum-md5-bad-sha1-1.0.jar",
+                      FileUtils.fileRead( checksumFile ).trim() );
+
+        assertFalse( "Check file not created", getChecksumFile( file, "sha1" ).exists() );
+    }
+
+    public void testGetWithNoChecksums()
+        throws ResourceDoesNotExistException, ProxyException, IOException
+    {
+        String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+
+        assertFalse( expectedFile.exists() );
+
+        File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
+
+        assertEquals( "Check file matches", expectedFile, file );
+        assertTrue( "Check file created", file.exists() );
+
+        assertFalse( "Check file not created", getChecksumFile( file, "md5" ).exists() );
+        assertFalse( "Check file not created", getChecksumFile( file, "sha1" ).exists() );
+    }
+
+    public void testGetBadMd5BadSha1()
+        throws ResourceDoesNotExistException, ProxyException, IOException
+    {
+        String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+
+        assertFalse( expectedFile.exists() );
+
+        try
+        {
+            File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
+            fail( "Found file: " + file + "; but was expecting a failure" );
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            // expect a failure
+            assertFalse( "Check file not created", expectedFile.exists() );
+
+            assertFalse( "Check file not created", getChecksumFile( expectedFile, "md5" ).exists() );
+            assertFalse( "Check file not created", getChecksumFile( expectedFile, "sha1" ).exists() );
+        }
+    }
+
+    public void testGetChecksumTransferFailed()
+        throws ResourceDoesNotExistException, ProxyException, IOException, TransferFailedException,
+        AuthorizationException
+    {
+        String path = "org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+
+        assertFalse( expectedFile.exists() );
+
+        proxiedRepository1 = createRepository( "proxied1", "test://..." );
+        proxiedRepositories.clear();
+        ProxiedArtifactRepository proxiedArtifactRepository1 = createProxiedRepository( proxiedRepository1 );
+        proxiedRepositories.add( proxiedArtifactRepository1 );
+
+        wagonMock.get( path, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) );
+
+        mockFailedChecksums( path, expectedFile );
+
+        wagonMockControl.replay();
+
+        try
+        {
+            File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
+            fail( "Found file: " + file + "; but was expecting a failure" );
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            // as expected
+            wagonMockControl.verify();
+
+            assertFalse( "Check file not created", expectedFile.exists() );
+
+            assertFalse( "Check file not created", getChecksumFile( expectedFile, "md5" ).exists() );
+            assertFalse( "Check file not created", getChecksumFile( expectedFile, "sha1" ).exists() );
+        }
+    }
+
+    private void mockFailedChecksums( String path, File expectedFile )
+        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+    {
+        // must do it twice as it will re-attempt it
+        wagonMock.get( path + ".sha1", new File( expectedFile.getParentFile(), expectedFile.getName() + ".sha1.tmp" ) );
+        wagonMockControl.setThrowable( new TransferFailedException( "transfer failed" ) );
+
+        wagonMock.get( path + ".md5", new File( expectedFile.getParentFile(), expectedFile.getName() + ".md5.tmp" ) );
+        wagonMockControl.setThrowable( new TransferFailedException( "transfer failed" ) );
+
+        wagonMock.get( path + ".sha1", new File( expectedFile.getParentFile(), expectedFile.getName() + ".sha1.tmp" ) );
+        wagonMockControl.setThrowable( new TransferFailedException( "transfer failed" ) );
+
+        wagonMock.get( path + ".md5", new File( expectedFile.getParentFile(), expectedFile.getName() + ".md5.tmp" ) );
+        wagonMockControl.setThrowable( new TransferFailedException( "transfer failed" ) );
+    }
+
+    public void testGetAlwaysBadChecksumPresentLocallyAbsentRemote()
+        throws ResourceDoesNotExistException, ProxyException, IOException
+    {
+        String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
+        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
+        String unexpectedContents = FileUtils.fileRead( expectedFile );
+
+        assertTrue( expectedFile.exists() );
+
+        File file = requestHandler.getAlways( path, proxiedRepositories, defaultManagedRepository );
+
+        assertEquals( "Check file matches", expectedFile, file );
+        assertTrue( "Check file created", file.exists() );
+        File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
+        String expectedContents = FileUtils.fileRead( proxiedFile );
+        assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+        assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+
+        assertFalse( "Check checksum removed", new File( file.getParentFile(), file.getName() + ".sha1" ).exists() );
+        assertFalse( "Check checksum removed", new File( file.getParentFile(), file.getName() + ".md5" ).exists() );
+    }
+
+    private File getChecksumFile( File file, String algorithm )
+    {
+        return new File( file.getParentFile(), file.getName() + "." + algorithm );
     }
 
     /**

Modified: maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/WagonDelegate.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/WagonDelegate.java?rev=431275&r1=431274&r2=431275&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/WagonDelegate.java (original)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/WagonDelegate.java Sun Aug 13 17:52:42 2006
@@ -16,19 +16,21 @@
  * limitations under the License.
  */
 
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.authorization.AuthorizationException;
 import org.apache.maven.wagon.events.SessionListener;
 import org.apache.maven.wagon.events.TransferListener;
 import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
 import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.codehaus.plexus.util.FileUtils;
 
 import java.io.File;
+import java.io.IOException;
 
 /**
  * A dummy wagon implementation
@@ -40,16 +42,21 @@
 {
     private Wagon delegate;
 
+    private String contentToGet;
+
     public void get( String resourceName, File destination )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
         delegate.get( resourceName, destination );
+        create( destination );
     }
 
     public boolean getIfNewer( String resourceName, File destination, long timestamp )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
-        return delegate.getIfNewer( resourceName, destination, timestamp );
+        boolean result = delegate.getIfNewer( resourceName, destination, timestamp );
+        createIfMissing( destination );
+        return result;
     }
 
     public void put( File source, String destination )
@@ -153,5 +160,39 @@
     public void setDelegate( Wagon delegate )
     {
         this.delegate = delegate;
+    }
+
+    void setContentToGet( String content )
+    {
+        contentToGet = content;
+    }
+
+    private void createIfMissing( File destination )
+    {
+        // since the mock won't actually copy a file, create an empty one to simulate file existence
+        if ( !destination.exists() )
+        {
+            create( destination );
+        }
+    }
+
+    private void create( File destination )
+    {
+        try
+        {
+            destination.getParentFile().mkdirs();
+            if ( contentToGet == null )
+            {
+                destination.createNewFile();
+            }
+            else
+            {
+                FileUtils.fileWrite( destination.getAbsolutePath(), contentToGet );
+            }
+        }
+        catch ( IOException e )
+        {
+            throw new RuntimeException( e.getMessage(), e );
+        }
     }
 }

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar Sun Aug 13 17:52:42 2006
@@ -0,0 +1,3 @@
+get-bad-local-checksum-1.0.jar
+(managed)
+

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar.md5
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar.md5?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar.md5 (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar.md5 Sun Aug 13 17:52:42 2006
@@ -0,0 +1 @@
+invalid checksum file
\ No newline at end of file

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar.sha1
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar.sha1?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar.sha1 (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar.sha1 Sun Aug 13 17:52:42 2006
@@ -0,0 +1 @@
+invalid checksum file
\ No newline at end of file

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-removed-from-proxies/1.0/get-removed-from-proxies-1.0.jar
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-removed-from-proxies/1.0/get-removed-from-proxies-1.0.jar?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-removed-from-proxies/1.0/get-removed-from-proxies-1.0.jar (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/managed/org/apache/maven/test/get-removed-from-proxies/1.0/get-removed-from-proxies-1.0.jar Sun Aug 13 17:52:42 2006
@@ -0,0 +1,3 @@
+get-removed-from-proxies-1.0.jar
+(managed)
+

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar Sun Aug 13 17:52:42 2006
@@ -0,0 +1,3 @@
+get-bad-local-checksum-1.0.jar
+(proxied 1)
+

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar Sun Aug 13 17:52:42 2006
@@ -0,0 +1,2 @@
+get-checksum-both-bad-1.0.jar
+

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar.md5
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar.md5?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar.md5 (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar.md5 Sun Aug 13 17:52:42 2006
@@ -0,0 +1 @@
+invalid checksum file
\ No newline at end of file

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar.sha1
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar.sha1?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar.sha1 (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar.sha1 Sun Aug 13 17:52:42 2006
@@ -0,0 +1 @@
+invalid checksum file

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar Sun Aug 13 17:52:42 2006
@@ -0,0 +1 @@
+get-checksum-both-right-1.0.jar

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar.md5
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar.md5?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar.md5 (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar.md5 Sun Aug 13 17:52:42 2006
@@ -0,0 +1 @@
+e58f30c6a150a2e843552438d18e15cb *get-checksum-both-right-1.0.jar
\ No newline at end of file

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar.sha1
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar.sha1?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar.sha1 (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar.sha1 Sun Aug 13 17:52:42 2006
@@ -0,0 +1 @@
+066d76e459f7782c312c31e8a11b3c0f1e3e43a7 *get-checksum-both-right-1.0.jar

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar Sun Aug 13 17:52:42 2006
@@ -0,0 +1,2 @@
+get-checksum-md5-bad-sha1-1.0.jar
+

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar.md5
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar.md5?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar.md5 (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar.md5 Sun Aug 13 17:52:42 2006
@@ -0,0 +1 @@
+8a02aa67549d27b2a03cd4547439c6d3 *get-checksum-md5-bad-sha1-1.0.jar
\ No newline at end of file

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar.sha1
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar.sha1?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar.sha1 (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-bad-sha1/1.0/get-checksum-md5-bad-sha1-1.0.jar.sha1 Sun Aug 13 17:52:42 2006
@@ -0,0 +1 @@
+invalid checksum file

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar Sun Aug 13 17:52:42 2006
@@ -0,0 +1,2 @@
+get-checksum-md5-only-1.0.jar
+

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar.md5
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar.md5?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar.md5 (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar.md5 Sun Aug 13 17:52:42 2006
@@ -0,0 +1 @@
+f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar Sun Aug 13 17:52:42 2006
@@ -0,0 +1,2 @@
+get-checksum-sha1-bad-md5-1.0.jar
+

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar.md5
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar.md5?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar.md5 (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar.md5 Sun Aug 13 17:52:42 2006
@@ -0,0 +1 @@
+invalid checksum file

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar.sha1
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar.sha1?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar.sha1 (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar.sha1 Sun Aug 13 17:52:42 2006
@@ -0,0 +1 @@
+3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar Sun Aug 13 17:52:42 2006
@@ -0,0 +1,2 @@
+get-checksum-sha1-only-1.0.jar
+

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar.sha1
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar.sha1?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar.sha1 (added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/repositories/proxied1/org/apache/maven/test/get-checksum-sha1-only/1.0/get-checksum-sha1-only-1.0.jar.sha1 Sun Aug 13 17:52:42 2006
@@ -0,0 +1 @@
+748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar

Modified: maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/AbstractDigester.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/AbstractDigester.java?rev=431275&r1=431274&r2=431275&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/AbstractDigester.java (original)
+++ maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/AbstractDigester.java Sun Aug 13 17:52:42 2006
@@ -23,8 +23,6 @@
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.security.NoSuchAlgorithmException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 /**
  * Create a digest for a file.
@@ -72,36 +70,8 @@
     public void verify( File file, String checksum )
         throws DigesterException
     {
-        String trimmedChecksum = checksum.replace( '\n', ' ' ).trim();
-
-        String algorithm = streamingDigester.getAlgorithm();
-
-        // Free-BSD / openssl
-        Matcher m = Pattern.compile( algorithm.replaceAll( "-", "" ) + "\\s*\\((.*?)\\)\\s*=\\s*([a-zA-Z0-9]+)" )
-            .matcher( trimmedChecksum );
-        if ( m.matches() )
-        {
-            String filename = m.group( 1 );
-            if ( !filename.equals( file.getName() ) )
-            {
-                throw new DigesterException( "Supplied checksum does not match checksum pattern" );
-            }
-            trimmedChecksum = m.group( 2 );
-        }
-        else
-        {
-            // GNU tools
-            m = Pattern.compile( "([a-zA-Z0-9]+)\\s\\*?(.+)" ).matcher( trimmedChecksum );
-            if ( m.matches() )
-            {
-                String filename = m.group( 2 );
-                if ( !filename.equals( file.getName() ) )
-                {
-                    throw new DigesterException( "Supplied checksum does not match checksum pattern" );
-                }
-                trimmedChecksum = m.group( 1 );
-            }
-        }
+        String trimmedChecksum =
+            DigestUtils.cleanChecksum( checksum, streamingDigester.getAlgorithm(), file.getName() );
 
         //Create checksum for jar file
         String sum = calc( file );

Added: maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/DigestUtils.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/DigestUtils.java?rev=431275&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/DigestUtils.java (added)
+++ maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/DigestUtils.java Sun Aug 13 17:52:42 2006
@@ -0,0 +1,67 @@
+package org.apache.maven.repository.digest;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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 java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Parse files from checksum file formats.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class DigestUtils
+{
+    private DigestUtils()
+    {
+        // don't create this class
+    }
+
+    public static String cleanChecksum( String checksum, String algorithm, String path )
+        throws DigesterException
+    {
+        String trimmedChecksum = checksum.replace( '\n', ' ' ).trim();
+
+        // Free-BSD / openssl
+        String regex = algorithm.replaceAll( "-", "" ) + "\\s*\\((.*?)\\)\\s*=\\s*([a-fA-F0-9]+)";
+        Matcher m = Pattern.compile( regex ).matcher( trimmedChecksum );
+        if ( m.matches() )
+        {
+            String filename = m.group( 1 );
+            if ( !path.endsWith( filename ) )
+            {
+                throw new DigesterException( "Supplied checksum does not match checksum pattern" );
+            }
+            trimmedChecksum = m.group( 2 );
+        }
+        else
+        {
+            // GNU tools
+            m = Pattern.compile( "([a-fA-F0-9]+)\\s\\*?(.+)" ).matcher( trimmedChecksum );
+            if ( m.matches() )
+            {
+                String filename = m.group( 2 );
+                if ( !path.endsWith( filename ) )
+                {
+                    throw new DigesterException( "Supplied checksum does not match checksum pattern" );
+                }
+                trimmedChecksum = m.group( 1 );
+            }
+        }
+        return trimmedChecksum;
+    }
+}

Propchange: maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/DigestUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/repository-manager/trunk/maven-repository-utils/src/main/java/org/apache/maven/repository/digest/DigestUtils.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message