1 package org.apache.archiva.web.xmlrpc.services;
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.metadata.model.ArtifactMetadata;
23 import org.apache.archiva.metadata.repository.MetadataRepository;
24 import org.apache.archiva.repository.events.RepositoryListener;
25 import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
26 import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
27 import org.apache.archiva.scheduler.repository.RepositoryTask;
28 import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository;
29 import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository;
30 import org.apache.commons.io.FileUtils;
31 import org.apache.commons.io.filefilter.FileFilterUtils;
32 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
33 import org.apache.maven.archiva.configuration.Configuration;
34 import org.apache.maven.archiva.configuration.FileTypes;
35 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
36 import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
37 import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
38 import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
39 import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
40 import org.apache.maven.archiva.model.ArtifactReference;
41 import org.apache.maven.archiva.repository.RepositoryContentFactory;
42 import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
43 import org.apache.maven.archiva.repository.content.ManagedLegacyRepositoryContent;
44 import org.apache.maven.archiva.repository.content.PathParser;
45 import org.apache.maven.archiva.repository.layout.LayoutException;
46 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
47 import org.easymock.MockControl;
48 import org.easymock.classextension.MockClassControl;
51 import java.io.IOException;
52 import java.util.ArrayList;
53 import java.util.Collections;
54 import java.util.List;
57 * AdministrationServiceImplTest
59 * @version $Id: AdministrationServiceImplTest.java
61 public class AdministrationServiceImplTest
62 extends PlexusInSpringTestCase
64 private MockControl archivaConfigControl;
66 private ArchivaConfiguration archivaConfig;
68 private MockControl configControl;
70 private Configuration config;
72 private AdministrationServiceImpl service;
74 private MockControl repositoryTaskSchedulerControl;
76 private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
78 // repository consumers
79 private MockControl repoConsumerUtilsControl;
81 private RepositoryContentConsumers repoConsumersUtil;
83 private MockControl knownContentConsumerControl;
85 private MockControl invalidContentConsumerControl;
87 private KnownRepositoryContentConsumer indexArtifactConsumer;
89 private KnownRepositoryContentConsumer indexPomConsumer;
91 private InvalidRepositoryContentConsumer checkPomConsumer;
93 private InvalidRepositoryContentConsumer checkMetadataConsumer;
96 private MockControl repoFactoryControl;
98 private RepositoryContentFactory repositoryFactory;
100 private MockControl listenerControl;
102 private RepositoryListener listener;
104 private MockControl metadataRepositoryControl;
106 private MetadataRepository metadataRepository;
108 protected void setUp()
113 archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class );
114 archivaConfig = ( ArchivaConfiguration ) archivaConfigControl.getMock();
116 configControl = MockClassControl.createControl( Configuration.class );
117 config = ( Configuration ) configControl.getMock();
119 repositoryTaskSchedulerControl = MockClassControl.createControl( RepositoryArchivaTaskScheduler.class );
120 repositoryTaskScheduler = (RepositoryArchivaTaskScheduler) repositoryTaskSchedulerControl.getMock();
123 repoConsumerUtilsControl = MockClassControl.createControl( RepositoryContentConsumers.class );
124 repoConsumersUtil = ( RepositoryContentConsumers ) repoConsumerUtilsControl.getMock();
126 knownContentConsumerControl = MockControl.createControl( KnownRepositoryContentConsumer.class );
127 indexArtifactConsumer = ( KnownRepositoryContentConsumer ) knownContentConsumerControl.getMock();
128 indexPomConsumer = ( KnownRepositoryContentConsumer ) knownContentConsumerControl.getMock();
130 invalidContentConsumerControl = MockControl.createControl( InvalidRepositoryContentConsumer.class );
131 checkPomConsumer = ( InvalidRepositoryContentConsumer ) invalidContentConsumerControl.getMock();
132 checkMetadataConsumer = ( InvalidRepositoryContentConsumer ) invalidContentConsumerControl.getMock();
135 repoFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
136 repositoryFactory = ( RepositoryContentFactory ) repoFactoryControl.getMock();
138 metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
139 metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
141 listenerControl = MockControl.createControl( RepositoryListener.class );
142 listener = (RepositoryListener) listenerControl.getMock();
145 new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, repositoryFactory,
146 metadataRepository, repositoryTaskScheduler,
147 Collections.singletonList( listener ) );
150 /* Tests for repository consumers */
152 public void testGetAllRepoConsumers()
155 recordRepoConsumers();
157 repoConsumerUtilsControl.replay();
158 knownContentConsumerControl.replay();
159 invalidContentConsumerControl.replay();
161 List<String> repoConsumers = service.getAllRepositoryConsumers();
163 repoConsumerUtilsControl.verify();
164 knownContentConsumerControl.verify();
165 invalidContentConsumerControl.verify();
167 assertNotNull( repoConsumers );
168 assertEquals( 4, repoConsumers.size() );
169 assertTrue( repoConsumers.contains( "index-artifact" ) );
170 assertTrue( repoConsumers.contains( "index-pom" ) );
171 assertTrue( repoConsumers.contains( "check-pom" ) );
172 assertTrue( repoConsumers.contains( "check-metadata" ) );
175 public void testConfigureValidRepositoryConsumer()
178 RepositoryScanningConfiguration repoScanning = new RepositoryScanningConfiguration();
179 repoScanning.addKnownContentConsumer( "index-artifact" );
180 repoScanning.addKnownContentConsumer( "index-pom" );
181 repoScanning.addInvalidContentConsumer( "check-pom" );
183 // test enable "check-metadata" consumer
184 recordRepoConsumers();
186 archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
187 configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning );
189 config.setRepositoryScanning( repoScanning );
190 configControl.setMatcher( MockControl.ALWAYS_MATCHER );
191 configControl.setVoidCallable();
193 archivaConfig.save( config );
194 archivaConfigControl.setVoidCallable();
196 repoConsumerUtilsControl.replay();
197 knownContentConsumerControl.replay();
198 invalidContentConsumerControl.replay();
199 archivaConfigControl.replay();
200 configControl.replay();
204 boolean success = service.configureRepositoryConsumer( null, "check-metadata", true );
205 assertTrue( success );
207 catch ( Exception e )
209 fail( "An exception should not have been thrown." );
212 repoConsumerUtilsControl.verify();
213 knownContentConsumerControl.verify();
214 invalidContentConsumerControl.verify();
215 archivaConfigControl.verify();
216 configControl.verify();
218 // test disable "check-metadata" consumer
219 repoConsumerUtilsControl.reset();
220 knownContentConsumerControl.reset();
221 invalidContentConsumerControl.reset();
222 archivaConfigControl.reset();
223 configControl.reset();
225 repoScanning.addInvalidContentConsumer( "check-metadata" );
227 recordRepoConsumers();
229 archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
230 configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning );
232 config.setRepositoryScanning( repoScanning );
233 configControl.setMatcher( MockControl.ALWAYS_MATCHER );
234 configControl.setVoidCallable();
236 archivaConfig.save( config );
237 archivaConfigControl.setVoidCallable();
239 repoConsumerUtilsControl.replay();
240 knownContentConsumerControl.replay();
241 invalidContentConsumerControl.replay();
242 archivaConfigControl.replay();
243 configControl.replay();
247 boolean success = service.configureRepositoryConsumer( null, "check-metadata", false );
249 repoConsumerUtilsControl.verify();
250 knownContentConsumerControl.verify();
251 invalidContentConsumerControl.verify();
252 archivaConfigControl.verify();
253 configControl.verify();
255 assertTrue( success );
257 catch ( Exception e )
259 fail( "An excecption should not have been thrown." );
264 public void testConfigureInvalidRepositoryConsumer()
267 recordRepoConsumers();
269 repoConsumerUtilsControl.replay();
270 knownContentConsumerControl.replay();
271 invalidContentConsumerControl.replay();
275 service.configureRepositoryConsumer( null, "invalid-consumer", true );
276 fail( "An exception should have been thrown." );
278 catch ( Exception e )
280 assertEquals( "Invalid repository consumer.", e.getMessage() );
283 repoConsumerUtilsControl.verify();
284 knownContentConsumerControl.verify();
285 invalidContentConsumerControl.verify();
288 /* Tests for delete artifact */
290 public void testDeleteM2ArtifactArtifactExists()
293 ManagedRepositoryConfiguration managedRepo = createManagedRepo("default", "default-repo");
295 archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
296 configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo );
298 ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
299 repoContent.setRepository( managedRepo );
301 repoFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( "internal" ), repoContent );
303 List<ArtifactMetadata> artifacts = getArtifacts();
304 ArtifactMetadata artifact = artifacts.get( 0 );
306 metadataRepositoryControl.expectAndReturn(
307 metadataRepository.getArtifacts( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
308 artifact.getVersion() ), artifacts );
309 metadataRepository.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
310 artifact.getVersion(), artifact.getId() );
312 listener.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
313 artifact.getVersion(), artifact.getId() );
314 listenerControl.setVoidCallable( 1 );
316 archivaConfigControl.replay();
317 configControl.replay();
318 repoFactoryControl.replay();
319 metadataRepositoryControl.replay();
320 listenerControl.replay();
322 boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" );
323 assertTrue( success );
325 archivaConfigControl.verify();
326 configControl.verify();
327 repoFactoryControl.verify();
328 metadataRepositoryControl.verify();
329 listenerControl.verify();
331 assertFalse( new File( managedRepo.getLocation(), "org/apache/archiva/archiva-test/1.0" ).exists() );
332 assertTrue( new File( managedRepo.getLocation(), "org/apache/archiva/archiva-test/1.1" ).exists() );
335 public void testDeleteM1ArtifactArtifactExists()
338 MockControl fileTypesControl = MockClassControl.createControl( FileTypes.class );
339 FileTypes fileTypes = ( FileTypes ) fileTypesControl.getMock();
341 MockControl pathParserControl = MockClassControl.createControl( PathParser.class );
342 PathParser parser = ( PathParser ) pathParserControl.getMock();
344 ManagedRepositoryConfiguration managedRepo = createManagedRepo( "legacy", "legacy-repo" );
346 archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
347 configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo );
349 ManagedLegacyRepositoryContent repoContent = new ManagedLegacyRepositoryContent();
350 repoContent.setRepository( managedRepo );
351 repoContent.setFileTypes( fileTypes );
352 repoContent.setLegacyPathParser( parser );
354 repoFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( "internal" ), repoContent );
356 recordInManagedLegacyRepoContent( fileTypesControl, fileTypes, pathParserControl, parser );
358 List<ArtifactMetadata> artifacts = getArtifacts();
359 ArtifactMetadata artifact = artifacts.get( 0 );
361 metadataRepositoryControl.expectAndReturn(
362 metadataRepository.getArtifacts( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
363 artifact.getVersion() ), artifacts );
364 metadataRepository.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
365 artifact.getVersion(), artifact.getId() );
367 listener.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
368 artifact.getVersion(), artifact.getId() );
369 listenerControl.setVoidCallable( 1 );
371 archivaConfigControl.replay();
372 configControl.replay();
373 repoFactoryControl.replay();
374 metadataRepositoryControl.replay();
375 listenerControl.replay();
376 fileTypesControl.replay();
377 pathParserControl.replay();
379 boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" );
380 assertTrue( success );
382 archivaConfigControl.verify();
383 configControl.verify();
384 repoFactoryControl.verify();
385 metadataRepositoryControl.verify();
386 listenerControl.verify();
387 fileTypesControl.verify();
388 pathParserControl.verify();
390 File repo = new File( managedRepo.getLocation() );
391 assertFalse( new File( repo, "org.apache.archiva/jars/archiva-test-1.0.jar" ).exists() );
392 assertFalse( new File( repo, "org.apache.archiva/poms/archiva-test-1.0.pom" ).exists() );
394 assertTrue( new File( repo, "org.apache.archiva/jars/archiva-test-1.1.jar" ).exists() );
395 assertTrue( new File( repo, "org.apache.archiva/jars/archiva-diff-1.0.jar" ).exists() );
396 assertTrue( new File( repo, "org.apache.archiva/poms/archiva-test-1.1.pom" ).exists() );
397 assertTrue( new File( repo, "org.apache.archiva/poms/archiva-diff-1.0.pom" ).exists() );
400 public void testDeleteArtifactArtifactDoesNotExist()
403 ManagedRepositoryConfiguration managedRepo = createManagedRepo("default", "default-repo");
405 archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
406 configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo );
408 ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
409 repoContent.setRepository( managedRepo );
411 repoFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( "internal" ), repoContent );
413 archivaConfigControl.replay();
414 configControl.replay();
415 repoFactoryControl.replay();
419 service.deleteArtifact( "internal", "org.apache.archiva", "archiva-non-existing", "1.0" );
420 fail( "An exception should have been thrown." );
422 catch ( Exception e )
424 assertEquals( "Artifact does not exist.", e.getMessage() );
427 archivaConfigControl.verify();
428 configControl.verify();
429 repoFactoryControl.verify();
432 private ManagedRepositoryConfiguration createManagedRepo(String layout, String directory)
435 File srcDir = new File( getBasedir(), "src/test/repositories/"+ directory );
437 File repoDir = getTestFile( "target/test-repos/" + directory );
439 FileUtils.deleteDirectory( repoDir );
441 FileUtils.copyDirectory( srcDir, repoDir, FileFilterUtils.makeSVNAware( null ) );
443 ManagedRepositoryConfiguration managedRepo =
444 createManagedRepo( "internal", layout, "Internal Repository", true, false );
445 managedRepo.setLocation( repoDir.getAbsolutePath() );
449 public void testDeleteArtifacRepositoryDoesNotExist()
452 archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
453 configControl.expectAndReturn( config.findManagedRepositoryById( "non-existing-repo" ), null );
455 archivaConfigControl.replay();
456 configControl.replay();
460 service.deleteArtifact( "non-existing-repo", "org.apache.archiva", "archiva-test", "1.0" );
461 fail( "An exception should have been thrown." );
463 catch ( Exception e )
465 assertEquals( "Repository does not exist.", e.getMessage() );
468 archivaConfigControl.verify();
469 configControl.verify();
472 /* Tests for repository scanning */
474 public void testExecuteRepoScannerRepoExistsAndNotBeingScanned()
477 archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
478 configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ),
479 createManagedRepo( "internal", "default", "Internal Repository", true, false ) );
481 RepositoryTask task = new RepositoryTask();
483 repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( "internal" ), false );
485 repositoryTaskScheduler.queueTask( task );
486 repositoryTaskSchedulerControl.setMatcher( MockControl.ALWAYS_MATCHER );
487 repositoryTaskSchedulerControl.setVoidCallable();
489 archivaConfigControl.replay();
490 configControl.replay();
491 repositoryTaskSchedulerControl.replay();
495 boolean success = service.executeRepositoryScanner( "internal" );
496 assertTrue( success );
498 catch ( Exception e )
500 fail( "An exception should not have been thrown." );
503 archivaConfigControl.verify();
504 configControl.verify();
505 repositoryTaskSchedulerControl.verify();
508 public void testExecuteRepoScannerRepoExistsButBeingScanned()
511 archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
512 configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ),
513 createManagedRepo( "internal", "default", "Internal Repository", true, false ) );
515 repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( "internal" ), true);
517 archivaConfigControl.replay();
518 configControl.replay();
519 repositoryTaskSchedulerControl.replay();
523 boolean success = service.executeRepositoryScanner( "internal" );
524 assertFalse( success );
526 catch ( Exception e )
528 fail( "An exception should not have been thrown." );
531 archivaConfigControl.verify();
532 configControl.verify();
533 repositoryTaskSchedulerControl.verify();
536 public void testExecuteRepoScannerRepoDoesNotExist()
539 archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
540 configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), null );
542 archivaConfigControl.replay();
543 configControl.replay();
547 service.executeRepositoryScanner( "internal" );
548 fail( "An exception should have been thrown." );
550 catch ( Exception e )
552 assertEquals( "Repository does not exist.", e.getMessage() );
555 archivaConfigControl.verify();
556 configControl.verify();
559 /* Tests for querying repositories */
561 public void testGetAllManagedRepositories()
564 List<ManagedRepositoryConfiguration> managedRepos = new ArrayList<ManagedRepositoryConfiguration>();
565 managedRepos.add( createManagedRepo( "internal", "default", "Internal Repository", true, false ) );
566 managedRepos.add( createManagedRepo( "snapshots", "default", "Snapshots Repository", false, true ) );
568 archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
569 configControl.expectAndReturn( config.getManagedRepositories(), managedRepos );
571 archivaConfigControl.replay();
572 configControl.replay();
574 List<ManagedRepository> repos = service.getAllManagedRepositories();
576 archivaConfigControl.verify();
577 configControl.verify();
579 assertNotNull( repos );
580 assertEquals( 2, repos.size() );
582 assertManagedRepo( repos.get( 0 ), managedRepos.get( 0 ) );
583 assertManagedRepo( repos.get( 1 ), managedRepos.get( 1 ) );
586 public void testGetAllRemoteRepositories()
589 List<RemoteRepositoryConfiguration> remoteRepos = new ArrayList<RemoteRepositoryConfiguration>();
590 remoteRepos.add( createRemoteRepository( "central", "Central Repository", "default", "http://repo1.maven.org/maven2") );
591 remoteRepos.add( createRemoteRepository( "dummy", "Dummy Remote Repository", "legacy", "http://dummy.com/dummy") );
593 archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
594 configControl.expectAndReturn( config.getRemoteRepositories(), remoteRepos );
596 archivaConfigControl.replay();
597 configControl.replay();
599 List<RemoteRepository> repos = service.getAllRemoteRepositories();
601 archivaConfigControl.verify();
602 configControl.verify();
604 assertNotNull( repos );
605 assertEquals( 2, repos.size() );
607 assertRemoteRepo( repos.get( 0 ), remoteRepos.get( 0 ) );
608 assertRemoteRepo( repos.get( 1 ), remoteRepos.get( 1 ) );
611 /* private methods */
613 private void assertRemoteRepo( RemoteRepository remoteRepo, RemoteRepositoryConfiguration expectedRepoConfig )
615 assertEquals( expectedRepoConfig.getId(), remoteRepo.getId() );
616 assertEquals( expectedRepoConfig.getLayout(), remoteRepo.getLayout() );
617 assertEquals( expectedRepoConfig.getName(), remoteRepo.getName() );
618 assertEquals( expectedRepoConfig.getUrl(), remoteRepo.getUrl() );
621 private RemoteRepositoryConfiguration createRemoteRepository(String id, String name, String layout, String url)
623 RemoteRepositoryConfiguration remoteConfig = new RemoteRepositoryConfiguration();
624 remoteConfig.setId( id );
625 remoteConfig.setName( name );
626 remoteConfig.setLayout( layout );
627 remoteConfig.setUrl( url );
632 private void assertManagedRepo( ManagedRepository managedRepo, ManagedRepositoryConfiguration expectedRepoConfig )
634 assertEquals( expectedRepoConfig.getId(), managedRepo.getId() );
635 assertEquals( expectedRepoConfig.getLayout(), managedRepo.getLayout() );
636 assertEquals( expectedRepoConfig.getName(), managedRepo.getName() );
638 //TODO enable assert once fixed in AdministrationServiceImpl!
639 //assertEquals( "http://localhost:8080/archiva/repository/" + expectedRepoConfig.getId(), managedRepo.getUrl() );
640 assertEquals( expectedRepoConfig.isReleases(), managedRepo.isReleases() );
641 assertEquals( expectedRepoConfig.isSnapshots(), managedRepo.isSnapshots() );
644 private ManagedRepositoryConfiguration createManagedRepo( String id, String layout, String name,
645 boolean hasReleases, boolean hasSnapshots )
647 ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
648 repoConfig.setId( id );
649 repoConfig.setLayout( layout );
650 repoConfig.setName( name );
651 repoConfig.setReleases( hasReleases );
652 repoConfig.setSnapshots( hasSnapshots );
657 private void recordRepoConsumers()
659 List<KnownRepositoryContentConsumer> availableKnownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
660 availableKnownConsumers.add( indexArtifactConsumer );
661 availableKnownConsumers.add( indexPomConsumer );
663 List<InvalidRepositoryContentConsumer> availableInvalidConsumers = new ArrayList<InvalidRepositoryContentConsumer>();
664 availableInvalidConsumers.add( checkPomConsumer );
665 availableInvalidConsumers.add( checkMetadataConsumer );
667 repoConsumerUtilsControl.expectAndReturn( repoConsumersUtil.getAvailableKnownConsumers(), availableKnownConsumers );
668 knownContentConsumerControl.expectAndReturn( indexArtifactConsumer.getId(), "index-artifact" );
669 knownContentConsumerControl.expectAndReturn( indexPomConsumer.getId(), "index-pom" );
671 repoConsumerUtilsControl.expectAndReturn( repoConsumersUtil.getAvailableInvalidConsumers(), availableInvalidConsumers );
672 invalidContentConsumerControl.expectAndReturn( checkPomConsumer.getId(), "check-pom" );
673 invalidContentConsumerControl.expectAndReturn( checkMetadataConsumer.getId(), "check-metadata" );
676 private void recordInManagedLegacyRepoContent( MockControl fileTypesControl, FileTypes fileTypes,
677 MockControl pathParserControl, PathParser parser )
678 throws LayoutException
680 String sep = File.separator;
681 String ad10p = "org.apache.archiva" + sep + "poms" + sep + "archiva-diff-1.0.pom";
682 String at10p = "org.apache.archiva" + sep + "poms" + sep + "archiva-test-1.0.pom";
683 String at11p = "org.apache.archiva" + sep + "poms" + sep + "archiva-test-1.1.pom";
684 String ad10j = "org.apache.archiva" + sep + "jars" + sep + "archiva-diff-1.0.jar";
685 String at10j = "org.apache.archiva" + sep + "jars" + sep + "archiva-test-1.0.jar";
686 String at11j = "org.apache.archiva" + sep + "jars" + sep + "archiva-test-1.1.jar";
688 fileTypesControl.expectAndReturn( fileTypes.matchesArtifactPattern( at10p ), true );
689 fileTypesControl.expectAndReturn( fileTypes.matchesArtifactPattern( at11p ), true );
690 fileTypesControl.expectAndReturn( fileTypes.matchesArtifactPattern( ad10p ), true );
691 fileTypesControl.expectAndReturn( fileTypes.matchesArtifactPattern( ad10j ), true );
692 fileTypesControl.expectAndReturn( fileTypes.matchesArtifactPattern( at10j ), true );
693 fileTypesControl.expectAndReturn( fileTypes.matchesArtifactPattern( at11j ), true );
695 ArtifactReference aRef = createArtifactReference("archiva-test", "org.apache.archiva", "1.1", "pom");
696 pathParserControl.expectAndReturn( parser.toArtifactReference( at11p ), aRef );
698 aRef = createArtifactReference("archiva-test", "org.apache.archiva", "1.0", "pom");
699 pathParserControl.expectAndReturn( parser.toArtifactReference( at10p ), aRef );
701 aRef = createArtifactReference("archiva-diff", "org.apache.archiva", "1.0", "pom");
702 pathParserControl.expectAndReturn( parser.toArtifactReference( ad10p ), aRef );
704 aRef = createArtifactReference("archiva-diff", "org.apache.archiva", "1.0", "jar");
705 pathParserControl.expectAndReturn( parser.toArtifactReference( ad10j ), aRef );
707 aRef = createArtifactReference("archiva-test", "org.apache.archiva", "1.0", "jar");
708 pathParserControl.expectAndReturn( parser.toArtifactReference( at10j ), aRef );
710 aRef = createArtifactReference("archiva-test", "org.apache.archiva", "1.1", "jar");
711 pathParserControl.expectAndReturn( parser.toArtifactReference( at11j ), aRef );
714 private List<ArtifactMetadata> getArtifacts()
716 List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>();
718 ArtifactMetadata artifact = new ArtifactMetadata();
719 artifact.setId( "archiva-test-1.0.jar" );
720 artifact.setProject( "archiva-test" );
721 artifact.setVersion( "1.0" );
722 artifact.setProjectVersion( "1.0" );
723 artifact.setNamespace( "org.apache.archiva" );
724 artifact.setRepositoryId( "internal" );
725 artifacts.add( artifact );
729 private ArtifactReference createArtifactReference( String artifactId, String groupId, String version, String type )
731 ArtifactReference aRef = new ArtifactReference();
732 aRef.setArtifactId( artifactId );
733 aRef.setGroupId( groupId );
734 aRef.setType( type );
735 aRef.setVersion( version );