]> source.dussan.org Git - archiva.git/blob
09fce755a46fa9f8c054f7df13e4d36fb16938fe
[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.List;
24
25 /**
26  * Test RetentionsCountRepositoryPurgeTest
27  *
28  * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
29  */
30 public class RetentionCountRepositoryPurgeTest
31     extends AbstractRepositoryPurgeTest
32 {
33
34     protected void setUp()
35         throws Exception
36     {
37         super.setUp();
38
39         repoPurge = new RetentionCountRepositoryPurge( getRepository(), dao,
40                                                        getRepoConfiguration().getRetentionCount() );
41     }
42
43     /**
44      * Test if the artifact to be processed was a jar.
45      *
46      * @throws Exception
47      */
48     public void testIfAJarWasFound()
49         throws Exception
50     {
51         populateIfJarWasFoundDb();
52
53         String repoRoot = prepareTestRepo();
54
55         repoPurge.process( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
56         
57         String versionRoot = repoRoot + "/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT";
58
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" );
66
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" );
73
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" );
81
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" );
88     }
89
90     /**
91      * Test if the artifact to be processed is a pom
92      *
93      * @throws Exception
94      */
95     public void testIfAPomWasFound()
96         throws Exception
97     {
98         populateIfPomWasFoundDb();
99
100         String repoRoot = prepareTestRepo();
101
102         repoPurge.process( PATH_TO_BY_RETENTION_COUNT_POM );
103
104         String versionRoot = repoRoot + "/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT";
105         
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" );
113
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" );
124
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" );
134     }
135
136     public void populateIfJarWasFoundDb()
137         throws Exception
138     {
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" );
144
145         populateDb( "org.jruby.plugins", "jruby-rake-plugin", versions );
146     }
147
148     public void populateIfPomWasFoundDb()
149         throws Exception
150     {
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" );
155
156         populateDb( "org.codehaus.castor", "castor-anttasks", versions );
157     }
158 }