1 package org.apache.maven.archiva.consumers.core.repository;
2
3 import java.util.Collections;
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 public class RetentionCountRepositoryPurgeTest
29 extends AbstractRepositoryPurgeTest
30 {
31
32 protected void setUp()
33 throws Exception
34 {
35 super.setUp();
36
37 repoPurge =
38 new RetentionCountRepositoryPurge(
39 getRepository(),
40 getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ).getRetentionCount(),
41 Collections.singletonList( listener ) );
42 }
43
44
45
46
47
48
49 public void testIfAJarWasFound()
50 throws Exception
51 {
52 String repoRoot = prepareTestRepos();
53
54
55 listener.deleteArtifact( getRepository(), createArtifact( "org.jruby.plugins", "jruby-rake-plugin",
56 "1.0RC1-20070504.153317-1", "jar" ) );
57 listener.deleteArtifact( getRepository(), createArtifact( "org.jruby.plugins", "jruby-rake-plugin",
58 "1.0RC1-20070504.153317-1", "pom" ) );
59 listener.deleteArtifact( getRepository(), createArtifact( "org.jruby.plugins", "jruby-rake-plugin",
60 "1.0RC1-20070504.160758-2", "jar" ) );
61 listener.deleteArtifact( getRepository(), createArtifact( "org.jruby.plugins", "jruby-rake-plugin",
62 "1.0RC1-20070504.160758-2", "pom" ) );
63 listenerControl.replay();
64
65 repoPurge.process( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
66
67 listenerControl.verify();
68
69 String versionRoot = repoRoot + "/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT";
70
71
72 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar" );
73 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.md5" );
74 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.sha1" );
75 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom" );
76 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.md5" );
77 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.sha1" );
78
79 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar" );
80 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.md5" );
81 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.sha1" );
82 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom" );
83 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.md5" );
84 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.sha1" );
85
86
87 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar" );
88 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.md5" );
89 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.sha1" );
90 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom" );
91 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.md5" );
92 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.sha1" );
93
94 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar" );
95 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.md5" );
96 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.sha1" );
97 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom" );
98 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.md5" );
99 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.sha1" );
100 }
101
102
103
104
105
106
107 public void testIfAPomWasFound()
108 throws Exception
109 {
110 String repoRoot = prepareTestRepos();
111
112
113 listener.deleteArtifact( getRepository(), createArtifact( "org.codehaus.castor", "castor-anttasks",
114 "1.1.2-20070427.065136-1", "jar" ) );
115 listener.deleteArtifact( getRepository(), createArtifact( "org.codehaus.castor", "castor-anttasks",
116 "1.1.2-20070427.065136-1", "pom" ) );
117 listenerControl.replay();
118
119 repoPurge.process( PATH_TO_BY_RETENTION_COUNT_POM );
120
121 listenerControl.verify();
122
123 String versionRoot = repoRoot + "/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT";
124
125
126 assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.jar" );
127 assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.jar.md5" );
128 assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.jar.sha1" );
129 assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.pom" );
130 assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.pom.md5" );
131 assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.pom.sha1" );
132
133
134 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.pom" );
135 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.pom.md5" );
136 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.pom.sha1" );
137 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.jar" );
138 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.jar.md5" );
139 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3.jar.sha1" );
140 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3-sources.jar" );
141 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3-sources.jar.md5" );
142 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070615.105019-3-sources.jar.sha1" );
143
144 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.pom" );
145 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.pom.md5" );
146 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.pom.sha1" );
147 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.jar" );
148 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.jar.md5" );
149 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2.jar.sha1" );
150 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2-sources.jar" );
151 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2-sources.jar.md5" );
152 assertExists( versionRoot + "/castor-anttasks-1.1.2-20070506.163513-2-sources.jar.sha1" );
153 }
154
155 public void testOrderOfDeletion()
156 throws Exception
157 {
158 String repoRoot = prepareTestRepos();
159
160
161 listener.deleteArtifact( getRepository(), createArtifact( "org.apache.maven.plugins", "maven-assembly-plugin",
162 "1.1.2-20070427.065136-1", "maven-plugin" ) );
163 listener.deleteArtifact( getRepository(), createArtifact( "org.apache.maven.plugins", "maven-assembly-plugin",
164 "1.1.2-20070427.065136-1", "pom" ) );
165 listenerControl.replay();
166
167 repoPurge.process( PATH_TO_TEST_ORDER_OF_DELETION );
168
169 listenerControl.verify();
170
171 String versionRoot = repoRoot +
172 "/org/apache/maven/plugins/maven-assembly-plugin/1.1.2-SNAPSHOT";
173
174 assertDeleted( versionRoot + "/maven-assembly-plugin-1.1.2-20070427.065136-1.jar" );
175 assertDeleted( versionRoot + "/maven-assembly-plugin-1.1.2-20070427.065136-1.jar.sha1" );
176 assertDeleted( versionRoot + "/maven-assembly-plugin-1.1.2-20070427.065136-1.jar.md5" );
177 assertDeleted( versionRoot + "/maven-assembly-plugin-1.1.2-20070427.065136-1.pom" );
178 assertDeleted( versionRoot + "/maven-assembly-plugin-1.1.2-20070427.065136-1.pom.sha1" );
179 assertDeleted( versionRoot + "/maven-assembly-plugin-1.1.2-20070427.065136-1.pom.md5" );
180
181
182 assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070506.163513-2.jar" );
183 assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070506.163513-2.jar.sha1" );
184 assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070506.163513-2.jar.md5" );
185 assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070506.163513-2.pom" );
186 assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070506.163513-2.pom.sha1" );
187 assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070506.163513-2.pom.md5" );
188
189 assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070615.105019-3.jar" );
190 assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070615.105019-3.jar.sha1" );
191 assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070615.105019-3.jar.md5" );
192 assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070615.105019-3.pom" );
193 assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070615.105019-3.pom.sha1" );
194 assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070615.105019-3.pom.md5" );
195 }
196 }