1 package org.apache.maven.archiva.consumers.core.repository;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.commons.io.FileUtils;
24 import java.util.List;
25 import java.util.ArrayList;
29 * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
31 public class DaysOldRepositoryPurgeTest
32 extends AbstractRepositoryPurgeTest
35 protected void setUp()
40 repoPurge = new DaysOldRepositoryPurge( getRepository(), getLayout(), dao, getRepoConfiguration() );
43 private void setLastModified()
46 new File( "target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/" );
47 File[] contents = dir.listFiles();
48 for ( int i = 0; i < contents.length; i++ )
50 contents[i].setLastModified( 1179382029 );
54 public void testIfAJarIsFound()
59 File testDir = new File( "target/test" );
60 FileUtils.copyDirectoryToDirectory( new File( "target/test-classes/test-repo" ), testDir );
64 repoPurge.process( PATH_TO_BY_DAYS_OLD_ARTIFACT );
66 assertFalse( new File(
67 "target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar" ).exists() );
68 assertFalse( new File(
69 "target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.md5" ).exists() );
70 assertFalse( new File(
71 "target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.sha1" ).exists() );
72 assertFalse( new File(
73 "target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom" ).exists() );
74 assertFalse( new File(
75 "target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.md5" ).exists() );
76 assertFalse( new File(
77 "target/test/test-repo/org/apache/maven/plugins/maven-install-plugin/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.sha1" ).exists() );
79 FileUtils.deleteDirectory( testDir );
82 protected void tearDown()
89 private void populateDb()
92 List versions = new ArrayList();
93 versions.add( "2.2-SNAPSHOT" );
95 populateDb( "org.apache.maven.plugins", "maven-install-plugin", versions );