<configuration>
<version>1</version>
- <managedRepositories>
- <managedRepository>
+ <repositories>
+ <repository>
<id>internal</id>
<name>Archiva Managed Internal Repository</name>
- <location>${appserver.base}/repositories/internal</location>
+ <url>file://${appserver.base}/repositories/internal</url>
<layout>default</layout>
<releases>true</releases>
<snapshots>false</snapshots>
<indexed>true</indexed>
<refreshCronExpression>0 0 * * ?</refreshCronExpression>
- </managedRepository>
- <managedRepository>
+ </repository>
+ <repository>
<id>snapshots</id>
<name>Archiva Managed Snapshot Repository</name>
- <location>${appserver.base}/repositories/snapshots</location>
+ <url>file://${appserver.base}/repositories/snapshots</url>
<layout>default</layout>
<releases>false</releases>
<snapshots>true</snapshots>
<indexed>true</indexed>
<refreshCronExpression>0 0,30 * * ?</refreshCronExpression>
- </managedRepository>
- </managedRepositories>
-
- <remoteRepositories>
- <remoteRepository>
+ </repository>
+ <repository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
<releases>true</releases>
<snapshots>false</snapshots>
- </remoteRepository>
- <remoteRepository>
+ <indexed>false</indexed>
+ </repository>
+ <repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven 2</name>
<url>https://maven2-repository.dev.java.net/nonav/repository</url>
<layout>default</layout>
<releases>true</releases>
<snapshots>false</snapshots>
- </remoteRepository>
- </remoteRepositories>
+ <indexed>false</indexed>
+ </repository>
+ <repository>
+ <id>test-repo</id>
+ <name>Test Repository</name>
+ <url>file://${appserver.base}/test-repo</url>
+ <layout>default</layout>
+ <releases>true</releases>
+ <snapshots>true</snapshots>
+ <indexed>true</indexed>
+ <refreshCronExpression>0 0 * * ?</refreshCronExpression>
+ <daysOlder>100</daysOlder>
+ <deleteReleasedSnapshots>true</deleteReleasedSnapshots>
+ </repository>
+ </repositories>
<proxyConnectors>
<proxyConnector>
<configuration>
<version>1</version>
- <managedRepositories>
- <managedRepository>
+ <repositories>
+ <repository>
<id>internal</id>
<name>Archiva Managed Internal Repository</name>
- <location>${appserver.base}/repositories/internal</location>
+ <url>file://${appserver.base}/repositories/internal</url>
<layout>default</layout>
<releases>true</releases>
<snapshots>false</snapshots>
<indexed>true</indexed>
<refreshCronExpression>0 0 * * ?</refreshCronExpression>
- </managedRepository>
- <managedRepository>
+ </repository>
+ <repository>
<id>snapshots</id>
<name>Archiva Managed Snapshot Repository</name>
- <location>${appserver.base}/repositories/snapshots</location>
+ <url>file://${appserver.base}/repositories/snapshots</url>
<layout>default</layout>
<releases>false</releases>
<snapshots>true</snapshots>
<indexed>true</indexed>
<refreshCronExpression>0 0,30 * * ?</refreshCronExpression>
- </managedRepository>
- </managedRepositories>
-
- <remoteRepositories>
- <remoteRepository>
+ </repository>
+ <repository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
<releases>true</releases>
<snapshots>false</snapshots>
- </remoteRepository>
- <remoteRepository>
+ <indexed>false</indexed>
+ </repository>
+ <repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven 2</name>
<url>https://maven2-repository.dev.java.net/nonav/repository</url>
<layout>default</layout>
<releases>true</releases>
<snapshots>false</snapshots>
- </remoteRepository>
- </remoteRepositories>
+ <indexed>false</indexed>
+ </repository>
+ <repository>
+ <id>test-repo</id>
+ <name>Test Repository</name>
+ <url>file://${appserver.base}/test-repo</url>
+ <layout>default</layout>
+ <releases>true</releases>
+ <snapshots>true</snapshots>
+ <indexed>true</indexed>
+ <refreshCronExpression>0 0 * * ?</refreshCronExpression>
+ <daysOlder>0</daysOlder>
+ <retentionCount>2</retentionCount>
+ </repository>
+ </repositories>
<proxyConnectors>
<proxyConnector>
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.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.maven.archiva.database.ArchivaDatabaseException;
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 );
String repoRoot = prepareTestRepo();
repoPurgeConsumer.processFile( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
-
+
String versionRoot = repoRoot + "/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT";
-
+
// assert if removed from repo
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.md5" );
private void addRepoToConfiguration( String configHint, ManagedRepositoryConfiguration repoConfiguration )
throws Exception
{
- ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class,
- configHint );
- archivaConfiguration.getConfiguration().addManagedRepository( repoConfiguration );
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class, configHint );
+ Configuration configuration = archivaConfiguration.getConfiguration();
+ configuration.removeManagedRepository( configuration.findManagedRepositoryById( repoConfiguration.getId() ) );
+ configuration.addManagedRepository( repoConfiguration );
}
public void testConsumerByDaysOld()
KnownRepositoryContentConsumer.class, "repo-purge-consumer-by-days-old" );
ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration();
- repoConfiguration.setDaysOlder( TEST_DAYS_OLDER );
+ repoConfiguration.setDaysOlder( TEST_DAYS_OLDER );
addRepoToConfiguration( "days-old", repoConfiguration );
repoPurgeConsumer.beginScan( repoConfiguration );
repoPurgeConsumer.processFile( PATH_TO_BY_DAYS_OLD_ARTIFACT );
- assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar" );
+ assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar" );
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.md5" );
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.sha1" );
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom" );
/**
* Test the snapshot clean consumer on a repository set to NOT clean/delete snapshots
- * based on released versions.
- *
+ * based on released versions.
+ *
* @throws Exception
*/
public void testReleasedSnapshotsWereNotCleaned()
ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration();
repoConfiguration.setDeleteReleasedSnapshots( false ); // Set to NOT delete released snapshots.
addRepoToConfiguration( "retention-count", repoConfiguration );
-
+
repoPurgeConsumer.beginScan( repoConfiguration );
String repoRoot = prepareTestRepo();
// check if the snapshot wasn't removed
String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-plugin-plugin";
-
+
assertExists( projectRoot + "/2.3-SNAPSHOT" );
assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar" );
assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.md5" );
File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, null );
-
+
String expectedVersions = "<expected><versions><version>2.3-SNAPSHOT</version></versions></expected>";
-
+
XMLAssert.assertXpathEvaluatesTo( "2.3-SNAPSHOT", "//metadata/versioning/latest", metadataXml );
XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions,
"//metadata/versioning/versions/version", metadataXml );
- XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
+ XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
}
public void testReleasedSnapshotsWereCleaned()
ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration();
repoConfiguration.setDeleteReleasedSnapshots( true );
addRepoToConfiguration( "days-old", repoConfiguration );
-
+
repoPurgeConsumer.beginScan( repoConfiguration );
String repoRoot = prepareTestRepo();
// check if metadata file was updated
File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
-
+
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, null );
-
- String expectedVersions = "<expected><versions><version>2.2</version>"
- + "<version>2.3</version></versions></expected>";
-
+
+ String expectedVersions =
+ "<expected><versions><version>2.2</version>" + "<version>2.3</version></versions></expected>";
+
XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/latest", metadataXml );
XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions,
"//metadata/versioning/versions/version", metadataXml );
- XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
- }
+ XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
+ }
public void populateDbForRetentionCountTest()
throws ArchivaDatabaseException