You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by jo...@apache.org on 2007/04/17 16:12:37 UTC

svn commit: r529617 [2/2] - in /maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-proxy/src: main/java/org/apache/maven/archiva/proxy/ test/java/org/apache/maven/archiva/proxy/ test/resources/org/apache/maven/archiva/proxy/

Modified: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java?view=diff&rev=529617&r1=529616&r2=529617
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java Tue Apr 17 07:12:36 2007
@@ -19,8 +19,15 @@
  * under the License.
  */
 
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.model.ArtifactReference;
+import org.apache.maven.archiva.policies.CachedFailuresPolicy;
+import org.apache.maven.archiva.policies.ChecksumPolicy;
+import org.apache.maven.archiva.policies.ReleasesPolicy;
+import org.apache.maven.archiva.policies.SnapshotsPolicy;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 
+import java.io.File;
 import java.io.IOException;
 import java.text.ParseException;
 
@@ -35,286 +42,259 @@
     extends AbstractProxyTestCase
 {
     public void testSnapshotNonExistant()
+        throws Exception
     {
         String path = "org/apache/maven/test/does-not-exist/1.0-SNAPSHOT/does-not-exist-1.0-SNAPSHOT.jar";
-        fail( "Implemented " + getName() );
+        File expectedFile = new File( managedDefaultDir, path );
+        ArtifactReference artifact = createArtifactReference( "default", path );
+
+        expectedFile.delete();
+        assertFalse( expectedFile.exists() );
 
-        //        String path = "org/apache/maven/test/does-not-exist/1.0-SNAPSHOT/does-not-exist-1.0-SNAPSHOT.jar";
-        //        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
-        //
-        //        assertFalse( expectedFile.exists() );
-        //
-        //        try
-        //        {
-        //            File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
-        //            fail( "File returned was: " + file + "; should have got a not found exception" );
-        //        }
-        //        catch ( ResourceDoesNotExistException e )
-        //        {
-        //            // expected, but check file was not created
-        //            assertFalse( expectedFile.exists() );
-        //        }        
+        // Configure Connector (usually done within archiva.xml configuration)
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
+
+        File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
+        assertNotDownloaded( downloadedFile );
+        assertNoTempFiles( expectedFile );
     }
 
     public void testTimestampDrivenSnapshotNotPresentAlready()
+        throws Exception
     {
-        String path = "org/apache/maven/test/does-not-exist/1.0-SNAPSHOT/does-not-exist-1.0-SNAPSHOT.jar";
-        fail( "Implemented " + getName() );
-
-        //        String path =
-        //            "org/apache/maven/test/get-timestamped-snapshot/1.0-SNAPSHOT/get-timestamped-snapshot-1.0-SNAPSHOT.jar";
-        //        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
-        //
-        //        expectedFile.delete();
-        //        assertFalse( expectedFile.exists() );
-        //
-        //        File file = requestHandler.get( 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.readFileToString( proxiedFile, null );
-        //        assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
+        String path = "org/apache/maven/test/get-timestamped-snapshot/1.0-SNAPSHOT/get-timestamped-snapshot-1.0-SNAPSHOT.jar";
+        File expectedFile = new File( managedDefaultDir, path );
+        ArtifactReference artifact = createArtifactReference( "default", path );
+
+        expectedFile.delete();
+        assertFalse( expectedFile.exists() );
+
+        // Configure Connector (usually done within archiva.xml configuration)
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
+
+        File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
+
+        File proxiedFile = new File( REPOPATH_PROXIED1, path );
+        assertFileEquals( expectedFile, downloadedFile, proxiedFile );
+        assertNoTempFiles( expectedFile );
     }
 
     public void testNewerTimestampDrivenSnapshotOnFirstRepo()
-        throws ResourceDoesNotExistException, ProxyException, IOException, ParseException
+        throws Exception
     {
-        fail( "Implemented " + getName() );
-
-        //        String path = "org/apache/maven/test/get-present-timestamped-snapshot/1.0-SNAPSHOT/get-present-timestamped-snapshot-1.0-SNAPSHOT.jar";
-        //        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
-        //
-        //        assertTrue( expectedFile.exists() );
-        //
-        //        expectedFile.setLastModified( getPastDate().getTime() );
-        //
-        //        File file = requestHandler.get( 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.readFileToString( proxiedFile, null );
-        //        assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
+        String path = "org/apache/maven/test/get-present-timestamped-snapshot/1.0-SNAPSHOT/get-present-timestamped-snapshot-1.0-SNAPSHOT.jar";
+        File expectedFile = new File( managedDefaultDir, path );
+        ArtifactReference artifact = createArtifactReference( "default", path );
+
+        assertTrue( expectedFile.exists() );
+        expectedFile.setLastModified( getPastDate().getTime() );
+
+        // Configure Connector (usually done within archiva.xml configuration)
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
+
+        File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
+
+        File proxiedFile = new File( REPOPATH_PROXIED1, path );
+        assertFileEquals( expectedFile, downloadedFile, proxiedFile );
+        assertNoTempFiles( expectedFile );
     }
 
     public void testOlderTimestampDrivenSnapshotOnFirstRepo()
-        throws ResourceDoesNotExistException, ProxyException, IOException
+        throws Exception
     {
-        fail( "Implemented " + getName() );
-
-        //        String path = "org/apache/maven/test/get-present-timestamped-snapshot/1.0-SNAPSHOT/get-present-timestamped-snapshot-1.0-SNAPSHOT.jar";
-        //        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
-        //        String expectedContents = FileUtils.readFileToString( expectedFile, null );
-        //
-        //        assertTrue( expectedFile.exists() );
-        //
-        //        expectedFile.setLastModified( getFutureDate().getTime() );
-        //
-        //        proxiedRepository1.getSnapshots().setUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS );
-        //        File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
-        //
-        //        assertEquals( "Check file matches", expectedFile, file );
-        //        assertTrue( "Check file created", file.exists() );
-        //        assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
-        //
-        //        File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
-        //        String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
-        //        assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
+        String path = "org/apache/maven/test/get-present-timestamped-snapshot/1.0-SNAPSHOT/get-present-timestamped-snapshot-1.0-SNAPSHOT.jar";
+        File expectedFile = new File( managedDefaultDir, path );
+        ArtifactReference artifact = createArtifactReference( "default", path );
+
+        assertTrue( expectedFile.exists() );
+        expectedFile.setLastModified( getFutureDate().getTime() );
+
+        // Configure Connector (usually done within archiva.xml configuration)
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
+
+        File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
+
+        File proxiedFile = new File( REPOPATH_PROXIED1, path );
+        assertFileEquals( expectedFile, downloadedFile, proxiedFile );
+        assertNoTempFiles( expectedFile );
     }
 
+    /**
+     * TODO: Has problems with wagon implementation not preserving timestamp.
+     */
     public void testNewerTimestampDrivenSnapshotOnSecondRepoThanFirstNotPresentAlready()
         throws Exception
     {
-        // TODO: wagon may not support timestamps (yet)
-        fail( "Implemented " + getName() );
-
-        //        String path = "org/apache/maven/test/get-timestamped-snapshot-in-both/1.0-SNAPSHOT/get-timestamped-snapshot-in-both-1.0-SNAPSHOT.jar";
-        //        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
-        //
-        //        assertFalse( expectedFile.exists() );
-        //
-        //        File repoLocation = getTestFile( "target/test-repository/proxied1" );
-        //        FileUtils.deleteDirectory( repoLocation );
-        //        copyDirectoryStructure( getTestFile( "src/test/repositories/proxied1" ), repoLocation );
-        //        proxiedRepository1 = createRepository( "proxied1", repoLocation );
-        //
-        //        new File( proxiedRepository1.getBasedir(), path ).setLastModified( getPastDate().getTime() );
-        //
-        //        proxiedRepositories.clear();
-        //        proxiedRepositories.add( createProxiedRepository( proxiedRepository1 ) );
-        //        proxiedRepositories.add( createProxiedRepository( proxiedRepository2 ) );
-        //
-        //        File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
-        //
-        //        assertEquals( "Check file matches", expectedFile, file );
-        //        assertTrue( "Check file created", file.exists() );
-        //
-        //        File proxiedFile = new File( proxiedRepository2.getBasedir(), path );
-        //        String expectedContents = FileUtils.readFileToString( proxiedFile, null );
-        //        assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
-        //
-        //        proxiedFile = new File( proxiedRepository1.getBasedir(), path );
-        //        String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
-        //        assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
+        String path = "org/apache/maven/test/get-timestamped-snapshot-in-both/1.0-SNAPSHOT/get-timestamped-snapshot-in-both-1.0-SNAPSHOT.jar";
+        File expectedFile = new File( managedDefaultDir, path );
+        ArtifactReference artifact = createArtifactReference( "default", path );
+
+        expectedFile.delete();
+        assertFalse( expectedFile.exists() );
+
+        // Create customized proxy / target repository
+        File targetProxyDir = saveTargetedRepositoryConfig( ID_PROXIED1_TARGET, REPOPATH_PROXIED1,
+                                                            REPOPATH_PROXIED1_TARGET, "default" );
+
+        new File( targetProxyDir, path ).setLastModified( getPastDate().getTime() );
+
+        // Configure Connector (usually done within archiva.xml configuration)
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1_TARGET, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
+
+        File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
+
+        // Should have downloaded the content from proxy2, as proxy1 has an old (by file.lastModified check) version.
+        File proxiedFile = new File( REPOPATH_PROXIED2, path );
+        assertFileEquals( expectedFile, downloadedFile, proxiedFile );
+        assertNoTempFiles( expectedFile );
     }
 
     public void testOlderTimestampDrivenSnapshotOnSecondRepoThanFirstNotPresentAlready()
         throws Exception
     {
-        fail( "Implemented " + getName() );
-
-        //        String path = "org/apache/maven/test/get-timestamped-snapshot-in-both/1.0-SNAPSHOT/get-timestamped-snapshot-in-both-1.0-SNAPSHOT.jar";
-        //        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
-        //
-        //        expectedFile.delete();
-        //        assertFalse( expectedFile.exists() );
-        //
-        //        File repoLocation = getTestFile( "target/test-repository/proxied2" );
-        //        FileUtils.deleteDirectory( repoLocation );
-        //        copyDirectoryStructure( getTestFile( "src/test/repositories/proxied2" ), repoLocation );
-        //        proxiedRepository2 = createRepository( "proxied2", repoLocation );
-        //
-        //        new File( proxiedRepository2.getBasedir(), path ).setLastModified( getPastDate().getTime() );
-        //
-        //        proxiedRepositories.clear();
-        //        proxiedRepositories.add( createProxiedRepository( proxiedRepository1 ) );
-        //        proxiedRepositories.add( createProxiedRepository( proxiedRepository2 ) );
-        //
-        //        File file = requestHandler.get( 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.readFileToString( proxiedFile, null );
-        //        assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
-        //
-        //        proxiedFile = new File( proxiedRepository2.getBasedir(), path );
-        //        String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
-        //        assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
+        String path = "org/apache/maven/test/get-timestamped-snapshot-in-both/1.0-SNAPSHOT/get-timestamped-snapshot-in-both-1.0-SNAPSHOT.jar";
+        File expectedFile = new File( managedDefaultDir, path );
+        ArtifactReference artifact = createArtifactReference( "default", path );
+
+        expectedFile.delete();
+        assertFalse( expectedFile.exists() );
+
+        // Create customized proxy / target repository
+        File targetProxyDir = saveTargetedRepositoryConfig( ID_PROXIED2_TARGET, REPOPATH_PROXIED2,
+                                                            REPOPATH_PROXIED2_TARGET, "default" );
+
+        new File( targetProxyDir, path ).setLastModified( getPastDate().getTime() );
+
+        // Configure Connector (usually done within archiva.xml configuration)
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2_TARGET, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
+
+        File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
+
+        File proxiedFile = new File( REPOPATH_PROXIED1_TARGET, path );
+        assertFileEquals( expectedFile, downloadedFile, proxiedFile );
+        assertNoTempFiles( expectedFile );
     }
 
     public void testTimestampDrivenSnapshotNotExpired()
         throws Exception
     {
-        fail( "Implemented " + getName() );
+        String path = "org/apache/maven/test/get-present-timestamped-snapshot/1.0-SNAPSHOT/get-present-timestamped-snapshot-1.0-SNAPSHOT.jar";
+        File expectedFile = new File( managedDefaultDir, path );
+        ArtifactReference artifact = createArtifactReference( "default", path );
+
+        assertTrue( expectedFile.exists() );
+
+        File proxiedFile = new File( REPOPATH_PROXIED1, path );
+        proxiedFile.setLastModified( getFutureDate().getTime() );
+
+        // Configure Connector (usually done within archiva.xml configuration)
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
+
+        File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
 
-        //        String path = "org/apache/maven/test/get-present-timestamped-snapshot/1.0-SNAPSHOT/get-present-timestamped-snapshot-1.0-SNAPSHOT.jar";
-        //        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
-        //
-        //        assertTrue( expectedFile.exists() );
-        //
-        //        File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
-        //        proxiedFile.setLastModified( getFutureDate().getTime() );
-        //
-        //        File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
-        //
-        //        assertEquals( "Check file matches", expectedFile, file );
-        //        assertTrue( "Check file created", file.exists() );
-        //        String expectedContents = FileUtils.readFileToString( expectedFile, null );
-        //        assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
-        //
-        //        String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
-        //        assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
+        assertFileEquals( expectedFile, downloadedFile, proxiedFile );
+        assertNoTempFiles( expectedFile );
     }
 
     public void testTimestampDrivenSnapshotNotUpdated()
         throws Exception
     {
-        fail( "Implemented " + getName() );
+        String path = "org/apache/maven/test/get-present-timestamped-snapshot/1.0-SNAPSHOT/get-present-timestamped-snapshot-1.0-SNAPSHOT.jar";
+        File expectedFile = new File( managedDefaultDir, path );
+        ArtifactReference artifact = createArtifactReference( "default", path );
 
-        //        String path = "org/apache/maven/test/get-present-timestamped-snapshot/1.0-SNAPSHOT/get-present-timestamped-snapshot-1.0-SNAPSHOT.jar";
-        //        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
-        //        String expectedContents = FileUtils.readFileToString( expectedFile, null );
-        //
-        //        assertTrue( expectedFile.exists() );
-        //
-        //        File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
-        //        expectedFile.setLastModified( proxiedFile.lastModified() );
-        //
-        //        proxiedRepository1.getSnapshots().setUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS );
-        //        File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
-        //
-        //        assertEquals( "Check file matches", expectedFile, file );
-        //        assertTrue( "Check file created", file.exists() );
-        //        assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
-        //
-        //        String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
-        //        assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
+        assertTrue( expectedFile.exists() );
+
+        File proxiedFile = new File( REPOPATH_PROXIED1, path );
+        expectedFile.setLastModified( proxiedFile.lastModified() );
+
+        // Configure Connector (usually done within archiva.xml configuration)
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
+
+        File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
+
+        assertFileEquals( expectedFile, downloadedFile, proxiedFile );
+        assertNoTempFiles( expectedFile );
     }
 
     public void testTimestampDrivenSnapshotNotPresentAlreadyExpiredCacheFailure()
-        throws ResourceDoesNotExistException, ProxyException, IOException
+        throws Exception
     {
-        fail( "Implemented " + getName() );
-
-        //        String path = "org/apache/maven/test/get-timestamped-snapshot/1.0-SNAPSHOT/get-timestamped-snapshot-1.0-SNAPSHOT.jar";
-        //        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
-        //
-        //        expectedFile.delete();
-        //        assertFalse( expectedFile.exists() );
-        //
-        //        proxiedRepositories.clear();
-        //        ProxiedArtifactRepository proxiedArtifactRepository = createProxiedRepository( proxiedRepository1 );
-        //        proxiedArtifactRepository.addFailure( path, ALWAYS_UPDATE_POLICY );
-        //        proxiedRepositories.add( proxiedArtifactRepository );
-        //        proxiedRepositories.add( createProxiedRepository( proxiedRepository2 ) );
-        //        File file = requestHandler.get( 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.readFileToString( proxiedFile, null );
-        //        assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
-        //
-        //        assertFalse( "Check failure", proxiedArtifactRepository.isCachedFailure( path ) );
+        String path = "org/apache/maven/test/get-timestamped-snapshot/1.0-SNAPSHOT/get-timestamped-snapshot-1.0-SNAPSHOT.jar";
+        File expectedFile = new File( managedDefaultDir, path );
+        ArtifactReference artifact = createArtifactReference( "default", path );
+
+        expectedFile.delete();
+        assertFalse( expectedFile.exists() );
+
+        // Configure Connector (usually done within archiva.xml configuration)
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.CACHED );
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.CACHED );
+
+        File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
+
+        File proxiedFile = new File( REPOPATH_PROXIED1, path );
+        assertFileEquals( expectedFile, downloadedFile, proxiedFile );
+        assertNoTempFiles( expectedFile );
     }
 
     public void testMetadataDrivenSnapshotNotPresentAlready()
-        throws ResourceDoesNotExistException, ProxyException, IOException
+        throws Exception
     {
-        fail( "Implemented " + getName() );
-
-        //        String path = "org/apache/maven/test/get-metadata-snapshot/1.0-SNAPSHOT/get-metadata-snapshot-1.0-20050831.101112-1.jar";
-        //        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
-        //
-        //        expectedFile.delete();
-        //        assertFalse( expectedFile.exists() );
-        //
-        //        File file = requestHandler.get( 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.readFileToString( proxiedFile, null );
-        //        assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
+        String path = "org/apache/maven/test/get-metadata-snapshot/1.0-SNAPSHOT/get-metadata-snapshot-1.0-20050831.101112-1.jar";
+        File expectedFile = new File( managedDefaultDir, path );
+        ArtifactReference artifact = createArtifactReference( "default", path );
+
+        expectedFile.delete();
+        assertFalse( expectedFile.exists() );
+
+        // Configure Connector (usually done within archiva.xml configuration)
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
+
+        File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
+
+        File proxiedFile = new File( REPOPATH_PROXIED1, path );
+        assertFileEquals( expectedFile, downloadedFile, proxiedFile );
+        assertNoTempFiles( expectedFile );
     }
 
     public void testGetMetadataDrivenSnapshotRemoteUpdate()
-        throws ResourceDoesNotExistException, ProxyException, IOException, ParseException
+        throws Exception
     {
-        fail( "Implemented " + getName() );
-
-        // Metadata driven snapshots (using a full timestamp) are treated like a release. It is the timing of the
+         // Metadata driven snapshots (using a full timestamp) are treated like a release. It is the timing of the
         // updates to the metadata files that triggers which will be downloaded
 
-        //        String path = "org/apache/maven/test/get-present-metadata-snapshot/1.0-SNAPSHOT/get-present-metadata-snapshot-1.0-20050831.101112-1.jar";
-        //        File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
-        //        String expectedContents = FileUtils.readFileToString( expectedFile, null );
-        //
-        //        assertTrue( expectedFile.exists() );
-        //
-        //        expectedFile.setLastModified( getPastDate().getTime() );
-        //
-        //        File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
-        //
-        //        assertEquals( "Check file matches", expectedFile, file );
-        //        assertTrue( "Check file created", file.exists() );
-        //        assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
-        //        File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
-        //        String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
-        //        assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
+        String path = "org/apache/maven/test/get-present-metadata-snapshot/1.0-SNAPSHOT/get-present-metadata-snapshot-1.0-20050831.101112-1.jar";
+        File expectedFile = new File( managedDefaultDir, path );
+        ArtifactReference artifact = createArtifactReference( "default", path );
+
+        assertTrue( expectedFile.exists() );
+
+        expectedFile.setLastModified( getPastDate().getTime() );
+
+        // Configure Connector (usually done within archiva.xml configuration)
+        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
+                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
+
+        File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
+
+        File proxiedFile = new File( REPOPATH_PROXIED1, path );
+        assertFileEquals( expectedFile, downloadedFile, proxiedFile );
+        assertNoTempFiles( expectedFile );
     }
 }

Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/RelocateTransferTest.xml
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/RelocateTransferTest.xml?view=auto&rev=529617
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/RelocateTransferTest.xml (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/RelocateTransferTest.xml Tue Apr 17 07:12:36 2007
@@ -0,0 +1,72 @@
+<!--
+  ~ 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.
+  -->
+
+<component-set>
+  <components>
+    <component>
+      <role>org.apache.maven.wagon.Wagon</role>
+      <role-hint>test</role-hint>
+      <implementation>org.apache.maven.archiva.proxy.WagonDelegate</implementation>
+    </component>
+    <component>
+      <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+      <role-hint>mock</role-hint>
+      <implementation>org.apache.maven.archiva.proxy.MockConfiguration</implementation>
+    </component>
+    <component>
+      <role>org.apache.maven.archiva.proxy.RepositoryProxyConnectors</role>
+      <role-hint>default</role-hint>
+      <implementation>org.apache.maven.archiva.proxy.DefaultRepositoryProxyConnectors</implementation>
+      <description>DefaultRepositoryProxyConnectors</description>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+          <role-hint>mock</role-hint>
+          <field-name>archivaConfiguration</field-name>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.wagon.Wagon</role>
+          <field-name>wagons</field-name>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory</role>
+          <field-name>layoutFactory</field-name>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role>
+          <field-name>preDownloadPolicies</field-name>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role>
+          <field-name>postDownloadPolicies</field-name>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.archiva.policies.urlcache.UrlFailureCache</role>
+          <role-hint>default</role-hint>
+          <field-name>urlFailureCache</field-name>
+        </requirement>
+      </requirements>
+    </component>
+    <component>
+      <role>org.codehaus.plexus.logging.LoggerManager</role>
+      <implementation>org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager</implementation>
+      <lifecycle-handler>basic</lifecycle-handler>
+    </component>
+  </components>
+</component-set>
\ No newline at end of file

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/RelocateTransferTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/RelocateTransferTest.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/RelocateTransferTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml