From: Maria Odea B. Ching Date: Mon, 26 May 2008 08:42:10 +0000 (+0000) Subject: [MRM-797] X-Git-Tag: archiva-r676265~111 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7d343a62a79f78d6a1555c01f93892a2874273ee;p=archiva.git [MRM-797] -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 --- diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java index 066542424..b9c1795a7 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java @@ -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 indices ) + MetadataTools metadataTools, Map 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 allVersions = new ArrayList( repository.getVersions( reference ) ); + List 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 releasedVersions = new ArrayList(); List snapshotVersions = new ArrayList(); 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; diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java index c29a647a8..dacee4891 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumer.java @@ -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(); } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java index eb547668c..5d0869942 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java @@ -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(); } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java index 55f53bf3c..b133c54d3 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java @@ -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 map = new HashMap(); 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 versions = new ArrayList(); + versions.add( "1.0-SNAPSHOT" ); + + populateDb( "org.apache.archiva", "released-artifact-in-diff-repo", versions ); + } } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java index b887b1f11..5d51d71aa 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java @@ -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"; diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java index 9653c2cc1..ca8b63f6c 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java @@ -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 versions = new ArrayList(); 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" ); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java index d7f7d5865..f67720ccf 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java @@ -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 ); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.xml index 86639b525..49f384e42 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.xml @@ -53,6 +53,52 @@ + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + cleanup-released-snapshots + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + cleanup-released-snapshots + + + org.apache.maven.archiva.policies.PreDownloadPolicy + prePolicies + + + org.apache.maven.archiva.policies.PostDownloadPolicy + postPolicies + + + + + + org.codehaus.plexus.registry.Registry + cleanup-released-snapshots + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + + + org.apache.maven.archiva.repository.RepositoryContentFactory + cleanup-released-snapshots + org.apache.maven.archiva.repository.RepositoryContentFactory + RepositoryContentRequest + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + cleanup-released-snapshots + archivaConfiguration + + + 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 index 000000000..e69de29bb 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 index 000000000..e69de29bb 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 index 000000000..e69de29bb 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 index 000000000..e69de29bb 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 index 000000000..e69de29bb 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 index 000000000..e69de29bb 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 index 000000000..e69de29bb 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 index 000000000..e69de29bb 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 index 000000000..e69de29bb 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 index 000000000..e69de29bb 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 index 000000000..e69de29bb 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 index 000000000..e69de29bb