]> source.dussan.org Git - archiva.git/blob
b9af53359a41168d0e44817c13040496ff349996
[archiva.git] /
1 package org.apache.maven.archiva.consumers.core.repository;
2
3 /*
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
11 *
12 *  http://www.apache.org/licenses/LICENSE-2.0
13 *
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
19 * under the License.
20 */
21
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.List;
25 import java.util.Map;
26
27 import org.apache.maven.archiva.consumers.core.repository.stubs.LuceneRepositoryContentIndexStub;
28 import org.apache.maven.archiva.indexer.RepositoryContentIndex;
29
30 /**
31  * Test RetentionsCountRepositoryPurgeTest
32  *
33  * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
34  */
35 public class RetentionCountRepositoryPurgeTest
36     extends AbstractRepositoryPurgeTest
37 {
38
39     protected void setUp()
40         throws Exception
41     {
42         super.setUp();
43
44         Map<String, RepositoryContentIndex> map = new HashMap<String, RepositoryContentIndex>();
45         map.put( "filecontent", new LuceneRepositoryContentIndexStub( 2 ) );
46         map.put( "hashcodes", new LuceneRepositoryContentIndexStub( 2 ) );
47         map.put( "bytecode", new LuceneRepositoryContentIndexStub( 2 ) );
48         
49         repoPurge = new RetentionCountRepositoryPurge( getRepository(), dao,
50                                                        getRepoConfiguration().getRetentionCount(), map );
51     }
52
53     /**
54      * Test if the artifact to be processed was a jar.
55      *
56      * @throws Exception
57      */
58     public void testIfAJarWasFound()
59         throws Exception
60     {
61         populateIfJarWasFoundDb();
62
63         String repoRoot = prepareTestRepo();
64
65         repoPurge.process( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
66         
67         String versionRoot = repoRoot + "/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT";
68
69         // assert if removed from repo
70         assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar" );
71         assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.md5" );
72         assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.sha1" );
73         assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom" );
74         assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.md5" );
75         assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.sha1" );
76
77         assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar" );
78         assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.md5" );
79         assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.sha1" );
80         assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom" );
81         assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.md5" );
82         assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.sha1" );
83
84         // assert if not removed from repo
85         assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar" );
86         assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.md5" );
87         assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.sha1" );
88         assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom" );
89         assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.md5" );
90         assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.sha1" );
91
92         assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar" );
93         assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.md5" );
94         assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.sha1" );
95         assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom" );
96         assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.md5" );
97         assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.sha1" );
98     }
99
100     /**
101      * Test if the artifact to be processed is a pom
102      *
103      * @throws Exception
104      */
105     public void testIfAPomWasFound()
106         throws Exception
107     {
108         populateIfPomWasFoundDb();
109
110         String repoRoot = prepareTestRepo();
111
112         repoPurge.process( PATH_TO_BY_RETENTION_COUNT_POM );
113
114         String versionRoot = repoRoot + "/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT";
115         
116         // assert if removed from repo
117         assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.jar" );
118         assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.jar.md5" );
119         assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.jar.sha1" );
120         assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.pom" );
121         assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.pom.md5" );
122         assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.pom.sha1" );
123
124         // assert if not removed from repo
125         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.pom" );
126         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.pom.md5" );
127         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.pom.sha1" );
128         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.jar" );
129         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.jar.md5" );
130         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.jar.sha1" );
131         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3-sources.jar" );
132         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3-sources.jar.md5" );
133         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3-sources.jar.sha1" );
134
135         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.pom" );
136         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.pom.md5" );
137         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.pom.sha1" );
138         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.jar" );
139         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.jar.md5" );
140         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.jar.sha1" );
141         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2-sources.jar" );
142         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2-sources.jar.md5" );
143         assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2-sources.jar.sha1" );
144     }
145
146     public void populateIfJarWasFoundDb()
147         throws Exception
148     {
149         List<String> versions = new ArrayList<String>();
150         versions.add( "1.0RC1-20070504.153317-1" );
151         versions.add( "1.0RC1-20070504.160758-2" );
152         versions.add( "1.0RC1-20070505.090015-3" );
153         versions.add( "1.0RC1-20070506.090132-4" );
154
155         populateDb( "org.jruby.plugins", "jruby-rake-plugin", versions );
156     }
157
158     public void populateIfPomWasFoundDb()
159         throws Exception
160     {
161         List<String> versions = new ArrayList<String>();
162         versions.add( "1.1.2-20070427.065136-1" );
163         versions.add( "1.1.2-20070615.105019-3" );
164         versions.add( "1.1.2-20070506.163513-2" );
165
166         populateDb( "org.codehaus.castor", "castor-anttasks", versions );
167     }
168 }