archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r569789 [1/2] - in /maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test: conf/ java/org/apache/maven/archiva/consumers/core/repository/ resources/org/apache/maven/archiva/consumers/core/repository/ resources/t...
Date Sun, 26 Aug 2007 09:42:32 GMT
Author: oching
Date: Sun Aug 26 02:42:27 2007
New Revision: 569789

URL: http://svn.apache.org/viewvc?rev=569789&view=rev
Log:
[MRM-453]
- Added tests for RepositoryConsumer and CleanupReleasedSnapshotsRepositoryPurge
- Added test data for the new tests
- Refactored AbstractRepositoryPurgeTest, DaysOldRepositoryPurgeTest and RetentionCountRepositoryPurgeTest


Added:
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager-daysOld.xml
    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/RepositoryPurgeConsumerTest.java
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.xml
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.xml
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.2/
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.2/maven-plugin-plugin-2.2.jar   (with props)
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.2/maven-plugin-plugin-2.2.jar.md5
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.2/maven-plugin-plugin-2.2.jar.sha1
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.2/maven-plugin-plugin-2.2.pom
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.2/maven-plugin-plugin-2.2.pom.md5
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.2/maven-plugin-plugin-2.2.pom.sha1
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/
    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/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/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar   (with props)
    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-plugin-plugin-2.3-SNAPSHOT.jar.md5
    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-plugin-plugin-2.3-SNAPSHOT.jar.sha1
    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-plugin-plugin-2.3-SNAPSHOT.pom
    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-plugin-plugin-2.3-SNAPSHOT.pom.md5
    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-plugin-plugin-2.3-SNAPSHOT.pom.sha1
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3-sources.jar   (with props)
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3-sources.jar.md5
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3-sources.jar.sha1
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3.jar   (with props)
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3.jar.md5
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3.jar.sha1
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3.pom
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3.pom.md5
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-plugin-plugin/2.3/maven-plugin-plugin-2.3.pom.sha1
    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/
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.2/
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.2/maven-source-plugin-2.0.2-sources.jar   (with props)
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.2/maven-source-plugin-2.0.2-sources.jar.md5
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.2/maven-source-plugin-2.0.2-sources.jar.sha1
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.2/maven-source-plugin-2.0.2.jar   (with props)
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.2/maven-source-plugin-2.0.2.jar.md5
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.2/maven-source-plugin-2.0.2.jar.sha1
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.2/maven-source-plugin-2.0.2.pom
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.2/maven-source-plugin-2.0.2.pom.md5
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/test-repo/org/apache/maven/plugins/maven-source-plugin/2.0.2/maven-source-plugin-2.0.2.pom.sha1
    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/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.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.jar   (with props)
    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-source-plugin-2.0.3-SNAPSHOT.jar.md5
    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-source-plugin-2.0.3-SNAPSHOT.jar.sha1
    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-source-plugin-2.0.3-SNAPSHOT.pom
    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-source-plugin-2.0.3-SNAPSHOT.pom.md5
    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-source-plugin-2.0.3-SNAPSHOT.pom.sha1
    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/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/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.jar   (with props)
    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-source-plugin-2.0.4-SNAPSHOT.jar.md5
    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-source-plugin-2.0.4-SNAPSHOT.jar.sha1
    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-source-plugin-2.0.4-SNAPSHOT.pom
    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-source-plugin-2.0.4-SNAPSHOT.pom.md5
    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-source-plugin-2.0.4-SNAPSHOT.pom.sha1
    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/src/test/conf/repository-manager.xml
    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/DaysOldRepositoryPurgeTest.java
    maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java

Added: maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager-daysOld.xml
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager-daysOld.xml?rev=569789&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager-daysOld.xml (added)
+++ maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager-daysOld.xml Sun Aug 26 02:42:27 2007
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<configuration>
+  <version>1</version>
+  <repositories>
+    <repository>
+      <id>internal</id>
+      <name>Archiva Managed Internal Repository</name>
+      <url>file://${appserver.base}/repositories/internal</url>
+      <layout>default</layout>
+      <releases>true</releases>
+      <snapshots>false</snapshots>
+      <indexed>true</indexed>
+      <refreshCronExpression>0 0 * * ?</refreshCronExpression>
+    </repository>
+    <repository>
+      <id>snapshots</id>
+      <name>Archiva Managed Snapshot Repository</name>
+      <url>file://${appserver.base}/repositories/internal</url>
+      <layout>default</layout>
+      <releases>false</releases>
+      <snapshots>true</snapshots>
+      <indexed>true</indexed>
+      <refreshCronExpression>0 0,30 * * ?</refreshCronExpression>
+    </repository>
+    <repository>
+      <id>central</id>
+      <name>Central Repository</name>
+      <url>http://repo1.maven.org/maven2</url>
+      <layout>default</layout>
+      <releases>true</releases>
+      <snapshots>false</snapshots>
+      <indexed>false</indexed>
+    </repository>
+    <repository>
+      <id>maven2-repository.dev.java.net</id>
+      <name>Java.net Repository for Maven 2</name>
+      <url>https://maven2-repository.dev.java.net/nonav/repository</url>
+      <layout>default</layout>
+      <releases>true</releases>
+      <snapshots>false</snapshots>
+      <indexed>false</indexed>
+    </repository>
+    <repository>
+      <id>test-repo</id>
+      <name>Test Repository</name>
+      <url>file://${appserver.base}/repositories/test-repo</url>
+      <layout>default</layout>
+      <releases>true</releases>
+      <snapshots>true</snapshots>
+      <indexed>true</indexed>
+      <refreshCronExpression>0 0 * * ?</refreshCronExpression>
+      <daysOlder>100</daysOlder>
+      <deleteReleasedSnapshots>true</deleteReleasedSnapshots>
+    </repository>
+  </repositories>
+
+  <proxyConnectors>
+    <proxyConnector>
+      <sourceRepoId>internal</sourceRepoId>
+      <targetRepoId>central</targetRepoId>
+      <proxyId/>
+      <snapshotsPolicy>disabled</snapshotsPolicy>
+      <releasePolicy>never</releasePolicy>
+      <failurePolicy>not-found</failurePolicy>
+    </proxyConnector>
+    <proxyConnector>
+      <sourceRepoId>internal</sourceRepoId>
+      <targetRepoId>maven2-repository.dev.java.net</targetRepoId>
+      <proxyId/>
+      <snapshotsPolicy>disabled</snapshotsPolicy>
+      <releasePolicy>never</releasePolicy>
+      <failurePolicy>not-found</failurePolicy>
+      <whiteListPatterns>
+        <whiteListPattern>javax/**</whiteListPattern>
+      </whiteListPatterns>
+    </proxyConnector>
+  </proxyConnectors>
+
+  <networkProxies>
+    <networkProxy>
+      <id>example</id>
+      <protocol>http</protocol>
+      <host>proxy.mycompany.com</host>
+      <port>8080</port>
+      <username>myself</username>
+      <password>mypass</password>
+    </networkProxy>
+  </networkProxies>
+
+  <repositoryScanning>
+    <fileTypes>
+      <fileType>
+        <id>artifacts</id>
+        <patterns>
+          <pattern>**/*.pom</pattern>
+          <pattern>**/*.jar</pattern>
+          <pattern>**/*.ear</pattern>
+          <pattern>**/*.war</pattern>
+          <pattern>**/*.car</pattern>
+          <pattern>**/*.sar</pattern>
+          <pattern>**/*.mar</pattern>
+          <pattern>**/*.rar</pattern>
+          <pattern>**/*.dtd</pattern>
+          <pattern>**/*.tld</pattern>
+          <pattern>**/*.tar.gz</pattern>
+          <pattern>**/*.tar.bz2</pattern>
+          <pattern>**/*.zip</pattern>
+        </patterns>
+      </fileType>
+      <fileType>
+        <id>indexable-content</id>
+        <patterns>
+          <pattern>**/*.txt</pattern>
+          <pattern>**/*.TXT</pattern>
+          <pattern>**/*.block</pattern>
+          <pattern>**/*.config</pattern>
+          <pattern>**/*.pom</pattern>
+          <pattern>**/*.xml</pattern>
+          <pattern>**/*.xsd</pattern>
+          <pattern>**/*.dtd</pattern>
+          <pattern>**/*.tld</pattern>
+        </patterns>
+      </fileType>
+      <fileType>
+        <id>auto-remove</id>
+        <patterns>
+          <pattern>**/*.bak</pattern>
+          <pattern>**/*~</pattern>
+          <pattern>**/*-</pattern>
+        </patterns>
+      </fileType>
+      <fileType>
+        <id>ignored</id>
+        <patterns>
+          <pattern>**/.htaccess</pattern>
+          <pattern>**/KEYS</pattern>
+          <pattern>**/*.rb</pattern>
+          <pattern>**/*.sh</pattern>
+          <pattern>**/.svn/**</pattern>
+          <pattern>**/.DAV/**</pattern>
+        </patterns>
+      </fileType>
+    </fileTypes>
+    <knownContentConsumers>
+      <knownContentConsumer>update-db-artifact</knownContentConsumer>
+      <knownContentConsumer>create-missing-checksums</knownContentConsumer>
+      <knownContentConsumer>update-db-repository-metadata</knownContentConsumer>
+      <knownContentConsumer>validate-checksum</knownContentConsumer>
+      <knownContentConsumer>validate-signature</knownContentConsumer>
+      <knownContentConsumer>index-content</knownContentConsumer>
+      <knownContentConsumer>auto-remove</knownContentConsumer>
+      <knownContentConsumer>auto-rename</knownContentConsumer>
+      <knownContentConsumer>repository-purge</knownContentConsumer>
+    </knownContentConsumers>
+    <invalidContentConsumers>
+      <invalidContentConsumer>update-db-bad-content</invalidContentConsumer>
+    </invalidContentConsumers>
+  </repositoryScanning>
+
+  <databaseScanning>
+    <cronExpression>0 0 * * ?</cronExpression>
+    <unprocessedConsumers>
+      <unprocessedConsumer>index-artifact</unprocessedConsumer>
+      <unprocessedConsumer>update-db-project</unprocessedConsumer>
+      <unprocessedConsumer>validate-repository-metadata</unprocessedConsumer>
+      <unprocessedConsumer>index-archive-toc</unprocessedConsumer>
+      <unprocessedConsumer>update-db-bytecode-stats</unprocessedConsumer>
+      <unprocessedConsumer>index-public-methods</unprocessedConsumer>
+    </unprocessedConsumers>
+    <cleanupConsumers>
+      <cleanupConsumer>not-present-remove-db-artifact</cleanupConsumer>
+      <cleanupConsumer>not-present-remove-db-project</cleanupConsumer>
+      <cleanupConsumer>not-present-remove-indexed</cleanupConsumer>
+    </cleanupConsumers>
+  </databaseScanning>
+
+  <webapp>
+    <ui>
+      <showFindArtifacts>true</showFindArtifacts>
+      <appletFindEnabled>true</appletFindEnabled>
+    </ui>
+  </webapp>
+
+</configuration>

Modified: maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager.xml
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager.xml?rev=569789&r1=569788&r2=569789&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager.xml (original)
+++ maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager.xml Sun Aug 26 02:42:27 2007
@@ -68,6 +68,7 @@
       <snapshots>true</snapshots>
       <indexed>true</indexed>
       <refreshCronExpression>0 0 * * ?</refreshCronExpression>
+      <daysOlder>0</daysOlder>
       <retentionCount>2</retentionCount>
     </repository>
   </repositories>

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=569789&r1=569788&r2=569789&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 Sun Aug 26 02:42:27 2007
@@ -22,23 +22,23 @@
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
 import org.codehaus.plexus.jdo.JdoFactory;
-import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.RepositoryConfiguration;
 import org.apache.maven.archiva.model.ArchivaRepository;
+import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
 import org.apache.maven.archiva.repository.layout.LayoutException;
 import org.apache.maven.archiva.repository.layout.DefaultBidirectionalRepositoryLayout;
-import org.apache.maven.archiva.database.ArchivaDAO;
 import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
 import org.jpox.SchemaTool;
 
 import javax.jdo.PersistenceManagerFactory;
 import javax.jdo.PersistenceManager;
-import java.util.List;
-import java.util.ArrayList;
 import java.util.Properties;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.List;
+import java.util.Date;
 import java.net.URL;
 import java.io.File;
 
@@ -52,12 +52,27 @@
 
     public static final String TEST_REPO_NAME = "Test Repository";
 
-    public static final String TEST_REPO_URL = "file://" + getBasedir() + "/target/test-classes/test-repo/";
+    public static final String TEST_REPO_URL = "file://" + getBasedir() + "/target/test/test-repo/";
 
     public static final int TEST_RETENTION_COUNT = 2;
 
     public static final int TEST_DAYS_OLDER = 30;
 
+    public static final String PATH_TO_BY_DAYS_OLD_ARTIFACT =
+           "org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar";
+
+    public static final String PATH_TO_BY_RETENTION_COUNT_ARTIFACT =
+        "org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar";
+
+    public static final String PATH_TO_BY_RETENTION_COUNT_POM =
+        "org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.pom";
+
+    public static final String PATH_TO_RELEASED_SNAPSHOT =
+        "org/apache/maven/plugins/maven-plugin-plugin/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar";
+
+    public static final String PATH_TO_HIGHER_SNAPSHOT_EXISTS =
+        "org/apache/maven/plugins/maven-source-plugin/2.0.3-SNAPSHOT/maven-source-plugin-2.0.3-SNAPSHOT.jar";
+
     private RepositoryConfiguration config;
 
     private ArchivaRepository repo;
@@ -173,5 +188,31 @@
         }
 
         return layout;
+    }
+
+    protected void populateDb( String groupId, String artifactId, List versions )
+        throws ArchivaDatabaseException
+    {
+        for( Iterator iter = versions.iterator(); iter.hasNext(); )
+        {
+            String version = (String) iter.next();
+            
+            ArchivaArtifact artifact =
+            dao.createArtifact( groupId, artifactId, version, "", "jar" );
+            assertNotNull( artifact );
+            artifact.getModel().setLastModified( new Date() );
+            artifact.getModel().setOrigin( "test" );
+            ArchivaArtifact savedArtifact = dao.saveArtifact( artifact );
+            assertNotNull( savedArtifact );
+
+            //POM
+            artifact =
+                dao.createArtifact( groupId, artifactId, version, "", "pom" );
+            assertNotNull( artifact );
+            artifact.getModel().setLastModified( new Date() );
+            artifact.getModel().setOrigin( "test" );
+            savedArtifact = dao.saveArtifact( artifact );
+            assertNotNull( savedArtifact );
+        }
     }
 }

Added: 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=569789&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java (added)
+++ maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java Sun Aug 26 02:42:27 2007
@@ -0,0 +1,249 @@
+package org.apache.maven.archiva.consumers.core.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.commons.io.FileUtils;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.xpath.XPath;
+import org.jdom.input.SAXBuilder;
+import org.codehaus.plexus.util.IOUtil;
+
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.io.File;
+import java.io.FileReader;
+
+/**
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ */
+public class CleanupReleasedSnapshotsRepositoryPurgeTest
+    extends AbstractRepositoryPurgeTest
+{
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        repoPurge = new CleanupReleasedSnapshotsRepositoryPurge( getRepository(), getLayout(), dao );
+    }      
+
+    public void testReleasedSnapshots()
+        throws Exception
+    {
+        populateReleasedSnapshotsTest();
+
+        File testDir = new File( "target/test" );
+        FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
+
+        repoPurge.process( PATH_TO_RELEASED_SNAPSHOT );
+
+        // 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() );
+
+        // 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() );
+
+
+        // check if metadata file was 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", el.getValue() );
+
+        el = (Element) xPath.newInstance( "./lastUpdated" ).selectSingleNode( versioning );
+        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 );
+    }
+
+    public void testHigherSnapshotExists()
+        throws Exception
+    {             
+        populateHigherSnapshotExistsTest();
+
+        File testDir = new File( "target/test" );
+        FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
+
+        repoPurge.process( PATH_TO_HIGHER_SNAPSHOT_EXISTS );
+
+        // 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() );
+
+        // 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() );
+
+        // check if metadata file was updated
+        File artifactMetadataFile =
+            new File( "target/test/test-repo/org/apache/maven/plugins/maven-source-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.0.4-SNAPSHOT", el.getValue() );
+
+        el = (Element) xPath.newInstance( "./lastUpdated" ).selectSingleNode( versioning );
+        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 );
+    }
+
+    private void populateReleasedSnapshotsTest()
+        throws ArchivaDatabaseException
+    {
+        List versions = new ArrayList();
+        versions.add( "2.3-SNAPSHOT" );
+
+        populateDb( "org.apache.maven.plugins", "maven-plugin-plugin", versions );
+    }
+
+    private void populateHigherSnapshotExistsTest()
+        throws Exception
+    {
+        List versions = new ArrayList();
+        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=569789&r1=569788&r2=569789&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 Sun Aug 26 02:42:27 2007
@@ -1,35 +1,37 @@
 package org.apache.maven.archiva.consumers.core.repository;
 
-import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
-import org.codehaus.plexus.jdo.JdoFactory;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.RepositoryConfiguration;
-import org.apache.maven.archiva.model.ArchivaRepository;
-import org.apache.maven.archiva.model.ArchivaArtifactModel;
-import org.apache.maven.archiva.model.ArchivaArtifact;
-import org.apache.maven.archiva.database.ArtifactDAO;
-import org.apache.maven.archiva.database.ArchivaDAO;
-import org.apache.maven.archiva.database.jdo.JdoAccess;
-
-import javax.jdo.JDOFatalUserException;
-import javax.jdo.JDOHelper;
-import javax.jdo.spi.JDOImplHelper;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.io.FileUtils;
+
 import java.util.List;
 import java.util.ArrayList;
-import java.util.Date;
 import java.io.File;
 
-
 /**
  * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
  */
 public class DaysOldRepositoryPurgeTest
     extends AbstractRepositoryPurgeTest
 {
-    public static final String PATH_TO_BY_DAYS_OLD_ARTIFACT =
-        "org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar";
-
+   
     protected void setUp()
         throws Exception
     {
@@ -41,7 +43,7 @@
     private void setLastModified()
     {
         File dir =
-            new File( "target/test-classes/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/" );
+            new File( "target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/" );
         File[] contents = dir.listFiles();
         for ( int i = 0; i < contents.length; i++ )
         {
@@ -53,25 +55,28 @@
         throws Exception
     {
         populateDb();
-        
+
+        File testDir = new File( "target/test" );
+        FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
+
         setLastModified();
 
         repoPurge.process( PATH_TO_BY_DAYS_OLD_ARTIFACT );
 
-        assertTrue( true );
-
         assertFalse( new File(
-            "target/test-classes/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar" ).exists() );
+            "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-classes/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.md5" ).exists() );
+            "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-classes/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.sha1" ).exists() );
+            "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-classes/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom" ).exists() );
+            "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-classes/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.md5" ).exists() );
+            "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-classes/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.sha1" ).exists() );
+            "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 );
     }
 
     protected void tearDown()
@@ -84,25 +89,9 @@
     private void populateDb()
         throws Exception
     {
-        // Create it
-        ArchivaArtifact artifact =
-            dao.createArtifact( "org.apache.maven.plugins", "maven-install-plugin", "2.2-SNAPSHOT", "", "jar" );
-        assertNotNull( artifact );
-
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-
-        // Save it.
-        ArchivaArtifact savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
-
-        //POM
-        artifact =
-            dao.createArtifact( "org.apache.maven.plugins", "maven-install-plugin", "2.2-SNAPSHOT", "", "pom" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-        savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
+        List versions = new ArrayList();
+        versions.add( "2.2-SNAPSHOT" );
+
+        populateDb( "org.apache.maven.plugins", "maven-install-plugin", versions );
     }
 }

Added: 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=569789&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java (added)
+++ maven/archiva/trunk/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java Sun Aug 26 02:42:27 2007
@@ -0,0 +1,347 @@
+package org.apache.maven.archiva.consumers.core.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.commons.io.FileUtils;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.xpath.XPath;
+import org.jdom.input.SAXBuilder;
+import org.codehaus.plexus.util.IOUtil;
+
+import java.io.File;
+import java.io.FileReader;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ */
+public class RepositoryPurgeConsumerTest
+    extends AbstractRepositoryPurgeTest
+{
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+    }
+
+    private void setLastModified()
+    {
+        File dir =
+            new File( "target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/" );
+        File[] contents = dir.listFiles();
+        for ( int i = 0; i < contents.length; i++ )
+        {
+            contents[i].setLastModified( 1179382029 );
+        }
+    }
+
+    public void testConsumerByRetentionCount()
+        throws Exception
+    {
+        KnownRepositoryContentConsumer repoPurgeConsumer = ( KnownRepositoryContentConsumer )
+            lookup( KnownRepositoryContentConsumer.class, "repo-purge-consumer-by-retention-count" );
+
+        populateDbForRetentionCountTest();
+
+        repoPurgeConsumer.beginScan( getRepository() );
+
+        File testDir = new File( "target/test" );
+        FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
+                
+        repoPurgeConsumer.processFile( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
+
+        // 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() );
+
+        // 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 );
+    }
+
+    public void testConsumerByDaysOld()
+        throws Exception
+    {
+        populateDbForDaysOldTest();
+
+        KnownRepositoryContentConsumer repoPurgeConsumer = ( KnownRepositoryContentConsumer )
+                    lookup( KnownRepositoryContentConsumer.class, "repo-purge-consumer-by-days-old" );
+
+        repoPurgeConsumer.beginScan( getRepository() );
+
+        File testDir = new File( "target/test" );
+        FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
+
+        setLastModified();
+        
+        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 );
+    }
+
+    public void testReleasedSnapshotsWereNotCleaned()
+        throws Exception
+    {
+        KnownRepositoryContentConsumer repoPurgeConsumer = ( KnownRepositoryContentConsumer )
+            lookup( KnownRepositoryContentConsumer.class, "repo-purge-consumer-by-retention-count" );
+
+        populateDbForReleasedSnapshotsTest();
+
+        repoPurgeConsumer.beginScan( getRepository() );
+
+        File testDir = new File( "target/test" );
+        FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
+
+        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() );
+
+        // 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() );
+
+        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 );
+    }
+
+    public void testReleasedSnapshotsWereCleaned()
+        throws Exception
+    {
+        KnownRepositoryContentConsumer repoPurgeConsumer = ( KnownRepositoryContentConsumer )
+                    lookup( KnownRepositoryContentConsumer.class, "repo-purge-consumer-by-days-old" );
+
+        populateDbForReleasedSnapshotsTest();
+
+        repoPurgeConsumer.beginScan( getRepository() );
+
+        File testDir = new File( "target/test" );
+        FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
+
+        repoPurgeConsumer.processFile( PATH_TO_RELEASED_SNAPSHOT );
+
+        // 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() );
+
+        // check if metadata file was 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", el.getValue() );
+
+        el = (Element) xPath.newInstance( "./lastUpdated" ).selectSingleNode( versioning );
+        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 );
+    }
+
+    public void populateDbForRetentionCountTest()
+            throws ArchivaDatabaseException
+    {
+        List versions = new ArrayList();
+        versions.add( "1.0RC1-20070504.153317-1" );
+        versions.add( "1.0RC1-20070504.160758-2" );
+        versions.add( "1.0RC1-20070505.090015-3" );
+        versions.add( "1.0RC1-20070506.090132-4" );
+
+        populateDb( "org.jruby.plugins", "jruby-rake-plugin", versions);
+    }
+
+    private void populateDbForDaysOldTest()
+        throws ArchivaDatabaseException
+    {
+        List versions = new ArrayList();
+        versions.add( "2.2-SNAPSHOT" );
+
+        populateDb( "org.apache.maven.plugins", "maven-install-plugin", versions );
+    }
+
+    public void populateDbForReleasedSnapshotsTest()
+        throws ArchivaDatabaseException
+    {
+        List versions = new ArrayList();
+        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=569789&r1=569788&r2=569789&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 Sun Aug 26 02:42:27 2007
@@ -19,10 +19,11 @@
 * under the License.
 */
 
-import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.commons.io.FileUtils;
 
 import java.io.File;
-import java.util.Date;
+import java.util.List;
+import java.util.ArrayList;
 
 /**
  * Test RetentionsCountRepositoryPurgeTest
@@ -33,12 +34,6 @@
     extends AbstractRepositoryPurgeTest
 {
 
-    public static final String PATH_TO_BY_RETENTION_COUNT_ARTIFACT =
-        "org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar";
-
-    public static final String PATH_TO_BY_RETENTION_COUNT_POM =
-        "org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.pom";
-
     protected void setUp()
         throws Exception
     {
@@ -57,61 +52,67 @@
     {
         populateIfJarWasFoundDb();
 
+        File testDir = new File( "target/test" );
+        testDir.mkdir();
+        FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
+
         repoPurge.process( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
 
         // assert if removed from repo
         assertFalse( new File(
-            "target/test-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.md5" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.sha1" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.md5" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.sha1" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.md5" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.sha1" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.md5" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.sha1" ).exists() );
+            "target/test/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.sha1" ).exists() );
 
         // assert if not removed from repo
         assertTrue( new File(
-            "target/test-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.md5" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.sha1" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.md5" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.sha1" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.md5" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.sha1" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.md5" ).exists() );
+            "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-classes/test-repo/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.sha1" ).exists() );
+            "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 );
     }
 
     /**
@@ -124,192 +125,88 @@
     {
         populateIfPomWasFoundDb();
 
+        File testDir = new File( "target/test" );
+        testDir.mkdir();
+        FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
+
         repoPurge.process( PATH_TO_BY_RETENTION_COUNT_POM );
 
         // assert if removed from repo
         assertFalse( new File(
-            "target/test-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070427.065136-1.jar" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070427.065136-1.jar.md5" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070427.065136-1.jar.sha1" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070427.065136-1.pom" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070427.065136-1.pom.md5" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070427.065136-1.pom.sha1" ).exists() );
+            "target/test/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070427.065136-1.pom.sha1" ).exists() );
 
         // assert if not removed from repo
         assertTrue( new File(
-            "target/test-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3.pom" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3.pom.md5" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3.pom.sha1" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3.jar" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3.jar.md5" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3.jar.sha1" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3-sources.jar" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3-sources.jar.md5" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070615.105019-3-sources.jar.sha1" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.pom" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.pom.md5" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.pom.sha1" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.jar" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.jar.md5" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2.jar.sha1" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2-sources.jar" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2-sources.jar.md5" ).exists() );
+            "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-classes/test-repo/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT/castor-anttasks-1.1.2-20070506.163513-2-sources.jar.sha1" ).exists() );
+            "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 );
     }
 
     public void populateIfJarWasFoundDb()
         throws Exception
     {
-        // Create it
-        ArchivaArtifact artifact =
-            dao.createArtifact( "org.jruby.plugins", "jruby-rake-plugin", "1.0RC1-20070504.153317-1", "", "jar" );
-        assertNotNull( artifact );
-
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-
-        // Save it.
-        ArchivaArtifact savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
-
-        //POM
-        artifact =
-            dao.createArtifact( "org.jruby.plugins", "jruby-rake-plugin", "1.0RC1-20070504.153317-1", "", "pom" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-        savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
-
-        //JAR
-        artifact =
-            dao.createArtifact( "org.jruby.plugins", "jruby-rake-plugin", "1.0RC1-20070504.160758-2", "", "jar" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-        savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
-
-        //POM
-        artifact =
-            dao.createArtifact( "org.jruby.plugins", "jruby-rake-plugin", "1.0RC1-20070504.160758-2", "", "pom" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-        savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
-
-        //JAR
-        artifact =
-            dao.createArtifact( "org.jruby.plugins", "jruby-rake-plugin", "1.0RC1-20070505.090015-3", "", "jar" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-        savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
-
-        //POM
-        artifact =
-            dao.createArtifact( "org.jruby.plugins", "jruby-rake-plugin", "1.0RC1-20070505.090015-3", "", "pom" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-        savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
-
-        //JAR
-        artifact =
-            dao.createArtifact( "org.jruby.plugins", "jruby-rake-plugin", "1.0RC1-20070506.090132-4", "", "jar" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-        savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
-
-        //POM
-        artifact =
-            dao.createArtifact( "org.jruby.plugins", "jruby-rake-plugin", "1.0RC1-20070506.090132-4", "", "pom" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-        savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
+        List versions = new ArrayList();
+        versions.add( "1.0RC1-20070504.153317-1" );
+        versions.add( "1.0RC1-20070504.160758-2" );
+        versions.add( "1.0RC1-20070505.090015-3" );
+        versions.add( "1.0RC1-20070506.090132-4" );
+
+        populateDb( "org.jruby.plugins", "jruby-rake-plugin", versions );
     }
 
     public void populateIfPomWasFoundDb()
         throws Exception
     {
-        // Create it
-        ArchivaArtifact artifact =
-            dao.createArtifact( "org.codehaus.castor", "castor-anttasks", "1.1.2-20070427.065136-1", "", "jar" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-        ArchivaArtifact savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
-
-        //POM
-        artifact = dao.createArtifact( "org.codehaus.castor", "castor-anttasks", "1.1.2-20070427.065136-1", "", "pom" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-        savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
-
-        //JAR
-        artifact = dao.createArtifact( "org.codehaus.castor", "castor-anttasks", "1.1.2-20070615.105019-3", "", "jar" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-        savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
-
-        //POM
-        artifact = dao.createArtifact( "org.codehaus.castor", "castor-anttasks", "1.1.2-20070615.105019-3", "", "pom" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-        savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
-
-        //JAR
-        artifact = dao.createArtifact( "org.codehaus.castor", "castor-anttasks", "1.1.2-20070506.163513-2", "", "jar" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-
-        savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
-
-        //POM
-        artifact = dao.createArtifact( "org.codehaus.castor", "castor-anttasks", "1.1.2-20070506.163513-2", "", "pom" );
-        assertNotNull( artifact );
-        artifact.getModel().setLastModified( new Date() );
-        artifact.getModel().setOrigin( "test" );
-        savedArtifact = dao.saveArtifact( artifact );
-        assertNotNull( savedArtifact );
+        List versions = new ArrayList();
+        versions.add( "1.1.2-20070427.065136-1" );
+        versions.add( "1.1.2-20070615.105019-3" );
+        versions.add( "1.1.2-20070506.163513-2" );
+
+        populateDb( "org.codehaus.castor", "castor-anttasks", versions );
     }
 }



Mime
View raw message