* under the License.
*/
+import org.apache.commons.lang.time.DateUtils;
+
import java.io.File;
-import java.io.IOException;
+import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collections;
-import org.apache.commons.lang.time.DateUtils;
-
/**
*/
public class DaysOldRepositoryPurgeTest
extends AbstractRepositoryPurgeTest
{
- private static final String[] extensions =
- new String[] { "-5.jar", "-5.pom", "-6.jar", "-6.pom", "-7.jar", "-7.pom" };
-
- private String year;
-
- private String mon;
-
- private String day;
-
- private String hr;
-
- private String min;
-
- private String sec;
-
private void setLastModified( String dirPath, long lastModified )
{
File dir = new File( dirPath );
"2.2-SNAPSHOT", "maven-install-plugin-2.2-SNAPSHOT.jar" );
listener.deleteArtifact( getRepository().getId(), "org.apache.maven.plugins", "maven-install-plugin",
"2.2-SNAPSHOT", "maven-install-plugin-2.2-SNAPSHOT.pom" );
+ listener.deleteArtifact( getRepository().getId(), "org.apache.maven.plugins", "maven-install-plugin",
+ "2.2-20061118.060401-2", "maven-install-plugin-2.2-20061118.060401-2.jar" );
+ listener.deleteArtifact( getRepository().getId(), "org.apache.maven.plugins", "maven-install-plugin",
+ "2.2-20061118.060401-2", "maven-install-plugin-2.2-20061118.060401-2.pom" );
listenerControl.replay();
-
+
repoPurge.process( PATH_TO_BY_DAYS_OLD_ARTIFACT );
-
+
listenerControl.verify();
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar" );
assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.pom.md5" );
assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.pom.sha1" );
- assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar" );
- assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar.md5" );
- assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar.sha1" );
- assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom" );
- assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom.md5" );
- assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom.sha1" );
+ assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.jar" );
+ assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.jar.md5" );
+ assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.jar.sha1" );
+ assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.pom" );
+ assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.pom.md5" );
+ assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.pom.sha1" );
+
+ assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar" );
+ assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar.md5" );
+ assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar.sha1" );
+ assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom" );
+ assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom.md5" );
+ assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom.sha1" );
}
public void testOrderOfDeletion()
{
repoPurge =
new DaysOldRepositoryPurge( getRepository(), getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ).getDaysOlder(),
- getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ).getRetentionCount(),
+ getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ).getRetentionCount(),
Collections.singletonList( listener ) );
String repoRoot = prepareTestRepos();
listener.deleteArtifact( getRepository().getId(), "org.apache.maven.plugins", "maven-assembly-plugin",
"1.1.2-20070427.065136-1", "maven-assembly-plugin-1.1.2-20070427.065136-1.pom" );
listenerControl.replay();
-
+
repoPurge.process( PATH_TO_TEST_ORDER_OF_DELETION );
listenerControl.verify();
Calendar currentDate = Calendar.getInstance( DateUtils.UTC_TIME_ZONE );
setLastModified( versionRoot, currentDate.getTimeInMillis() );
- year = String.valueOf( currentDate.get( Calendar.YEAR ) );
- mon = String.valueOf( currentDate.get( Calendar.MONTH ) + 1 );
- day = String.valueOf( currentDate.get( Calendar.DATE ) );
- hr = String.valueOf( currentDate.get( Calendar.HOUR ) );
- min = String.valueOf( currentDate.get( Calendar.MINUTE ) );
- sec = String.valueOf( currentDate.get( Calendar.SECOND ) );
-
- if ( mon.length() == 1 )
- {
- mon = "0" + mon;
- }
-
- if ( day.length() == 1 )
- {
- day = "0" + day;
- }
-
- if ( hr.length() == 1 )
- {
- hr = "0" + hr;
- }
-
- if ( min.length() == 1 )
- {
- min = "0" + min;
- }
+ String timestamp = new SimpleDateFormat( "yyyyMMdd.HHmmss" ).format( currentDate.getTime() );
- if ( sec.length() == 1 )
+ for ( int i = 5; i <= 7; i++ )
{
- sec = "0" + sec;
+ new File( versionRoot, "/plexus-utils-1.4.3-" + timestamp + "-" + i + ".jar" ).createNewFile();
+ new File( versionRoot, "/plexus-utils-1.4.3-" + timestamp + "-" + i + ".pom" ).createNewFile();
}
- createFiles( versionRoot );
-
// test listeners for the correct artifacts
listener.deleteArtifact( getRepository().getId(), "org.codehaus.plexus", "plexus-utils",
"1.4.3-20070113.163208-4", "plexus-utils-1.4.3-20070113.163208-4.jar" );
listener.deleteArtifact( getRepository().getId(), "org.codehaus.plexus", "plexus-utils",
"1.4.3-20070113.163208-4", "plexus-utils-1.4.3-20070113.163208-4.pom" );
listenerControl.replay();
-
+
repoPurge.process( PATH_TO_BY_DAYS_OLD_METADATA_DRIVEN_ARTIFACT );
listenerControl.verify();
assertExists( versionRoot + "/plexus-utils-1.4.3-SNAPSHOT.jar" );
assertExists( versionRoot + "/plexus-utils-1.4.3-SNAPSHOT.pom" );
- for ( String extension : extensions )
- {
- assertExists( versionRoot + "/plexus-utils-1.4.3-" + year + mon + day + "." + hr + min + sec + extension );
- }
- }
-
- private void createFiles( String versionRoot )
- throws IOException
- {
- for ( String extension : extensions )
+ for ( int i = 5; i <= 7; i++ )
{
- File file =
- new File( versionRoot, "/plexus-utils-1.4.3-" + year + mon + day + "." + hr + min + sec + extension );
- file.createNewFile();
+ assertExists( versionRoot + "/plexus-utils-1.4.3-" + timestamp + "-" + i + ".jar" );
+ assertExists( versionRoot + "/plexus-utils-1.4.3-" + timestamp + "-" + i + ".pom" );
}
}
* under the License.
*/
-import java.io.File;
-
import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.common.utils.BaseFile;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.consumers.functors.ConsumerWantsFilePredicate;
import org.custommonkey.xmlunit.XMLAssert;
+import java.io.File;
+
/**
*/
public class RepositoryPurgeConsumerTest
assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.pom" );
assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.pom.md5" );
assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.pom.sha1" );
-
- assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar" );
- assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar.md5" );
- assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar.sha1" );
- assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom" );
- assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom.md5" );
- assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom.sha1" );
+
+ assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.jar" );
+ assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.jar.md5" );
+ assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.jar.sha1" );
+ assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.pom" );
+ assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.pom.md5" );
+ assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.pom.sha1" );
+
+ assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar" );
+ assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar.md5" );
+ assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar.sha1" );
+ assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom" );
+ assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom.md5" );
+ assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom.sha1" );
}
/**