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