1 package org.apache.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 org.apache.archiva.common.utils.BaseFile;
23 import org.apache.archiva.configuration.ArchivaConfiguration;
24 import org.apache.archiva.configuration.FileType;
25 import org.apache.archiva.configuration.FileTypes;
26 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
27 import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
28 import org.apache.archiva.metadata.model.ArtifactMetadata;
29 import org.apache.archiva.metadata.model.MetadataFacet;
30 import org.apache.archiva.mock.MockRepositorySessionFactory;
31 import org.apache.archiva.repository.RepositoryRegistry;
32 import org.apache.archiva.repository.features.ArtifactCleanupFeature;
33 import org.custommonkey.xmlunit.XMLAssert;
34 import org.junit.After;
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.mockito.ArgumentCaptor;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40 import org.springframework.test.context.ContextConfiguration;
42 import java.io.IOException;
43 import java.nio.charset.Charset;
44 import java.nio.file.Files;
45 import java.nio.file.Path;
46 import java.nio.file.Paths;
47 import java.nio.file.attribute.FileTime;
48 import java.time.Period;
49 import java.util.HashSet;
50 import java.util.List;
53 import static org.junit.Assert.*;
54 import static org.mockito.Matchers.any;
55 import static org.mockito.Matchers.eq;
56 import static org.mockito.Mockito.*;
60 @ContextConfiguration (
61 locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-purge-consumer-test.xml" } )
62 public class RepositoryPurgeConsumerTest
63 extends AbstractRepositoryPurgeTest
65 private static final Logger log = LoggerFactory.getLogger( RepositoryPurgeConsumerTest.class );
74 MockRepositorySessionFactory factory = applicationContext.getBean( MockRepositorySessionFactory.class );
75 factory.setRepository( metadataRepository );
80 public void tearDown()
87 public void testConsumption()
90 assertNotConsumed( "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata.xml" );
95 public void testConsumptionOfOtherMetadata()
98 assertNotConsumed( "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata-central.xml" );
102 private void cleanupFileTypes()
104 ArchivaConfiguration archivaConfiguration =
105 applicationContext.getBean( "archivaConfiguration#default", ArchivaConfiguration.class );
107 FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 );
108 fileType.removePattern( "**/*.xml" );
111 private void assertNotConsumed( String path )
114 ArchivaConfiguration archivaConfiguration =
115 applicationContext.getBean( "archivaConfiguration#default", ArchivaConfiguration.class );
117 FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 );
118 assertEquals( FileTypes.ARTIFACTS, fileType.getId() );
119 fileType.addPattern( "**/*.xml" );
122 //FileTypes fileTypes = applicationContext.getBean( FileTypes.class );
123 for ( FileTypes fileTypes : applicationContext.getBeansOfType( FileTypes.class ).values() )
125 fileTypes.afterConfigurationChange( null, "repositoryScanning.fileTypes", null );
127 KnownRepositoryContentConsumer repoPurgeConsumer =
128 applicationContext.getBean( "knownRepositoryContentConsumer#repository-purge",
129 KnownRepositoryContentConsumer.class );
131 Path repoLocation = Paths.get( "target/test-" + getName() + "/test-repo" );
133 Path localFile = repoLocation.resolve( path );
135 ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
136 BaseFile baseFile = new BaseFile( repoLocation.toFile(), localFile.toFile() );
137 predicate.setBasefile( baseFile );
139 assertFalse( predicate.evaluate( repoPurgeConsumer ) );
142 private void setLastModified( String path ) throws IOException
144 Path dir = Paths.get( path );
145 Path[] contents = new Path[0];
148 contents = Files.list( dir ).toArray(Path[]::new);
150 catch ( IOException e )
152 log.error("Could not list files {}: {}", dir, e.getMessage(), e);
153 contents = new Path[0];
155 for ( int i = 0; i < contents.length; i++ )
157 Files.setLastModifiedTime( contents[i], FileTime.fromMillis( 1179382029 ) );
162 public void testConsumerByRetentionCount()
165 KnownRepositoryContentConsumer repoPurgeConsumer =
166 applicationContext.getBean( "knownRepositoryContentConsumer#repo-purge-consumer-by-retention-count",
167 KnownRepositoryContentConsumer.class );
169 org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
170 ArtifactCleanupFeature atf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ).get();
171 atf.setRetentionPeriod( Period.ofDays( 0 ) ); // force days older off to allow retention count purge to execute.
172 atf.setRetentionCount( TEST_RETENTION_COUNT );
173 addRepoToConfiguration( "retention-count", repoConfiguration );
175 repoPurgeConsumer.beginScan( repoConfiguration, null );
177 String repoRoot = prepareTestRepos();
178 String projectNs = "org.jruby.plugins";
179 String projectPath = projectNs.replaceAll("\\.","/");
180 String projectName = "jruby-rake-plugin";
181 String projectVersion = "1.0RC1-SNAPSHOT";
182 String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
183 String versionRoot = projectRoot + "/" + projectVersion;
185 Path repo = getTestRepoRootPath();
186 Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
188 // Provide the metadata list
189 List<ArtifactMetadata> ml = getArtifactMetadataFromDir( TEST_REPO_ID, projectName, repo, vDir );
190 when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
191 projectName, projectVersion)).thenReturn(ml);
192 Set<String> deletedVersions = new HashSet<>();
193 deletedVersions.add("1.0RC1-20070504.153317-1");
194 deletedVersions.add("1.0RC1-20070504.160758-2");
196 repoPurgeConsumer.processFile( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
198 // Verify the metadataRepository invocations
199 verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
200 ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
201 verify(metadataRepository, times(2)).removeArtifact(metadataArg.capture(), eq(projectVersion));
202 List<ArtifactMetadata> metaL = metadataArg.getAllValues();
203 for (ArtifactMetadata meta : metaL) {
204 assertTrue(meta.getId().startsWith(projectName));
205 assertTrue(deletedVersions.contains(meta.getVersion()));
210 // assert if removed from repo
211 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar" );
212 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1-javadoc.jar" );
213 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1-javadoc.zip" );
214 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.md5" );
215 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar.sha1" );
216 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom" );
217 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.md5" );
218 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.pom.sha1" );
220 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar" );
221 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2-javadoc.jar" );
222 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2-javadoc.zip" );
223 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.md5" );
224 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.jar.sha1" );
225 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom" );
226 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.md5" );
227 assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.160758-2.pom.sha1" );
229 // assert if not removed from repo
230 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar" );
231 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3-javadoc.jar" );
232 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3-javadoc.zip" );
233 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.md5" );
234 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.jar.sha1" );
235 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom" );
236 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.md5" );
237 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070505.090015-3.pom.sha1" );
239 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar" );
240 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.md5" );
241 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.jar.sha1" );
242 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom" );
243 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.md5" );
244 assertExists( versionRoot + "/jruby-rake-plugin-1.0RC1-20070506.090132-4.pom.sha1" );
246 removeRepoFromConfiguration( "retention-count", repoConfiguration );
249 private void addRepoToConfiguration( String configHint, org.apache.archiva.repository.ManagedRepository repoConfiguration )
252 RepositoryRegistry repositoryRegistry = applicationContext.getBean(RepositoryRegistry.class);
253 repositoryRegistry.putRepository( repoConfiguration );
256 private void removeRepoFromConfiguration( String configHint, org.apache.archiva.repository.ManagedRepository repoConfiguration )
259 RepositoryRegistry repositoryRegistry = applicationContext.getBean(RepositoryRegistry.class);
260 repositoryRegistry.removeRepository( repoConfiguration );
264 public void testConsumerByDaysOld()
267 KnownRepositoryContentConsumer repoPurgeConsumer =
268 applicationContext.getBean( "knownRepositoryContentConsumer#repo-purge-consumer-by-days-old",
269 KnownRepositoryContentConsumer.class );
271 org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
272 ArtifactCleanupFeature atf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ).get();
273 atf.setRetentionPeriod( Period.ofDays( TEST_DAYS_OLDER ) );
274 addRepoToConfiguration( "days-old", repoConfiguration );
276 repoPurgeConsumer.beginScan( repoConfiguration, null );
278 String repoRoot = prepareTestRepos();
279 String projectNs = "org.apache.maven.plugins";
280 String projectPath = projectNs.replaceAll("\\.","/");
281 String projectName = "maven-install-plugin";
282 String projectVersion = "2.2-SNAPSHOT";
283 String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
285 setLastModified( projectRoot + "/"+projectVersion);
288 Path repo = getTestRepoRootPath();
289 Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
291 // Provide the metadata list
292 List<ArtifactMetadata> ml = getArtifactMetadataFromDir( TEST_REPO_ID, projectName, repo, vDir );
293 when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
294 projectName, projectVersion)).thenReturn(ml);
295 Set<String> deletedVersions = new HashSet<>();
296 deletedVersions.add("2.2-SNAPSHOT");
297 deletedVersions.add("2.2-20061118.060401-2");
299 repoPurgeConsumer.processFile( PATH_TO_BY_DAYS_OLD_ARTIFACT );
301 // Verify the metadataRepository invocations
302 verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
303 ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
304 verify(metadataRepository, times(2)).removeArtifact(metadataArg.capture(), eq(projectVersion));
305 List<ArtifactMetadata> metaL = metadataArg.getAllValues();
306 for (ArtifactMetadata meta : metaL) {
307 assertTrue(meta.getId().startsWith(projectName));
308 assertTrue(deletedVersions.contains(meta.getVersion()));
311 assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar" );
312 assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.md5" );
313 assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.sha1" );
314 assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom" );
315 assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.md5" );
316 assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.sha1" );
318 // shouldn't be deleted because even if older than 30 days (because retention count = 2)
319 assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.jar" );
320 assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.jar.md5" );
321 assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.jar.sha1" );
322 assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.pom" );
323 assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.pom.md5" );
324 assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.pom.sha1" );
326 assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.jar" );
327 assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.jar.md5" );
328 assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.jar.sha1" );
329 assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.pom" );
330 assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.pom.md5" );
331 assertExists( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070510.010101-4.pom.sha1" );
333 assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar" );
334 assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar.md5" );
335 assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar.sha1" );
336 assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom" );
337 assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom.md5" );
338 assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom.sha1" );
340 removeRepoFromConfiguration( "days-old", repoConfiguration );
344 * Test the snapshot clean consumer on a repository set to NOT clean/delete snapshots based on released versions.
349 public void testReleasedSnapshotsWereNotCleaned()
352 KnownRepositoryContentConsumer repoPurgeConsumer =
353 applicationContext.getBean( "knownRepositoryContentConsumer#repo-purge-consumer-by-retention-count",
354 KnownRepositoryContentConsumer.class );
356 org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
357 ArtifactCleanupFeature acf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ).get();
358 acf.setDeleteReleasedSnapshots( false ); // Set to NOT delete released snapshots.
359 addRepoToConfiguration( "retention-count", repoConfiguration );
361 repoPurgeConsumer.beginScan( repoConfiguration, null );
363 String repoRoot = prepareTestRepos();
364 String projectNs = "org.apache.maven.plugins";
365 String projectPath = projectNs.replaceAll("\\.","/");
366 String projectName = "maven-plugin-plugin";
367 String projectVersion = "2.3-SNAPSHOT";
368 String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
370 Path repo = getTestRepoRootPath();
371 Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
373 // Provide the metadata list
374 List<ArtifactMetadata> ml = getArtifactMetadataFromDir( TEST_REPO_ID, projectName, repo, vDir );
375 when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
376 projectName, projectVersion)).thenReturn(ml);
378 repoPurgeConsumer.processFile(
379 CleanupReleasedSnapshotsRepositoryPurgeTest.PATH_TO_RELEASED_SNAPSHOT_IN_SAME_REPO );
381 verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
382 ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
383 verify(metadataRepository, never()).removeArtifact(any(), any());
384 verify(metadataRepository, never()).removeArtifact( any(), any(), any(), any(), any(MetadataFacet.class) );
386 // check if the snapshot wasn't removed
388 assertExists( projectRoot + "/2.3-SNAPSHOT" );
389 assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar" );
390 assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.md5" );
391 assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.sha1" );
392 assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom" );
393 assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.md5" );
394 assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" );
396 // check if metadata file wasn't updated
397 Path artifactMetadataFile = Paths.get( projectRoot + "/maven-metadata.xml" );
399 String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
401 String expectedVersions = "<expected><versions><version>2.3-SNAPSHOT</version></versions></expected>";
403 XMLAssert.assertXpathEvaluatesTo( "2.3-SNAPSHOT", "//metadata/versioning/latest", metadataXml );
404 XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions,
405 "//metadata/versioning/versions/version", metadataXml );
406 XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
408 removeRepoFromConfiguration( "retention-count", repoConfiguration );
412 public void testReleasedSnapshotsWereCleaned()
415 KnownRepositoryContentConsumer repoPurgeConsumer =
416 applicationContext.getBean( "knownRepositoryContentConsumer#repo-purge-consumer-by-days-old",
417 KnownRepositoryContentConsumer.class );
419 org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME );
420 ArtifactCleanupFeature acf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ).get();
421 acf.setDeleteReleasedSnapshots( true );
422 addRepoToConfiguration( "days-old", repoConfiguration );
425 repoPurgeConsumer.beginScan( repoConfiguration, null );
427 String repoRoot = prepareTestRepos();
428 String projectNs = "org.apache.maven.plugins";
429 String projectPath = projectNs.replaceAll("\\.","/");
430 String projectName = "maven-plugin-plugin";
431 String projectVersion = "2.3-SNAPSHOT";
432 String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
433 Path repo = getTestRepoRootPath();
434 Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
436 // Provide the metadata list
437 List<ArtifactMetadata> ml = getArtifactMetadataFromDir(TEST_REPO_ID , projectName, repo.getParent(), vDir );
438 when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
439 projectName, projectVersion)).thenReturn(ml);
441 repoPurgeConsumer.processFile(
442 CleanupReleasedSnapshotsRepositoryPurgeTest.PATH_TO_RELEASED_SNAPSHOT_IN_SAME_REPO );
444 verify(metadataRepository, times(1)).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
445 ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
446 verify(metadataRepository, never()).removeArtifact(any(), any());
448 // check if the snapshot was removed
449 assertDeleted( projectRoot + "/2.3-SNAPSHOT" );
450 assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar" );
451 assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.md5" );
452 assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.sha1" );
453 assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom" );
454 assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.md5" );
455 assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" );
457 // check if metadata file was updated
458 Path artifactMetadataFile = Paths.get( projectRoot + "/maven-metadata.xml" );
460 String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
462 String expectedVersions =
463 "<expected><versions><version>2.2</version>" + "<version>2.3</version></versions></expected>";
465 XMLAssert.assertXpathEvaluatesTo( "2.3", "//metadata/versioning/latest", metadataXml );
466 XMLAssert.assertXpathsEqual( "//expected/versions/version", expectedVersions,
467 "//metadata/versioning/versions/version", metadataXml );
468 XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
470 removeRepoFromConfiguration( "days-old", repoConfiguration );