]> source.dussan.org Git - archiva.git/commitdiff
[MRM-797]
authorMaria Odea B. Ching <oching@apache.org>
Mon, 26 May 2008 08:42:10 +0000 (08:42 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Mon, 26 May 2008 08:42:10 +0000 (08:42 +0000)
-check for released versions of a snapshot across all releases repo
-add test

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@660126 13f79535-47bb-0310-9956-ffa450edef68

20 files changed:
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.xml
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.jar [new file with mode: 0644]
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.jar.md5 [new file with mode: 0644]
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.jar.sha1 [new file with mode: 0644]
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.pom [new file with mode: 0644]
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.pom.md5 [new file with mode: 0644]
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.pom.sha1 [new file with mode: 0644]
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.jar [new file with mode: 0644]
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.jar.md5 [new file with mode: 0644]
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.jar.sha1 [new file with mode: 0644]
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.pom [new file with mode: 0644]
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.pom.md5 [new file with mode: 0644]
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.pom.sha1 [new file with mode: 0644]

index 06654242401905f558d8af015b5223b4da08ded3..b9c1795a730aee0b3dc7f9ed559d317c2c896a72 100644 (file)
@@ -21,6 +21,8 @@ package org.apache.maven.archiva.consumers.core.repository;
 
 import org.apache.maven.archiva.common.utils.VersionComparator;
 import org.apache.maven.archiva.common.utils.VersionUtil;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.database.ArtifactDAO;
 import org.apache.maven.archiva.indexer.RepositoryContentIndex;
 import org.apache.maven.archiva.model.ArtifactReference;
@@ -28,6 +30,9 @@ import org.apache.maven.archiva.model.ProjectReference;
 import org.apache.maven.archiva.model.VersionedReference;
 import org.apache.maven.archiva.repository.ContentNotFoundException;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
+import org.apache.maven.archiva.repository.RepositoryContentFactory;
+import org.apache.maven.archiva.repository.RepositoryException;
+import org.apache.maven.archiva.repository.RepositoryNotFoundException;
 import org.apache.maven.archiva.repository.layout.LayoutException;
 import org.apache.maven.archiva.repository.metadata.MetadataTools;
 import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
@@ -68,12 +73,19 @@ public class CleanupReleasedSnapshotsRepositoryPurge
     extends AbstractRepositoryPurge
 {
     private MetadataTools metadataTools;
+    
+    private ArchivaConfiguration archivaConfig;
+    
+    private RepositoryContentFactory repoContentFactory;
 
     public CleanupReleasedSnapshotsRepositoryPurge( ManagedRepositoryContent repository, ArtifactDAO artifactDao,
-                    MetadataTools metadataTools, Map<String, RepositoryContentIndex> indices )
+                    MetadataTools metadataTools, Map<String, RepositoryContentIndex> indices, 
+                    ArchivaConfiguration archivaConfig, RepositoryContentFactory repoContentFactory )
     {
         super( repository, artifactDao, indices );
         this.metadataTools = metadataTools;
+        this.archivaConfig = archivaConfig;
+        this.repoContentFactory = repoContentFactory;
     }
 
     public void process( String path )
@@ -100,16 +112,37 @@ public class CleanupReleasedSnapshotsRepositoryPurge
             ProjectReference reference = new ProjectReference();
             reference.setGroupId( artifact.getGroupId() );
             reference.setArtifactId( artifact.getArtifactId() );
-
+            
             // Gather up all of the versions.
             List<String> allVersions = new ArrayList<String>( repository.getVersions( reference ) );
 
+            List<ManagedRepositoryConfiguration> repos = archivaConfig.getConfiguration().getManagedRepositories();
+            for( ManagedRepositoryConfiguration repo : repos )
+            {   
+                if( repo.isReleases() && !repo.getId().equals( repository.getId() ) )
+                {   
+                    try
+                    {   
+                        ManagedRepositoryContent repoContent = repoContentFactory.getManagedRepositoryContent( repo.getId() );                        
+                        allVersions.addAll( repoContent.getVersions( reference ) );
+                    }
+                    catch( RepositoryNotFoundException  e )
+                    {
+                        // swallow
+                    }
+                    catch( RepositoryException  e )
+                    {
+                        // swallow
+                    }
+                }
+            }
+
             // Split the versions into released and snapshots.
             List<String> releasedVersions = new ArrayList<String>();
             List<String> snapshotVersions = new ArrayList<String>();
 
             for ( String version : allVersions )
-            {
+            {   
                 if ( VersionUtil.isSnapshot( version ) )
                 {
                     snapshotVersions.add( version );
@@ -123,10 +156,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge
             Collections.sort( allVersions, VersionComparator.getInstance() );
             Collections.sort( releasedVersions, VersionComparator.getInstance() );
             Collections.sort( snapshotVersions, VersionComparator.getInstance() );
-
-            // Find out the highest released version.
-            String highestReleasedVersion = allVersions.get( allVersions.size() - 1 );
-
+            
             // Now clean out any version that is earlier than the highest released version.
             boolean needsMetadataUpdate = false;
 
@@ -137,7 +167,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge
             for ( String version : snapshotVersions )
             {   
                 if( releasedVersions.contains( VersionUtil.getReleaseVersion( version ) ) )
-                {
+                {                    
                     versionRef.setVersion( version );
                     repository.deleteVersion( versionRef );
                     needsMetadataUpdate = true;
index c29a647a81d2acd7c3c409dfb37c578b065e2f0b..dacee4891db0151597bd5cf9f2e05540cf6ea58a 100644 (file)
@@ -157,9 +157,9 @@ public class RepositoryPurgeConsumer
                 repoPurge = new RetentionCountRepositoryPurge( repositoryContent, dao.getArtifactDAO(), repository
                     .getRetentionCount(), indices );
             }
-
+            
             cleanUp = new CleanupReleasedSnapshotsRepositoryPurge( repositoryContent, dao.getArtifactDAO(),
-                                                                   metadataTools, indices );
+                                   metadataTools, indices, configuration, repositoryFactory );
 
             deleteReleasedSnapshots = repository.isDeleteReleasedSnapshots();
         }
index eb547668cb97693f6d1ba363d208c98db4e3b402..5d08699428c57501e8f8dd46cb0ec9606a719b0d 100644 (file)
@@ -64,12 +64,12 @@ public abstract class AbstractRepositoryPurgeTest
 
     public static final String PATH_TO_BY_RETENTION_COUNT_POM = "org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.pom";
 
-    public static final String PATH_TO_RELEASED_SNAPSHOT = "org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar";
-
-    public static final String PATH_TO_HIGHER_SNAPSHOT_EXISTS = "org/apache/maven/plugins/maven-source-plugin/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.jar";
-    
     public static final String PATH_TO_TEST_ORDER_OF_DELETION = "org/apache/maven/plugins/maven-assembly-plugin/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070615.105019-3.jar";
 
+    protected static final String RELEASES_TEST_REPO_ID = "releases-test-repo-one";
+
+    protected static final String RELEASES_TEST_REPO_NAME = "Releases Test Repo One";
+
     private ManagedRepositoryConfiguration config;
 
     private ManagedRepositoryContent repo;
@@ -153,22 +153,18 @@ public abstract class AbstractRepositoryPurgeTest
         repo = null;
     }
 
-    public ManagedRepositoryConfiguration getRepoConfiguration()
+    public ManagedRepositoryConfiguration getRepoConfiguration( String repoId, String repoName )
     {
-        if ( config == null )
-        {
-            config = new ManagedRepositoryConfiguration();
-        }
-
-        config.setId( TEST_REPO_ID );
-        config.setName( TEST_REPO_NAME );
+        config = new ManagedRepositoryConfiguration();
+        config.setId( repoId );
+        config.setName( repoName );
         config.setDaysOlder( TEST_DAYS_OLDER );
-        config.setLocation( getTestRepoRoot().getAbsolutePath() );
+        config.setLocation( getTestFile( "target/test-" + getName() + "/" + repoId ).getAbsolutePath() );
         config.setReleases( true );
         config.setSnapshots( true );
         config.setDeleteReleasedSnapshots( true );
         config.setRetentionCount( TEST_RETENTION_COUNT );
-
+        
         return config;
     }
 
@@ -177,8 +173,8 @@ public abstract class AbstractRepositoryPurgeTest
     {
         if ( repo == null )
         {
-            repo = (ManagedRepositoryContent) lookup( ManagedRepositoryContent.class, "default" );
-            repo.setRepository( getRepoConfiguration() );
+            repo = (ManagedRepositoryContent) lookup( ManagedRepositoryContent.class, "default" );            
+            repo.setRepository( getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ) );
         }
 
         return repo;
@@ -218,15 +214,19 @@ public abstract class AbstractRepositoryPurgeTest
     
     protected File getTestRepoRoot()
     {
-        return getTestFile( "target/test-" + getName() + "/test-repo" );
+        return getTestFile( "target/test-" + getName() + "/" + TEST_REPO_ID );
     }
 
-    protected String prepareTestRepo()
+    protected String prepareTestRepos()
         throws IOException
     {
         File testDir = getTestRepoRoot();
         FileUtils.deleteDirectory( testDir );
-        FileUtils.copyDirectory( getTestFile( "target/test-classes/test-repo" ), testDir );
+        FileUtils.copyDirectory( getTestFile( "target/test-classes/" + TEST_REPO_ID ), testDir );
+        
+        File releasesTestDir = getTestFile( "target/test-" + getName() + "/" + RELEASES_TEST_REPO_ID );
+        FileUtils.deleteDirectory( releasesTestDir );
+        FileUtils.copyDirectory( getTestFile( "target/test-classes/" + RELEASES_TEST_REPO_ID ), releasesTestDir );
         
         return testDir.getAbsolutePath();
     }
index 55f53bf3c58d44aafd5836efcf58b6a5b2199096..b133c54d33bbc9e1f09a0388f47b003dbc194577 100644 (file)
@@ -20,9 +20,12 @@ package org.apache.maven.archiva.consumers.core.repository;
  */
 
 import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.consumers.core.repository.stubs.LuceneRepositoryContentIndexStub;
 import org.apache.maven.archiva.database.ArchivaDatabaseException;
 import org.apache.maven.archiva.indexer.RepositoryContentIndex;
+import org.apache.maven.archiva.repository.RepositoryContentFactory;
 import org.apache.maven.archiva.repository.metadata.MetadataTools;
 import org.custommonkey.xmlunit.XMLAssert;
 
@@ -37,11 +40,20 @@ import java.util.Map;
  */
 public class CleanupReleasedSnapshotsRepositoryPurgeTest
     extends AbstractRepositoryPurgeTest
-{   
+{  
+    private ArchivaConfiguration archivaConfiguration;
+    
+    public static final String PATH_TO_RELEASED_SNAPSHOT_IN_DIFF_REPO =
+        "org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.jar";
+    
+    public static final String PATH_TO_HIGHER_SNAPSHOT_EXISTS_IN_SAME_REPO = "org/apache/maven/plugins/maven-source-plugin/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.jar";
+
+    public static final String PATH_TO_RELEASED_SNAPSHOT_IN_SAME_REPO = "org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar";
+    
     protected void setUp()
         throws Exception
     {
-        super.setUp();
+        super.setUp(); 
 
         Map<String, RepositoryContentIndex> map = new HashMap<String, RepositoryContentIndex>();
         map.put( "filecontent", new LuceneRepositoryContentIndexStub() );
@@ -49,19 +61,28 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
         map.put( "bytecode", new LuceneRepositoryContentIndexStub() );
         
         MetadataTools metadataTools = (MetadataTools) lookup( MetadataTools.class );
+        RepositoryContentFactory factory = (RepositoryContentFactory) lookup( RepositoryContentFactory.class, "cleanup-released-snapshots");
         
-        repoPurge = new CleanupReleasedSnapshotsRepositoryPurge( getRepository(), dao, metadataTools, map );
+        archivaConfiguration =
+            (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "cleanup-released-snapshots" );
+                
+        repoPurge =
+            new CleanupReleasedSnapshotsRepositoryPurge( getRepository(), dao, metadataTools, map, archivaConfiguration, factory );
     }
 
-    public void testReleasedSnapshots()
+    public void testReleasedSnapshotsExistsInSameRepo()
         throws Exception
     {
+        
+        Configuration config = archivaConfiguration.getConfiguration();
+        config.removeManagedRepository( config.findManagedRepositoryById( TEST_REPO_ID ) );
+        config.addManagedRepository( getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ) );
+      
         populateReleasedSnapshotsTest();
 
-        String repoRoot = prepareTestRepo();
-        
+        String repoRoot = prepareTestRepos();        
 
-        repoPurge.process( PATH_TO_RELEASED_SNAPSHOT );
+        repoPurge.process( CleanupReleasedSnapshotsRepositoryPurgeTest.PATH_TO_RELEASED_SNAPSHOT_IN_SAME_REPO );
 
         String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-plugin-plugin";
         
@@ -100,15 +121,58 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
                                      "//metadata/versioning/versions/version", metadataXml );
         XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
     }
+    
+    public void testReleasedSnapshotsExistsInDifferentRepo()
+        throws Exception
+    {   
+        Configuration config = archivaConfiguration.getConfiguration();
+        config.removeManagedRepository( config.findManagedRepositoryById( TEST_REPO_ID ) );
+        config.addManagedRepository( getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ) );
+        config.addManagedRepository( getRepoConfiguration( RELEASES_TEST_REPO_ID, RELEASES_TEST_REPO_NAME ) );
+        
+        populateReleasedSnapshotsTestInDiffRepo();
+
+        String repoRoot = prepareTestRepos();        
+
+        repoPurge.process( PATH_TO_RELEASED_SNAPSHOT_IN_DIFF_REPO );
+
+        String projectRoot = repoRoot + "/org/apache/archiva/released-artifact-in-diff-repo";
+        
+        // check if the snapshot was removed
+        assertDeleted( projectRoot + "/1.0-SNAPSHOT" );
+        assertDeleted( projectRoot + "/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.jar" );
+        assertDeleted( projectRoot + "/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.jar.md5" );
+        assertDeleted( projectRoot + "/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.jar.sha1" );
+        assertDeleted( projectRoot + "/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.pom" );
+        assertDeleted( projectRoot + "/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.pom.md5" );
+        assertDeleted( projectRoot + "/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.pom.sha1" );
+
+        String releasesProjectRoot =
+            getTestFile( "target/test-" + getName() + "/releases-test-repo-one" ).getAbsolutePath() +
+                "/org/apache/archiva/released-artifact-in-diff-repo";
+        
+        // check if the released version was not removed
+        assertExists( releasesProjectRoot + "/1.0" );        
+        assertExists( releasesProjectRoot + "/1.0/released-artifact-in-diff-repo-1.0.jar" );
+        assertExists( releasesProjectRoot + "/1.0/released-artifact-in-diff-repo-1.0.jar.md5" );
+        assertExists( releasesProjectRoot + "/1.0/released-artifact-in-diff-repo-1.0.jar.sha1" );
+        assertExists( releasesProjectRoot + "/1.0/released-artifact-in-diff-repo-1.0.pom" );
+        assertExists( releasesProjectRoot + "/1.0/released-artifact-in-diff-repo-1.0.pom.md5" );
+        assertExists( releasesProjectRoot + "/1.0/released-artifact-in-diff-repo-1.0.pom.sha1" );        
+    }
 
-    public void testHigherSnapshotExists()
+    public void testHigherSnapshotExistsInSameRepo()
         throws Exception
-    {
+    {   
+        Configuration config = archivaConfiguration.getConfiguration();
+        config.removeManagedRepository( config.findManagedRepositoryById( TEST_REPO_ID ) );
+        config.addManagedRepository( getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ) );
+        
         populateHigherSnapshotExistsTest();
 
-        String repoRoot = prepareTestRepo();
+        String repoRoot = prepareTestRepos();
 
-        repoPurge.process( PATH_TO_HIGHER_SNAPSHOT_EXISTS );
+        repoPurge.process( CleanupReleasedSnapshotsRepositoryPurgeTest.PATH_TO_HIGHER_SNAPSHOT_EXISTS_IN_SAME_REPO );
         
         String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-source-plugin";
         
@@ -143,7 +207,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
                                      "//metadata/versioning/versions/version", metadataXml );
         XMLAssert.assertXpathEvaluatesTo( "20070427033345", "//metadata/versioning/lastUpdated", metadataXml );
     }
-    
+   
     private void populateReleasedSnapshotsTest()
         throws ArchivaDatabaseException
     {
@@ -161,5 +225,14 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
 
         populateDb( "org.apache.maven.plugins", "maven-source-plugin", versions );
     }
+    
+    private void populateReleasedSnapshotsTestInDiffRepo()
+        throws ArchivaDatabaseException
+    {
+        List<String> versions = new ArrayList<String>();
+        versions.add( "1.0-SNAPSHOT" );
+        
+        populateDb( "org.apache.archiva", "released-artifact-in-diff-repo", versions );
+    }
 
 }
index b887b1f11480c3fe6cd385b1ac45d7d703a94e0e..5d51d71aabb7f35b28638276dbffe7b222cadffa 100644 (file)
@@ -80,10 +80,10 @@ public class DaysOldRepositoryPurgeTest
         map.put( "bytecode", new LuceneRepositoryContentIndexStub( 2 ) );
 
         repoPurge =
-            new DaysOldRepositoryPurge( getRepository(), dao, getRepoConfiguration().getDaysOlder(),
-                                        getRepoConfiguration().getRetentionCount(), map );
+            new DaysOldRepositoryPurge( getRepository(), dao, getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ).getDaysOlder(),
+                                        getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ).getRetentionCount(), map );
 
-        String repoRoot = prepareTestRepo();
+        String repoRoot = prepareTestRepos();
 
         String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-install-plugin";
 
@@ -125,10 +125,10 @@ public class DaysOldRepositoryPurgeTest
         map.put( "bytecode", new LuceneRepositoryContentIndexStub( 2 ) );
 
         repoPurge =
-            new DaysOldRepositoryPurge( getRepository(), dao, getRepoConfiguration().getDaysOlder(),
-                                        getRepoConfiguration().getRetentionCount(), map );
+            new DaysOldRepositoryPurge( getRepository(), dao, getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ).getDaysOlder(),
+                                        getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ).getRetentionCount(), map );
 
-        String repoRoot = prepareTestRepo();
+        String repoRoot = prepareTestRepos();
 
         String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-assembly-plugin";
 
@@ -170,10 +170,10 @@ public class DaysOldRepositoryPurgeTest
         map.put( "bytecode", new LuceneRepositoryContentIndexStub( 2 ) );
 
         repoPurge =
-            new DaysOldRepositoryPurge( getRepository(), dao, getRepoConfiguration().getDaysOlder(),
-                                        getRepoConfiguration().getRetentionCount(), map );
+            new DaysOldRepositoryPurge( getRepository(), dao, getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ).getDaysOlder(),
+                                        getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ).getRetentionCount(), map );
 
-        String repoRoot = prepareTestRepo();
+        String repoRoot = prepareTestRepos();
 
         String versionRoot = repoRoot + "/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT";
 
index 9653c2cc1fa627ec4bc94fa703c9b117885b5e1b..ca8b63f6cfc55b8b87f4442a08a4cbed9442bad4 100644 (file)
@@ -88,7 +88,7 @@ public class RepositoryPurgeConsumerTest
         File[] contents = dir.listFiles();
         for ( int i = 0; i < contents.length; i++ )
         {
-            contents[i].setLastModified( 1179382029 );
+            contents[i].setLastModified( 1179382029 ); 
         }
     }
 
@@ -106,14 +106,14 @@ public class RepositoryPurgeConsumerTest
 
         populateDbForRetentionCountTest();
 
-        ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration();
+        ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
         repoConfiguration.setDaysOlder( 0 ); // force days older off to allow retention count purge to execute.
         repoConfiguration.setRetentionCount( TEST_RETENTION_COUNT );
         addRepoToConfiguration( "retention-count", repoConfiguration );
 
         repoPurgeConsumer.beginScan( repoConfiguration, null );
 
-        String repoRoot = prepareTestRepo();
+        String repoRoot = prepareTestRepos();
 
         repoPurgeConsumer.processFile( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
 
@@ -174,13 +174,13 @@ public class RepositoryPurgeConsumerTest
 
         ( (RepositoryPurgeConsumer) repoPurgeConsumer ).setRepositoryContentIndexFactory( indexFactory );
 
-        ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration();
+        ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
         repoConfiguration.setDaysOlder( TEST_DAYS_OLDER );
         addRepoToConfiguration( "days-old", repoConfiguration );
 
         repoPurgeConsumer.beginScan( repoConfiguration, null );
 
-        String repoRoot = prepareTestRepo();
+        String repoRoot = prepareTestRepos();
         String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-install-plugin";
 
         setLastModified( projectRoot + "/2.2-SNAPSHOT" );
@@ -224,15 +224,15 @@ public class RepositoryPurgeConsumerTest
 
         populateDbForReleasedSnapshotsTest();
 
-        ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration();
+        ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
         repoConfiguration.setDeleteReleasedSnapshots( false ); // Set to NOT delete released snapshots.
         addRepoToConfiguration( "retention-count", repoConfiguration );
 
         repoPurgeConsumer.beginScan( repoConfiguration, null );
 
-        String repoRoot = prepareTestRepo();
+        String repoRoot = prepareTestRepos();
 
-        repoPurgeConsumer.processFile( PATH_TO_RELEASED_SNAPSHOT );
+        repoPurgeConsumer.processFile( CleanupReleasedSnapshotsRepositoryPurgeTest.PATH_TO_RELEASED_SNAPSHOT_IN_SAME_REPO );
 
         // check if the snapshot wasn't removed
         String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-plugin-plugin";
@@ -267,15 +267,15 @@ public class RepositoryPurgeConsumerTest
 
         populateDbForReleasedSnapshotsTest();
 
-        ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration();
+        ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
         repoConfiguration.setDeleteReleasedSnapshots( true );
         addRepoToConfiguration( "days-old", repoConfiguration );
 
         repoPurgeConsumer.beginScan( repoConfiguration, null );
 
-        String repoRoot = prepareTestRepo();
+        String repoRoot = prepareTestRepos();
 
-        repoPurgeConsumer.processFile( PATH_TO_RELEASED_SNAPSHOT );
+        repoPurgeConsumer.processFile( CleanupReleasedSnapshotsRepositoryPurgeTest.PATH_TO_RELEASED_SNAPSHOT_IN_SAME_REPO );
 
         String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-plugin-plugin";
 
@@ -307,7 +307,7 @@ public class RepositoryPurgeConsumerTest
     {
         List<String> versions = new ArrayList<String>();
         versions.add( "1.0RC1-20070504.153317-1" );
-        versions.add( "1.0RC1-20070504.160758-2" );
+        versions.add( "1.0RC1-20070504.160758-2" ); 
         versions.add( "1.0RC1-20070505.090015-3" );
         versions.add( "1.0RC1-20070506.090132-4" );
 
index d7f7d5865c5fee89274d66603e1eead619e013cc..f67720ccff21c49988d17ce7c747d8dd26dc21be 100644 (file)
@@ -47,7 +47,7 @@ public class RetentionCountRepositoryPurgeTest
         map.put( "bytecode", new LuceneRepositoryContentIndexStub( 2 ) );
         
         repoPurge = new RetentionCountRepositoryPurge( getRepository(), dao,
-                                                       getRepoConfiguration().getRetentionCount(), map );
+                                                       getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ).getRetentionCount(), map );
     }
 
     /**
@@ -60,7 +60,7 @@ public class RetentionCountRepositoryPurgeTest
     {
         populateIfJarWasFoundDb();
 
-        String repoRoot = prepareTestRepo();
+        String repoRoot = prepareTestRepos();
 
         repoPurge.process( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
         
@@ -107,7 +107,7 @@ public class RetentionCountRepositoryPurgeTest
     {
         populateIfPomWasFoundDb();
 
-        String repoRoot = prepareTestRepo();
+        String repoRoot = prepareTestRepos();
 
         repoPurge.process( PATH_TO_BY_RETENTION_COUNT_POM );
 
@@ -148,7 +148,7 @@ public class RetentionCountRepositoryPurgeTest
     {
         populateDbForTestOrderOfDeletion();
 
-        String repoRoot = prepareTestRepo();
+        String repoRoot = prepareTestRepos();
 
         repoPurge.process( PATH_TO_TEST_ORDER_OF_DELETION );
 
index 86639b5259c4c3e36f11ce0c3e1e22c5c78ab09b..49f384e4282342b26432fc71794e507a895cb796 100644 (file)
         </otherProperties>
       </configuration>
     </component>
+    
+    <component>
+      <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+      <role-hint>cleanup-released-snapshots</role-hint>
+      <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
+      <requirements>
+        <requirement>
+          <role>org.codehaus.plexus.registry.Registry</role>
+          <role-hint>cleanup-released-snapshots</role-hint>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role>
+          <field-name>prePolicies</field-name>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role>
+          <field-name>postPolicies</field-name>
+        </requirement>
+      </requirements>
+    </component>
+    
+     <component>
+      <role>org.codehaus.plexus.registry.Registry</role>
+      <role-hint>cleanup-released-snapshots</role-hint>
+      <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
+      <configuration>
+        <properties>
+          <xml fileName="${basedir}/src/test/conf/repository-manager.xml"
+               config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/>
+        </properties>
+      </configuration>
+    </component>
+    
+    <component>
+      <role>org.apache.maven.archiva.repository.RepositoryContentFactory</role>
+      <role-hint>cleanup-released-snapshots</role-hint>
+      <implementation>org.apache.maven.archiva.repository.RepositoryContentFactory</implementation>
+      <description>RepositoryContentRequest</description>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+          <role-hint>cleanup-released-snapshots</role-hint>
+          <field-name>archivaConfiguration</field-name>
+        </requirement>
+      </requirements>
+    </component>
 
   </components>
 </component-set>
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.jar b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.jar
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.jar.md5 b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.jar.md5
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.jar.sha1 b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.jar.sha1
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.pom b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.pom
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.pom.md5 b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.pom.md5
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.pom.sha1 b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/releases-test-repo-one/org/apache/archiva/released-artifact-in-diff-repo/1.0/released-artifact-in-diff-repo-1.0.pom.sha1
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.jar b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.jar
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.jar.md5 b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.jar.md5
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.jar.sha1 b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.jar.sha1
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.pom b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.pom
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.pom.md5 b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.pom.md5
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.pom.sha1 b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/archiva/released-artifact-in-diff-repo/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.pom.sha1
new file mode 100644 (file)
index 0000000..e69de29