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 java.util.ArrayList;
23 import java.util.List;
26 * Test RetentionsCountRepositoryPurgeTest
28 * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
30 public class RetentionCountRepositoryPurgeTest
31 extends AbstractRepositoryPurgeTest
34 protected void setUp()
39 repoPurge = new RetentionCountRepositoryPurge( getRepository(), dao,
40 getRepoConfiguration().getRetentionCount() );
44 * Test if the artifact to be processed was a jar.
48 public void testIfAJarWasFound()
51 populateIfJarWasFoundDb();
53 String repoRoot = prepareTestRepo();
55 repoPurge.process( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
57 String versionRoot = repoRoot + "/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT";
59 // assert if removed from repo
60 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar" );
61 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.md5" );
62 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.sha1" );
63 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom" );
64 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.md5" );
65 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.sha1" );
67 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar" );
68 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.md5" );
69 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.sha1" );
70 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom" );
71 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.md5" );
72 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.sha1" );
74 // assert if not removed from repo
75 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar" );
76 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.md5" );
77 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.sha1" );
78 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom" );
79 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.md5" );
80 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.sha1" );
82 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar" );
83 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.md5" );
84 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.sha1" );
85 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom" );
86 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.md5" );
87 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.sha1" );
91 * Test if the artifact to be processed is a pom
95 public void testIfAPomWasFound()
98 populateIfPomWasFoundDb();
100 String repoRoot = prepareTestRepo();
102 repoPurge.process( PATH_TO_BY_RETENTION_COUNT_POM );
104 String versionRoot = repoRoot + "/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT";
106 // assert if removed from repo
107 assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.jar" );
108 assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.jar.md5" );
109 assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.jar.sha1" );
110 assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.pom" );
111 assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.pom.md5" );
112 assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.pom.sha1" );
114 // assert if not removed from repo
115 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.pom" );
116 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.pom.md5" );
117 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.pom.sha1" );
118 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.jar" );
119 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.jar.md5" );
120 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.jar.sha1" );
121 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3-sources.jar" );
122 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3-sources.jar.md5" );
123 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3-sources.jar.sha1" );
125 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.pom" );
126 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.pom.md5" );
127 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.pom.sha1" );
128 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.jar" );
129 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.jar.md5" );
130 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.jar.sha1" );
131 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2-sources.jar" );
132 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2-sources.jar.md5" );
133 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2-sources.jar.sha1" );
136 public void populateIfJarWasFoundDb()
139 List<String> versions = new ArrayList<String>();
140 versions.add( "1.0RC1-20070504.153317-1" );
141 versions.add( "1.0RC1-20070504.160758-2" );
142 versions.add( "1.0RC1-20070505.090015-3" );
143 versions.add( "1.0RC1-20070506.090132-4" );
145 populateDb( "org.jruby.plugins", "jruby-rake-plugin", versions );
148 public void populateIfPomWasFoundDb()
151 List<String> versions = new ArrayList<String>();
152 versions.add( "1.1.2-20070427.065136-1" );
153 versions.add( "1.1.2-20070615.105019-3" );
154 versions.add( "1.1.2-20070506.163513-2" );
156 populateDb( "org.codehaus.castor", "castor-anttasks", versions );