-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-ffa450edef68tags/archiva-r676265
@@ -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; |
@@ -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(); | |||
} |
@@ -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(); | |||
} |
@@ -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 ); | |||
} | |||
} |
@@ -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"; | |||
@@ -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" ); | |||
@@ -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 ); | |||
@@ -53,6 +53,52 @@ | |||
</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> |