Browse Source

Fixed unit tests for RepositoryPurge as they were non-repeatable in an IDE environment.

Corrected the assumption that a Managed Repository is the same as a Local Repository. (re: maven-metadata-local.xml)
Streamlined asserts to be more clear .assertExists() .assertDeleted() when reading code and when error message is created.
Removed jdom direct usage in unit tests in favor of XMLUnit.



git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@584213 13f79535-47bb-0310-9956-ffa450edef68
tags/archiva-1.0-beta-3
Joakim Erdfelt 16 years ago
parent
commit
46f7d825da
14 changed files with 296 additions and 576 deletions
  1. 5
    0
      archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
  2. 0
    2
      archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurge.java
  3. 0
    2
      archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java
  4. 41
    12
      archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
  5. 64
    184
      archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
  6. 35
    63
      archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java
  7. 92
    199
      archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
  8. 59
    114
      archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java
  9. 0
    0
      archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-metadata.xml
  10. 0
    0
      archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-metadata.xml
  11. 0
    0
      archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/maven-metadata.xml
  12. 0
    0
      archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.3-SNAPSHOT/maven-metadata.xml
  13. 0
    0
      archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.4-SNAPSHOT/maven-metadata.xml
  14. 0
    0
      archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml

+ 5
- 0
archiva-base/archiva-consumers/archiva-core-consumers/pom.xml View File

@@ -60,5 +60,10 @@
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

+ 0
- 2
archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurge.java View File

@@ -88,7 +88,6 @@ public abstract class AbstractRepositoryPurge
{
File artifactFile = repository.toFile( reference );

System.err.println( "Purging: " + artifactFile.getAbsolutePath() );
artifactFile.delete();
purgeSupportFiles( artifactFile );

@@ -139,7 +138,6 @@ public abstract class AbstractRepositoryPurge
if ( file.exists() && file.isFile() )
{
file.delete();
System.err.println( "Deleting support file: " + file.getAbsolutePath() );
// TODO: log that it was deleted?
}
}

+ 0
- 2
archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java View File

@@ -116,8 +116,6 @@ public class RetentionCountRepositoryPurge
artifact.setClassifier( reference.getClassifier() );
artifact.setType( reference.getType() );
System.err.println( "Requesting (retention) purge of " + ArtifactReference.toKey( reference ) );

try
{
Set<ArtifactReference> related = repository.getRelatedArtifacts( artifact );

+ 41
- 12
archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java View File

@@ -19,6 +19,7 @@ package org.apache.maven.archiva.consumers.core.repository;
* under the License.
*/

import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.database.ArchivaDatabaseException;
import org.apache.maven.archiva.database.ArtifactDAO;
@@ -30,12 +31,12 @@ import org.codehaus.plexus.jdo.JdoFactory;
import org.jpox.SchemaTool;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Map.Entry;

import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
@@ -50,8 +51,6 @@ public abstract class AbstractRepositoryPurgeTest

public static final String TEST_REPO_NAME = "Test Repository";

public static final String TEST_REPO_LOCATION = getBasedir() + "/target/test/test-repo/";

public static final int TEST_RETENTION_COUNT = 2;

public static final int TEST_DAYS_OLDER = 30;
@@ -113,10 +112,8 @@ public abstract class AbstractRepositoryPurgeTest

Properties properties = jdoFactory.getProperties();

for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); )
for ( Entry<Object, Object> entry : properties.entrySet() )
{
Map.Entry entry = (Map.Entry) it.next();

System.setProperty( (String) entry.getKey(), (String) entry.getValue() );
}

@@ -143,6 +140,15 @@ public abstract class AbstractRepositoryPurgeTest

dao = (ArtifactDAO) lookup( ArtifactDAO.class.getName(), "jdo" );
}
@Override
protected void tearDown()
throws Exception
{
super.tearDown();
config = null;
repo = null;
}

public ManagedRepositoryConfiguration getRepoConfiguration()
{
@@ -154,7 +160,7 @@ public abstract class AbstractRepositoryPurgeTest
config.setId( TEST_REPO_ID );
config.setName( TEST_REPO_NAME );
config.setDaysOlder( TEST_DAYS_OLDER );
config.setLocation( TEST_REPO_LOCATION );
config.setLocation( getTestRepoRoot().getAbsolutePath() );
config.setReleases( true );
config.setSnapshots( true );
config.setDeleteReleasedSnapshots( true );
@@ -175,13 +181,11 @@ public abstract class AbstractRepositoryPurgeTest
return repo;
}

protected void populateDb( String groupId, String artifactId, List versions )
protected void populateDb( String groupId, String artifactId, List<String> versions )
throws ArchivaDatabaseException
{
for ( Iterator iter = versions.iterator(); iter.hasNext(); )
for ( String version : versions )
{
String version = (String) iter.next();

ArchivaArtifact artifact = dao.createArtifact( groupId, artifactId, version, "", "jar" );
assertNotNull( artifact );
artifact.getModel().setLastModified( new Date() );
@@ -198,4 +202,29 @@ public abstract class AbstractRepositoryPurgeTest
assertNotNull( savedArtifact );
}
}

protected void assertDeleted( String path )
{
assertFalse( "File should have been deleted: " + path, new File( path ).exists() );
}

protected void assertExists( String path )
{
assertTrue( "File should exist: " + path, new File( path ).exists() );
}
protected File getTestRepoRoot()
{
return getTestFile( "target/test-" + getName() + "/test-repo" );
}

protected String prepareTestRepo()
throws IOException
{
File testDir = getTestRepoRoot();
FileUtils.deleteDirectory( testDir );
FileUtils.copyDirectory( getTestFile( "target/test-classes/test-repo" ), testDir );
return testDir.getAbsolutePath();
}
}

+ 64
- 184
archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java View File

@@ -22,16 +22,10 @@ package org.apache.maven.archiva.consumers.core.repository;
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.database.ArchivaDatabaseException;
import org.apache.maven.archiva.repository.metadata.MetadataTools;
import org.codehaus.plexus.util.IOUtil;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import org.jdom.xpath.XPath;
import org.custommonkey.xmlunit.XMLAssert;

import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
@@ -46,7 +40,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
super.setUp();

MetadataTools metadataTools = (MetadataTools) lookup( MetadataTools.class );
repoPurge = new CleanupReleasedSnapshotsRepositoryPurge( getRepository(), dao, metadataTools );
}

@@ -55,105 +49,46 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
{
populateReleasedSnapshotsTest();

File testDir = new File( "target/test" );
FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
String repoRoot = prepareTestRepo();

repoPurge.process( PATH_TO_RELEASED_SNAPSHOT );

String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-plugin-plugin";
// check if the snapshot was removed
assertFalse( new File( "target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT" )
.exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar" )
.exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.md5" )
.exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.sha1" )
.exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom" )
.exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.md5" )
.exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" )
.exists() );
assertDeleted( projectRoot + "/2.3-SNAPSHOT" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.md5" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.sha1" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.md5" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" );

// check if the released version was not removed
assertTrue( new File( "target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3-sources.jar" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3-sources.jar.md5" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3-sources.jar.sha1" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3.jar" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3.jar.md5" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3.jar.sha1" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3.pom" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3.pom.md5" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3.pom.sha1" )
.exists() );
assertExists( projectRoot + "/2.3" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3-sources.jar" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3-sources.jar.md5" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3-sources.jar.sha1" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3.jar" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3.jar.md5" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3.jar.sha1" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3.pom" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3.pom.md5" );
assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3.pom.sha1" );

// check if metadata file was updated
File artifactMetadataFile = new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/maven-metadata.xml" );

FileReader fileReader = new FileReader( artifactMetadataFile );
Document document;

try
{
SAXBuilder builder = new SAXBuilder();
document = builder.build( fileReader );
}
finally
{
IOUtil.close( fileReader );
}

// parse the metadata file
XPath xPath = XPath.newInstance( "//metadata/versioning" );
Element rootElement = document.getRootElement();

Element versioning = (Element) xPath.selectSingleNode( rootElement );
Element el = (Element) xPath.newInstance( "./latest" ).selectSingleNode( versioning );
assertEquals( "2.3", el.getValue() );

el = (Element) xPath.newInstance( "./lastUpdated" ).selectSingleNode( versioning );
// FIXME: assertFalse( el.getValue().equals( "20070315032817" ) );

List nodes = xPath.newInstance( "./versions" ).selectNodes( rootElement );

boolean found = false;
for ( Iterator iter = nodes.iterator(); iter.hasNext(); )
{
el = (Element) iter.next();
if ( el.getValue().equals( "2.3-SNAPSHOT" ) )
{
found = true;
}
}
assertFalse( found );

FileUtils.deleteDirectory( testDir );
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>";
XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/release", metadataXml );
XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/latest", metadataXml );
XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions,
"//metadata/versioning/versions/version", metadataXml );
// FIXME [MRM-535]: XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
}

public void testHigherSnapshotExists()
@@ -161,103 +96,48 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
{
populateHigherSnapshotExistsTest();

File testDir = new File( "target/test" );
FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
String repoRoot = prepareTestRepo();

repoPurge.process( PATH_TO_HIGHER_SNAPSHOT_EXISTS );
String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-source-plugin";

// check if the snapshot was removed
assertFalse( new File( "target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.3-SNAPSHOT" )
.exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.jar" )
.exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.jar.md5" )
.exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.jar.sha1" )
.exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.pom" )
.exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.pom.md5" )
.exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.pom.sha1" )
.exists() );
assertDeleted( projectRoot + "/2.0.3-SNAPSHOT" );
assertDeleted( projectRoot + "/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.jar" );
assertDeleted( projectRoot + "/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.jar.md5" );
assertDeleted( projectRoot + "/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.jar.sha1" );
assertDeleted( projectRoot + "/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.pom" );
assertDeleted( projectRoot + "/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.pom.md5" );
assertDeleted( projectRoot + "/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.pom.sha1" );

// check if the released version was not removed
assertTrue( new File( "target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.4-SNAPSHOT" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.jar" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.jar.md5" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.jar.sha1" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.pom" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.pom.md5" )
.exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.pom.sha1" )
.exists() );
assertExists( projectRoot + "/2.0.4-SNAPSHOT" );
assertExists( projectRoot + "/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.jar" );
assertExists( projectRoot + "/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.jar.md5" );
assertExists( projectRoot + "/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.jar.sha1" );
assertExists( projectRoot + "/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.pom" );
assertExists( projectRoot + "/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.pom.md5" );
assertExists( projectRoot + "/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.pom.sha1" );

// check if metadata file was updated
File artifactMetadataFile = new File(
"target/test/test-repo/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml" );

FileReader fileReader = new FileReader( artifactMetadataFile );
Document document;

try
{
SAXBuilder builder = new SAXBuilder();
document = builder.build( fileReader );
}
finally
{
IOUtil.close( fileReader );
}

// parse the metadata file
XPath xPath = XPath.newInstance( "//metadata/versioning" );
Element rootElement = document.getRootElement();

Element versioning = (Element) xPath.selectSingleNode( rootElement );
Element el = (Element) xPath.newInstance( "./latest" ).selectSingleNode( versioning );
assertEquals( "2.0.4-SNAPSHOT", el.getValue() );

el = (Element) xPath.newInstance( "./lastUpdated" ).selectSingleNode( versioning );
// FIXME: assertFalse( el.getValue().equals( "20070427033345" ) );

List nodes = xPath.newInstance( "./versions" ).selectNodes( rootElement );

boolean found = false;
for ( Iterator iter = nodes.iterator(); iter.hasNext(); )
{
el = (Element) iter.next();
if ( el.getValue().equals( "2.0.3-SNAPSHOT" ) )
{
found = true;
}
}
assertFalse( found );

FileUtils.deleteDirectory( testDir );
File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );

String metadataXml = FileUtils.readFileToString( artifactMetadataFile, null );
String expectedVersions = "<expected><versions><version>2.0.2</version>" +
"<version>2.0.4-SNAPSHOT</version></versions></expected>";
XMLAssert.assertXpathEvaluatesTo( "2.0.4-SNAPSHOT", "//metadata/versioning/latest", metadataXml );
XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions,
"//metadata/versioning/versions/version", metadataXml );
// FIXME [MRM-535]: XMLAssert.assertXpathEvaluatesTo( "20070427033345", "//metadata/versioning/lastUpdated", metadataXml );
}

private void populateReleasedSnapshotsTest()
throws ArchivaDatabaseException
{
List versions = new ArrayList();
List<String> versions = new ArrayList<String>();
versions.add( "2.3-SNAPSHOT" );

populateDb( "org.apache.maven.plugins", "maven-plugin-plugin", versions );
@@ -266,7 +146,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
private void populateHigherSnapshotExistsTest()
throws Exception
{
List versions = new ArrayList();
List<String> versions = new ArrayList<String>();
versions.add( "2.0.3-SNAPSHOT" );

populateDb( "org.apache.maven.plugins", "maven-source-plugin", versions );

+ 35
- 63
archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java View File

@@ -19,8 +19,6 @@ package org.apache.maven.archiva.consumers.core.repository;
* under the License.
*/

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -56,27 +54,20 @@ public class DaysOldRepositoryPurgeTest
{
populateDbForTestByLastModified();

File testDir = new File( "target/test" );
FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
String repoRoot = prepareTestRepo();

setLastModified( "target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/" );
String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-install-plugin";
setLastModified( projectRoot + "/2.2-SNAPSHOT/" );

repoPurge.process( PATH_TO_BY_DAYS_OLD_ARTIFACT );

assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.sha1" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.sha1" ).exists() );

FileUtils.deleteDirectory( testDir );
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" );
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.md5" );
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.sha1" );
}

public void testMetadataDrivenSnapshots()
@@ -84,57 +75,38 @@ public class DaysOldRepositoryPurgeTest
{
populateDbForTestMetadataDrivenSnapshots();

File testDir = new File( "target/test" );
FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
String repoRoot = prepareTestRepo();

repoPurge.process( PATH_TO_BY_DAYS_OLD_METADATA_DRIVEN_ARTIFACT );

String versionRoot = repoRoot + "/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT";
// this should be deleted since the filename version (timestamp) is older than
// 100 days even if the last modified date was <100 days ago
assertFalse( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070113.163208-4.jar" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070113.163208-4.jar.sha1" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070113.163208-4.pom" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070113.163208-4.pom.sha1" ).exists() );
assertDeleted( versionRoot + "/plexus-utils-1.4.3-20070113.163208-4.jar" );
assertDeleted( versionRoot + "/plexus-utils-1.4.3-20070113.163208-4.jar.sha1" );
assertDeleted( versionRoot + "/plexus-utils-1.4.3-20070113.163208-4.pom" );
assertDeleted( versionRoot + "/plexus-utils-1.4.3-20070113.163208-4.pom.sha1" );

// musn't be deleted since the filename version (timestamp) is not older than 100 days
assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070618.102615-5.jar" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070618.102615-5.jar.sha1" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070618.102615-5.pom" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070618.102615-5.pom.sha1" ).exists() );

assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070630.113158-6.jar" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070630.113158-6.jar.sha1" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070630.113158-6.pom" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070630.113158-6.pom.sha1" ).exists() );

assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070707.122114-7.jar" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070707.122114-7.jar.sha1" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070707.122114-7.pom" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-20070707.122114-7.pom.sha1" ).exists() );
assertExists( versionRoot + "/plexus-utils-1.4.3-20070618.102615-5.jar" );
assertExists( versionRoot + "/plexus-utils-1.4.3-20070618.102615-5.jar.sha1" );
assertExists( versionRoot + "/plexus-utils-1.4.3-20070618.102615-5.pom" );
assertExists( versionRoot + "/plexus-utils-1.4.3-20070618.102615-5.pom.sha1" );

// mustn't be deleted since the last modified date is <100 days (this is not a timestamped version)
assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-SNAPSHOT.jar" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT/plexus-utils-1.4.3-SNAPSHOT.pom" ).exists() );
assertExists( versionRoot + "/plexus-utils-1.4.3-20070630.113158-6.jar" );
assertExists( versionRoot + "/plexus-utils-1.4.3-20070630.113158-6.jar.sha1" );
assertExists( versionRoot + "/plexus-utils-1.4.3-20070630.113158-6.pom" );
assertExists( versionRoot + "/plexus-utils-1.4.3-20070630.113158-6.pom.sha1" );

FileUtils.deleteDirectory( testDir );
assertExists( versionRoot + "/plexus-utils-1.4.3-20070707.122114-7.jar" );
assertExists( versionRoot + "/plexus-utils-1.4.3-20070707.122114-7.jar.sha1" );
assertExists( versionRoot + "/plexus-utils-1.4.3-20070707.122114-7.pom" );
assertExists( versionRoot + "/plexus-utils-1.4.3-20070707.122114-7.pom.sha1" );

// mustn't be deleted since the last modified date is <100 days (this is not a timestamped version)
assertExists( versionRoot + "/plexus-utils-1.4.3-SNAPSHOT.jar" );
assertExists( versionRoot + "/plexus-utils-1.4.3-SNAPSHOT.pom" );
}

protected void tearDown()
@@ -147,7 +119,7 @@ public class DaysOldRepositoryPurgeTest
private void populateDbForTestByLastModified()
throws Exception
{
List versions = new ArrayList();
List<String> versions = new ArrayList<String>();
versions.add( "2.2-SNAPSHOT" );

populateDb( "org.apache.maven.plugins", "maven-install-plugin", versions );
@@ -156,7 +128,7 @@ public class DaysOldRepositoryPurgeTest
private void populateDbForTestMetadataDrivenSnapshots()
throws Exception
{
List versions = new ArrayList();
List<String> versions = new ArrayList<String>();
versions.add( "1.4.3-20070113.163208-4" );
versions.add( "1.4.3-20070618.102615-5" );
versions.add( "1.4.3-20070630.113158-6" );

+ 92
- 199
archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java View File

@@ -24,16 +24,10 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.maven.archiva.database.ArchivaDatabaseException;
import org.codehaus.plexus.util.IOUtil;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import org.jdom.xpath.XPath;
import org.custommonkey.xmlunit.XMLAssert;

import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
@@ -42,9 +36,9 @@ import java.util.List;
public class RepositoryPurgeConsumerTest
extends AbstractRepositoryPurgeTest
{
private void setLastModified()
private void setLastModified( String path )
{
File dir = new File( "target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/" );
File dir = new File( path );
File[] contents = dir.listFiles();
for ( int i = 0; i < contents.length; i++ )
{
@@ -67,66 +61,41 @@ public class RepositoryPurgeConsumerTest
repoPurgeConsumer.beginScan( repoConfiguration );

File testDir = new File( "target/test" );
FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
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
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.sha1" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.sha1" ).exists() );

assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.sha1" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.sha1" ).exists() );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.md5" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.sha1" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.md5" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.sha1" );

assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.md5" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.sha1" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.md5" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.sha1" );

// assert if not removed from repo
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.sha1" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.sha1" ).exists() );

assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.sha1" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.sha1" ).exists() );

FileUtils.deleteDirectory( testDir );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.md5" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.sha1" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.md5" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.sha1" );

assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.md5" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.sha1" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.md5" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.sha1" );
}

private void addRepoToConfiguration( String configHint, ManagedRepositoryConfiguration repoConfiguration )
@@ -151,29 +120,27 @@ public class RepositoryPurgeConsumerTest

repoPurgeConsumer.beginScan( repoConfiguration );

File testDir = new File( "target/test" );
FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
String repoRoot = prepareTestRepo();
String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-install-plugin";

setLastModified();
setLastModified( projectRoot + "/2.2-SNAPSHOT" );

repoPurgeConsumer.processFile( PATH_TO_BY_DAYS_OLD_ARTIFACT );

assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.sha1" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.sha1" ).exists() );

FileUtils.deleteDirectory( testDir );
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" );
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.md5" );
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.sha1" );
}

/**
* Test the snapshot clean consumer on a repository set to NOT clean/delete snapshots
* based on released versions.
*
* @throws Exception
*/
public void testReleasedSnapshotsWereNotCleaned()
throws Exception
{
@@ -183,74 +150,37 @@ public class RepositoryPurgeConsumerTest
populateDbForReleasedSnapshotsTest();

ManagedRepositoryConfiguration repoConfiguration = getRepoConfiguration();
repoConfiguration.setDeleteReleasedSnapshots( false );
repoConfiguration.setDeleteReleasedSnapshots( false ); // Set to NOT delete released snapshots.
addRepoToConfiguration( "retention-count", repoConfiguration );
repoPurgeConsumer.beginScan( repoConfiguration );

File testDir = new File( "target/test" );
FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
String repoRoot = prepareTestRepo();

repoPurgeConsumer.processFile( PATH_TO_RELEASED_SNAPSHOT );

// check if the snapshot wasn't removed
assertTrue(
new File( "target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.sha1" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" ).exists() );
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" );
assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.sha1" );
assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom" );
assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.md5" );
assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" );

// check if metadata file wasn't updated
File artifactMetadataFile =
new File( "target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/maven-metadata-local.xml" );

FileReader fileReader = new FileReader( artifactMetadataFile );
Document document;

try
{
SAXBuilder builder = new SAXBuilder();
document = builder.build( fileReader );
}
finally
{
IOUtil.close( fileReader );
}

// parse the metadata file
XPath xPath = XPath.newInstance( "//metadata/versioning" );
Element rootElement = document.getRootElement();

Element versioning = (Element) xPath.selectSingleNode( rootElement );
Element el = (Element) xPath.newInstance( "./latest" ).selectSingleNode( versioning );
assertEquals( "2.3-SNAPSHOT", el.getValue() );
File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );

el = (Element) xPath.newInstance( "./lastUpdated" ).selectSingleNode( versioning );
assertTrue( el.getValue().equals( "20070315032817" ) );

List nodes = xPath.newInstance( "./versions" ).selectNodes( versioning );

boolean found = false;
for ( Iterator iter = nodes.iterator(); iter.hasNext(); )
{
el = (Element) iter.next();
if ( el.getValue().trim().equals( "2.3-SNAPSHOT" ) )
{
found = true;
}
}
assertTrue( found );

FileUtils.deleteDirectory( testDir );
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 );
}

public void testReleasedSnapshotsWereCleaned()
@@ -267,75 +197,39 @@ public class RepositoryPurgeConsumerTest
repoPurgeConsumer.beginScan( repoConfiguration );

File testDir = new File( "target/test" );
FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
String repoRoot = prepareTestRepo();

repoPurgeConsumer.processFile( PATH_TO_RELEASED_SNAPSHOT );

String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-plugin-plugin";

// check if the snapshot was removed
assertFalse(
new File( "target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.sha1" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" ).exists() );
assertDeleted( projectRoot + "/2.3-SNAPSHOT" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.md5" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.sha1" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.md5" );
assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" );

// check if metadata file was updated
File artifactMetadataFile =
new File( "target/test/test-repo/org/apache/maven/plugins/maven-plugin-plugin/maven-metadata.xml" );

FileReader fileReader = new FileReader( artifactMetadataFile );
Document document;

try
{
SAXBuilder builder = new SAXBuilder();
document = builder.build( fileReader );
}
finally
{
IOUtil.close( fileReader );
}

// parse the metadata file
XPath xPath = XPath.newInstance( "//metadata/versioning" );
Element rootElement = document.getRootElement();

Element versioning = (Element) xPath.selectSingleNode( rootElement );
Element el = (Element) xPath.newInstance( "./latest" ).selectSingleNode( versioning );
assertEquals( "2.3", el.getValue() );

el = (Element) xPath.newInstance( "./lastUpdated" ).selectSingleNode( versioning );
// FIXME: assertFalse( el.getValue().equals( "20070315032817" ) );

List nodes = xPath.newInstance( "./versions" ).selectNodes( rootElement );

boolean found = false;
for ( Iterator iter = nodes.iterator(); iter.hasNext(); )
{
el = (Element) iter.next();
if ( el.getValue().equals( "2.3-SNAPSHOT" ) )
{
found = true;
}
}
assertFalse( found );

FileUtils.deleteDirectory( testDir );
}
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>";
XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/latest", metadataXml );
XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions,
"//metadata/versioning/versions/version", metadataXml );
// FIXME [MRM-535]: XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
}

public void populateDbForRetentionCountTest()
throws ArchivaDatabaseException
{
List versions = new ArrayList();
List<String> versions = new ArrayList<String>();
versions.add( "1.0RC1-20070504.153317-1" );
versions.add( "1.0RC1-20070504.160758-2" );
versions.add( "1.0RC1-20070505.090015-3" );
@@ -347,7 +241,7 @@ public class RepositoryPurgeConsumerTest
private void populateDbForDaysOldTest()
throws ArchivaDatabaseException
{
List versions = new ArrayList();
List<String> versions = new ArrayList<String>();
versions.add( "2.2-SNAPSHOT" );

populateDb( "org.apache.maven.plugins", "maven-install-plugin", versions );
@@ -356,10 +250,9 @@ public class RepositoryPurgeConsumerTest
public void populateDbForReleasedSnapshotsTest()
throws ArchivaDatabaseException
{
List versions = new ArrayList();
List<String> versions = new ArrayList<String>();
versions.add( "2.3-SNAPSHOT" );

populateDb( "org.apache.maven.plugins", "maven-plugin-plugin", versions );
}

}

+ 59
- 114
archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java View File

@@ -19,9 +19,6 @@ package org.apache.maven.archiva.consumers.core.repository;
* under the License.
*/

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

@@ -53,67 +50,41 @@ public class RetentionCountRepositoryPurgeTest
{
populateIfJarWasFoundDb();

File testDir = new File( "target/test" );
testDir.mkdir();
FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
String repoRoot = prepareTestRepo();

repoPurge.process( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
String versionRoot = repoRoot + "/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT";

// assert if removed from repo
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.sha1" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.sha1" ).exists() );

assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.sha1" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.sha1" ).exists() );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.md5" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.sha1" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.md5" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.sha1" );

assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.md5" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.sha1" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.md5" );
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.sha1" );

// assert if not removed from repo
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.sha1" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.sha1" ).exists() );

assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.sha1" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.sha1" ).exists() );

FileUtils.deleteDirectory( testDir );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.md5" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.sha1" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.md5" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.sha1" );

assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.md5" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.sha1" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.md5" );
assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.sha1" );
}

/**
@@ -126,72 +97,46 @@ public class RetentionCountRepositoryPurgeTest
{
populateIfPomWasFoundDb();

File testDir = new File( "target/test" );
testDir.mkdir();
FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
String repoRoot = prepareTestRepo();

repoPurge.process( PATH_TO_BY_RETENTION_COUNT_POM );

String versionRoot = repoRoot + "/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT";
// assert if removed from repo
assertFalse( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070427.065136-1.jar" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070427.065136-1.jar.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070427.065136-1.jar.sha1" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070427.065136-1.pom" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070427.065136-1.pom.md5" ).exists() );
assertFalse( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070427.065136-1.pom.sha1" ).exists() );
assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.jar" );
assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.jar.md5" );
assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.jar.sha1" );
assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.pom" );
assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.pom.md5" );
assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.pom.sha1" );

// assert if not removed from repo
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3.pom" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3.pom.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3.pom.sha1" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3.jar" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3.jar.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3.jar.sha1" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3-sources.jar" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3-sources.jar.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3-sources.jar.sha1" ).exists() );

assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.pom" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.pom.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.pom.sha1" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.jar" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.jar.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.jar.sha1" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2-sources.jar" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2-sources.jar.md5" ).exists() );
assertTrue( new File(
"target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2-sources.jar.sha1" ).exists() );

FileUtils.deleteDirectory( testDir );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.pom" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.pom.md5" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.pom.sha1" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.jar" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.jar.md5" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.jar.sha1" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3-sources.jar" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3-sources.jar.md5" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3-sources.jar.sha1" );

assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.pom" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.pom.md5" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.pom.sha1" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.jar" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.jar.md5" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.jar.sha1" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2-sources.jar" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2-sources.jar.md5" );
assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2-sources.jar.sha1" );
}

public void populateIfJarWasFoundDb()
throws Exception
{
List versions = new ArrayList();
List<String> versions = new ArrayList<String>();
versions.add( "1.0RC1-20070504.153317-1" );
versions.add( "1.0RC1-20070504.160758-2" );
versions.add( "1.0RC1-20070505.090015-3" );
@@ -203,7 +148,7 @@ public class RetentionCountRepositoryPurgeTest
public void populateIfPomWasFoundDb()
throws Exception
{
List versions = new ArrayList();
List<String> versions = new ArrayList<String>();
versions.add( "1.1.2-20070427.065136-1" );
versions.add( "1.1.2-20070615.105019-3" );
versions.add( "1.1.2-20070506.163513-2" );

archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-metadata-local.xml → archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-metadata.xml View File


archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-metadata-local.xml → archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-metadata.xml View File


archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/maven-metadata-local.xml → archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/maven-metadata.xml View File


archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.3-SNAPSHOT/maven-metadata-local.xml → archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.3-SNAPSHOT/maven-metadata.xml View File


archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.4-SNAPSHOT/maven-metadata-local.xml → archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.4-SNAPSHOT/maven-metadata.xml View File


archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/maven-metadata-local.xml → archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml View File


Loading…
Cancel
Save