You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by jo...@apache.org on 2007/10/12 19:49:43 UTC
svn commit: r584213 - in
/maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers:
./ src/main/java/org/apache/maven/archiva/consumers/core/repository/
src/test/java/org/apache/maven/archiva/consumers/core/repository/
src/test/resourc...
Author: joakime
Date: Fri Oct 12 10:49:40 2007
New Revision: 584213
URL: http://svn.apache.org/viewvc?rev=584213&view=rev
Log:
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.
Added:
maven/archiva/trunk/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
- copied unchanged from r582995, maven/archiva/trunk/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
maven/archiva/trunk/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
- copied unchanged from r582995, maven/archiva/trunk/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
maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/maven-metadata.xml
- copied unchanged from r582995, maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/maven-metadata-local.xml
maven/archiva/trunk/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
- copied unchanged from r582995, maven/archiva/trunk/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
maven/archiva/trunk/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
- copied unchanged from r582995, maven/archiva/trunk/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
maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml
- copied unchanged from r582995, maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/maven-metadata-local.xml
Removed:
maven/archiva/trunk/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
maven/archiva/trunk/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
maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/maven-metadata-local.xml
maven/archiva/trunk/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
maven/archiva/trunk/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
maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/maven-metadata-local.xml
Modified:
maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurge.java
maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java
maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java
maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java
Modified: maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml?rev=584213&r1=584212&r2=584213&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml (original)
+++ maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml Fri Oct 12 10:49:40 2007
@@ -60,5 +60,10 @@
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified: maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurge.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurge.java?rev=584213&r1=584212&r2=584213&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurge.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurge.java Fri Oct 12 10:49:40 2007
@@ -88,7 +88,6 @@
{
File artifactFile = repository.toFile( reference );
- System.err.println( "Purging: " + artifactFile.getAbsolutePath() );
artifactFile.delete();
purgeSupportFiles( artifactFile );
@@ -139,7 +138,6 @@
if ( file.exists() && file.isFile() )
{
file.delete();
- System.err.println( "Deleting support file: " + file.getAbsolutePath() );
// TODO: log that it was deleted?
}
}
Modified: maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java?rev=584213&r1=584212&r2=584213&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java Fri Oct 12 10:49:40 2007
@@ -116,8 +116,6 @@
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 );
Modified: maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java?rev=584213&r1=584212&r2=584213&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java Fri Oct 12 10:49:40 2007
@@ -19,6 +19,7 @@
* 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.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 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 @@
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 @@
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 @@
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 @@
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() );
@@ -197,5 +201,30 @@
savedArtifact = dao.saveArtifact( artifact );
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();
}
}
Modified: maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java?rev=584213&r1=584212&r2=584213&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java Fri Oct 12 10:49:40 2007
@@ -22,16 +22,10 @@
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 @@
super.setUp();
MetadataTools metadataTools = (MetadataTools) lookup( MetadataTools.class );
-
+
repoPurge = new CleanupReleasedSnapshotsRepositoryPurge( getRepository(), dao, metadataTools );
}
@@ -55,105 +49,46 @@
{
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 );
+ File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
- FileUtils.deleteDirectory( testDir );
+ 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 @@
{
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 );
+ File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
- FileUtils.deleteDirectory( testDir );
+ 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 @@
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 );
Modified: maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java?rev=584213&r1=584212&r2=584213&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java Fri Oct 12 10:49:40 2007
@@ -19,8 +19,6 @@
* 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 @@
{
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 @@
{
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" );
+
+ 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" );
+
+ 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)
- 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() );
-
- FileUtils.deleteDirectory( testDir );
+ 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 @@
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 @@
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" );
Modified: maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java?rev=584213&r1=584212&r2=584213&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java Fri Oct 12 10:49:40 2007
@@ -24,16 +24,10 @@
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 @@
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 @@
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 @@
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 @@
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();
+ File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
- Element versioning = (Element) xPath.selectSingleNode( rootElement );
- Element el = (Element) xPath.newInstance( "./latest" ).selectSingleNode( versioning );
- assertEquals( "2.3-SNAPSHOT", el.getValue() );
-
- 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 @@
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 @@
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 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 );
}
-
}
Modified: maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java?rev=584213&r1=584212&r2=584213&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java Fri Oct 12 10:49:40 2007
@@ -19,9 +19,6 @@
* 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 @@
{
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 @@
{
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 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" );