From 78d1f291f0612f70b805776926ce6e669dd34d0c Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Wed, 15 Dec 2010 02:26:34 +0000 Subject: [PATCH] [MRM-1421] Archiva repository purge incorrectly purges based on file timestamps even when the snapshot timestamp is known git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-1.3.x@1049392 13f79535-47bb-0310-9956-ffa450edef68 --- .../DaysOldRepositoryPurgeTest.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java index 252abcad8..be9860573 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java @@ -33,6 +33,8 @@ import java.util.List; public class DaysOldRepositoryPurgeTest extends AbstractRepositoryPurgeTest { + private static final int OLD_TIMESTAMP = 1179382029; + private void setLastModified( String dirPath, long lastModified ) { File dir = new File( dirPath ); @@ -56,7 +58,7 @@ public class DaysOldRepositoryPurgeTest String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-install-plugin"; - setLastModified( projectRoot + "/2.2-SNAPSHOT/", 1179382029 ); + setLastModified( projectRoot + "/2.2-SNAPSHOT/", OLD_TIMESTAMP ); // test listeners for the correct artifacts listener.deleteArtifact( getRepository(), createArtifact( "org.apache.maven.plugins", "maven-install-plugin", @@ -115,7 +117,7 @@ public class DaysOldRepositoryPurgeTest String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-assembly-plugin"; - setLastModified( projectRoot + "/1.1.2-SNAPSHOT/", 1179382029 ); + setLastModified( projectRoot + "/1.1.2-SNAPSHOT/", OLD_TIMESTAMP ); // test listeners for the correct artifacts listener.deleteArtifact( getRepository(), createArtifact( "org.apache.maven.plugins", "maven-assembly-plugin", @@ -171,8 +173,17 @@ public class DaysOldRepositoryPurgeTest for ( int i = 5; i <= 7; i++ ) { - new File( versionRoot, "/plexus-utils-1.4.3-" + timestamp + "-" + i + ".jar" ).createNewFile(); - new File( versionRoot, "/plexus-utils-1.4.3-" + timestamp + "-" + i + ".pom" ).createNewFile(); + File jarFile = new File( versionRoot, "/plexus-utils-1.4.3-" + timestamp + "-" + i + ".jar" ); + jarFile.createNewFile(); + File pomFile = new File( versionRoot, "/plexus-utils-1.4.3-" + timestamp + "-" + i + ".pom" ); + pomFile.createNewFile(); + + // set timestamp to older than 100 days for the first build, but ensure the filename timestamp is honoured instead + if ( i == 5 ) + { + jarFile.setLastModified( OLD_TIMESTAMP ); + pomFile.setLastModified( OLD_TIMESTAMP ); + } } List versions = new ArrayList(); -- 2.39.5