1 package org.apache.maven.archiva.web.action;
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 com.opensymphony.xwork2.Action;
23 import org.apache.archiva.metadata.model.ArtifactMetadata;
24 import org.apache.archiva.metadata.model.Dependency;
25 import org.apache.archiva.metadata.model.MailingList;
26 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
27 import org.apache.archiva.metadata.model.ProjectVersionReference;
28 import org.apache.archiva.metadata.repository.MetadataRepository;
29 import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
30 import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
31 import org.apache.maven.archiva.common.utils.VersionUtil;
32 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
33 import org.apache.maven.archiva.configuration.Configuration;
34 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
35 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
36 import org.apache.maven.archiva.repository.RepositoryContentFactory;
37 import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
39 import java.util.Arrays;
40 import java.util.Collections;
41 import java.util.List;
44 import static org.mockito.Mockito.mock;
45 import static org.mockito.Mockito.when;
47 public class ShowArtifactActionTest
48 extends AbstractActionTestCase
50 private static final String ACTION_HINT = "showArtifactAction";
52 private static final String TEST_VERSION = "version";
54 private static final String TEST_SNAPSHOT_VERSION = "1.0-SNAPSHOT";
56 private static final String TEST_TS_SNAPSHOT_VERSION = "1.0-20091120.111111-1";
58 private static final String OTHER_TEST_REPO = "first-repo";
60 private ShowArtifactAction action;
62 private static final List<ArtifactMetadata> TEST_SNAPSHOT_ARTIFACTS = Arrays.asList( createArtifact(
63 TEST_TS_SNAPSHOT_VERSION ), createArtifact( "1.0-20091120.222222-2", "20091120.222222", 2 ), createArtifact(
64 "1.0-20091123.333333-3", "20091123.333333", 3 ) );
66 private static final long TEST_SIZE = 12345L;
68 private static final String TEST_TYPE = "jar";
70 public void testInstantiation()
72 assertFalse( action == lookup( Action.class, ACTION_HINT ) );
75 public void testGetArtifactUniqueRelease()
77 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
80 setActionParameters();
82 String result = action.artifact();
84 assertActionSuccess( action, result );
86 assertActionParameters( action );
87 ProjectVersionMetadata model = action.getModel();
88 assertDefaultModel( model );
90 assertEquals( TEST_REPO, action.getRepositoryId() );
92 assertNull( action.getDependees() );
93 assertNull( action.getDependencies() );
94 assertNull( action.getMailingLists() );
95 assertTrue( action.getArtifacts().isEmpty() );
98 public void testGetArtifactUniqueSnapshot()
100 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
101 TEST_SNAPSHOT_VERSION ) );
102 metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
103 TEST_SNAPSHOT_ARTIFACTS );
105 action.setGroupId( TEST_GROUP_ID );
106 action.setArtifactId( TEST_ARTIFACT_ID );
107 action.setVersion( TEST_SNAPSHOT_VERSION );
109 String result = action.artifact();
111 assertActionSuccess( action, result );
113 assertEquals( TEST_GROUP_ID, action.getGroupId() );
114 assertEquals( TEST_ARTIFACT_ID, action.getArtifactId() );
115 assertEquals( TEST_SNAPSHOT_VERSION, action.getVersion() );
116 ProjectVersionMetadata model = action.getModel();
117 assertDefaultModel( model, TEST_SNAPSHOT_VERSION );
119 assertEquals( TEST_REPO, action.getRepositoryId() );
121 assertArtifacts( TEST_SNAPSHOT_ARTIFACTS, action.getArtifacts() );
123 assertNull( action.getDependees() );
124 assertNull( action.getDependencies() );
125 assertNull( action.getMailingLists() );
128 public void testGetArtifactUniqueSnapshotTimestamped()
130 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
131 TEST_SNAPSHOT_VERSION ) );
132 metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
133 TEST_SNAPSHOT_ARTIFACTS );
135 action.setGroupId( TEST_GROUP_ID );
136 action.setArtifactId( TEST_ARTIFACT_ID );
137 action.setVersion( TEST_TS_SNAPSHOT_VERSION );
139 String result = action.artifact();
140 assertError( result );
141 assertNoOutputFields();
144 public void testGetMissingProject()
146 setActionParameters();
148 String result = action.artifact();
149 assertError( result );
151 assertActionParameters( action );
152 assertNoOutputFields();
155 public void testGetArtifactNoObservableRepos()
157 setObservableRepos( Collections.<String>emptyList() );
159 setActionParameters();
161 String result = action.artifact();
163 // Actually, it'd be better to have an error:
164 assertError( result );
165 assertActionParameters( action );
166 assertNoOutputFields();
169 public void testGetArtifactNotInObservableRepos()
171 metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
174 setActionParameters();
176 String result = action.artifact();
177 assertError( result );
179 assertActionParameters( action );
180 assertNoOutputFields();
183 public void testGetArtifactOnlySeenInSecondObservableRepo()
185 setObservableRepos( Arrays.asList( OTHER_TEST_REPO, TEST_REPO ) );
186 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
189 setActionParameters();
191 String result = action.artifact();
193 assertActionSuccess( action, result );
195 assertActionParameters( action );
196 ProjectVersionMetadata model = action.getModel();
197 assertDefaultModel( model );
199 assertEquals( TEST_REPO, action.getRepositoryId() );
201 assertNull( action.getDependees() );
202 assertNull( action.getDependencies() );
203 assertNull( action.getMailingLists() );
204 assertTrue( action.getArtifacts().isEmpty() );
207 public void testGetArtifactSeenInBothObservableRepo()
209 setObservableRepos( Arrays.asList( TEST_REPO, OTHER_TEST_REPO ) );
210 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
212 metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
215 setActionParameters();
217 String result = action.artifact();
219 assertActionSuccess( action, result );
221 assertActionParameters( action );
222 ProjectVersionMetadata model = action.getModel();
223 assertDefaultModel( model );
225 assertEquals( TEST_REPO, action.getRepositoryId() );
227 assertNull( action.getDependees() );
228 assertNull( action.getDependencies() );
229 assertNull( action.getMailingLists() );
230 assertTrue( action.getArtifacts().isEmpty() );
233 public void testGetArtifactCanOnlyObserveInOneOfTwoRepos()
235 setObservableRepos( Arrays.asList( TEST_REPO ) );
236 metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
238 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
241 setActionParameters();
243 String result = action.artifact();
245 assertActionSuccess( action, result );
247 assertActionParameters( action );
248 ProjectVersionMetadata model = action.getModel();
249 assertDefaultModel( model );
251 assertEquals( TEST_REPO, action.getRepositoryId() );
253 assertNull( action.getDependees() );
254 assertNull( action.getDependencies() );
255 assertNull( action.getMailingLists() );
256 assertTrue( action.getArtifacts().isEmpty() );
259 public void testGetArtifactNoMavenFacet()
261 ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata();
262 versionMetadata.setId( TEST_VERSION );
263 versionMetadata.setUrl( TEST_URL );
264 versionMetadata.setName( TEST_NAME );
265 versionMetadata.setDescription( TEST_DESCRIPTION );
267 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
269 setActionParameters();
271 String result = action.artifact();
273 assertActionSuccess( action, result );
275 assertActionParameters( action );
276 ProjectVersionMetadata model = action.getModel();
277 assertEquals( TEST_VERSION, model.getVersion() );
278 assertEquals( TEST_URL, model.getUrl() );
279 assertEquals( TEST_NAME, model.getName() );
280 assertEquals( TEST_DESCRIPTION, model.getDescription() );
282 assertEquals( TEST_REPO, action.getRepositoryId() );
284 assertNull( action.getDependees() );
285 assertNull( action.getDependencies() );
286 assertNull( action.getMailingLists() );
287 assertTrue( action.getArtifacts().isEmpty() );
290 public void testGetMailingLists()
292 ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
293 MailingList ml1 = createMailingList( "Users List", "users" );
294 MailingList ml2 = createMailingList( "Developers List", "dev" );
295 versionMetadata.setMailingLists( Arrays.asList( ml1, ml2 ) );
296 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
298 setActionParameters();
300 String result = action.mailingLists();
302 assertActionSuccess( action, result );
304 assertActionParameters( action );
305 ProjectVersionMetadata model = action.getModel();
306 assertDefaultModel( model );
308 assertNotNull( action.getMailingLists() );
309 assertMailingList( action.getMailingLists().get( 0 ), "Users List", "users" );
310 assertMailingList( action.getMailingLists().get( 1 ), "Developers List", "dev" );
312 assertEquals( TEST_REPO, action.getRepositoryId() );
313 assertNull( action.getDependees() );
314 assertNull( action.getDependencies() );
315 assertTrue( action.getArtifacts().isEmpty() );
318 public void testGetDependencies()
320 ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
321 Dependency dependency1 = createDependencyBasic( "artifactId1" );
322 Dependency dependency2 = createDependencyExtended( "artifactId2" );
323 versionMetadata.setDependencies( Arrays.asList( dependency1, dependency2 ) );
324 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
326 setActionParameters();
328 String result = action.dependencies();
330 assertActionSuccess( action, result );
332 assertActionParameters( action );
333 ProjectVersionMetadata model = action.getModel();
334 assertDefaultModel( model );
336 assertNotNull( action.getDependencies() );
337 assertDependencyBasic( action.getDependencies().get( 0 ), "artifactId1" );
338 assertDependencyExtended( action.getDependencies().get( 1 ), "artifactId2" );
340 assertEquals( TEST_REPO, action.getRepositoryId() );
341 assertNull( action.getDependees() );
342 assertNull( action.getMailingLists() );
343 assertTrue( action.getArtifacts().isEmpty() );
346 public void testGetDependees()
349 ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
350 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
351 ProjectVersionReference dependee1 = createReference( "artifactId1" );
352 ProjectVersionReference dependee2 = createReference( "artifactId2" );
353 metadataResolver.setProjectReferences( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION, Arrays.asList(
354 dependee1, dependee2 ) );
356 setActionParameters();
358 String result = action.dependees();
360 assertActionSuccess( action, result );
362 assertActionParameters( action );
363 ProjectVersionMetadata model = action.getModel();
364 assertDefaultModel( model );
366 assertNotNull( action.getDependees() );
367 assertCoordinate( action.getDependees().get( 0 ), "artifactId1" );
368 assertCoordinate( action.getDependees().get( 1 ), "artifactId2" );
370 assertEquals( TEST_REPO, action.getRepositoryId() );
371 assertNull( action.getDependencies() );
372 assertNull( action.getMailingLists() );
373 assertTrue( action.getArtifacts().isEmpty() );
376 public void testGetProjectMetadata()
378 ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
380 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
382 setActionParameters();
384 String result = action.projectMetadata();
386 assertActionSuccess( action, result );
388 assertActionParameters( action );
390 Map<String, String> genericMetadata = action.getGenericMetadata();
391 assertNotNull( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ) );
392 assertEquals( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ),
393 TEST_GENERIC_METADATA_PROPERTY_VALUE );
395 assertEquals( TEST_REPO, action.getRepositoryId() );
396 assertNotNull( action.getModel() );
397 assertNull( action.getDependees() );
398 assertNull( action.getDependencies() );
399 assertNull( action.getMailingLists() );
400 assertTrue( action.getArtifacts().isEmpty() );
403 public void testAddAndDeleteMetadataProperty()
405 ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
407 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
409 setActionParameters();
410 action.setPropertyName( "foo" );
411 action.setPropertyValue( "bar" );
412 action.setRepositoryId( TEST_REPO );
414 MetadataRepository repo = mock( MetadataRepository.class );
415 action.setMetadataRepository( repo );
417 String result = action.addMetadataProperty();
419 assertActionSuccess( action, result );
420 assertActionParameters( action );
422 Map<String, String> genericMetadata = action.getGenericMetadata();
423 assertNotNull( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ) );
424 assertEquals( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ),
425 TEST_GENERIC_METADATA_PROPERTY_VALUE );
427 assertNotNull( genericMetadata.get( "foo" ) );
428 assertEquals( "bar", genericMetadata.get( "foo" ) );
430 assertEquals( TEST_REPO, action.getRepositoryId() );
431 assertNotNull( action.getModel() );
432 assertNull( action.getDependees() );
433 assertNull( action.getDependencies() );
434 assertNull( action.getMailingLists() );
435 assertTrue( action.getArtifacts().isEmpty() );
437 // test delete property
438 setActionParameters();
439 action.setDeleteItem( "foo" );
441 result = action.deleteMetadataEntry();
443 assertEquals( Action.SUCCESS, result );
444 assertActionParameters( action );
445 assertTrue( !action.getActionMessages().isEmpty() );
446 assertTrue( action.getActionMessages().contains( "Property successfully deleted." ) );
448 genericMetadata = action.getGenericMetadata();
449 assertNotNull( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ) );
450 assertEquals( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ),
451 TEST_GENERIC_METADATA_PROPERTY_VALUE );
453 assertNull( genericMetadata.get( "foo" ) );
455 assertEquals( TEST_REPO, action.getRepositoryId() );
456 assertNotNull( action.getModel() );
457 assertNull( action.getDependees() );
458 assertNull( action.getDependencies() );
459 assertNull( action.getMailingLists() );
460 assertTrue( action.getArtifacts().isEmpty() );
463 private void assertArtifacts( List<ArtifactMetadata> expectedArtifacts,
464 Map<String, List<ShowArtifactAction.ArtifactDownloadInfo>> artifactMap )
466 // assuming only one of each version at this point
467 assertEquals( expectedArtifacts.size(), artifactMap.size() );
468 for ( ArtifactMetadata artifact : expectedArtifacts )
470 assertTrue( artifactMap.containsKey( artifact.getVersion() ) );
471 List<ShowArtifactAction.ArtifactDownloadInfo> list = artifactMap.get( artifact.getVersion() );
472 ShowArtifactAction.ArtifactDownloadInfo actual = list.get( 0 );
473 assertEquals( artifact.getNamespace(), actual.getNamespace() );
474 assertEquals( artifact.getId(), actual.getId() );
475 assertEquals( artifact.getProject(), actual.getProject() );
476 assertEquals( artifact.getRepositoryId(), actual.getRepositoryId() );
477 assertEquals( artifact.getVersion(), actual.getVersion() );
478 assertEquals( TEST_TYPE, actual.getType() );
479 assertEquals( "12.06 K", actual.getSize() );
480 assertEquals( artifact.getNamespace() + "/" + artifact.getProject() + "/" + TEST_SNAPSHOT_VERSION + "/" +
481 artifact.getId(), actual.getPath() );
485 private static ArtifactMetadata createArtifact( String version )
487 return createArtifact( version, null, 0 );
490 private static ArtifactMetadata createArtifact( String version, String timestamp, int buildNumber )
492 ArtifactMetadata metadata = new ArtifactMetadata();
493 metadata.setProject( TEST_ARTIFACT_ID );
494 metadata.setId( TEST_ARTIFACT_ID + "-" + version + ".jar" );
495 metadata.setNamespace( TEST_GROUP_ID );
496 metadata.setRepositoryId( TEST_REPO );
497 metadata.setSize( TEST_SIZE );
498 metadata.setProjectVersion( VersionUtil.getBaseVersion( version ) );
499 metadata.setVersion( version );
501 MavenArtifactFacet facet = new MavenArtifactFacet();
502 facet.setType( "jar" );
503 facet.setTimestamp( timestamp );
504 facet.setBuildNumber( buildNumber );
505 metadata.addFacet( facet );
510 private ProjectVersionReference createReference( String projectId )
512 ProjectVersionReference reference = new ProjectVersionReference();
513 reference.setNamespace( "groupId" );
514 reference.setProjectId( projectId );
515 reference.setProjectVersion( "version" );
516 reference.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY );
520 private void assertCoordinate( ProjectVersionReference dependee, String artifactId )
522 assertEquals( artifactId, dependee.getProjectId() );
523 assertEquals( "groupId", dependee.getNamespace() );
524 assertEquals( "version", dependee.getProjectVersion() );
527 private void assertDependencyBasic( Dependency dependency, String artifactId )
529 assertEquals( artifactId, dependency.getArtifactId() );
530 assertEquals( "groupId", dependency.getGroupId() );
531 assertEquals( "version", dependency.getVersion() );
534 private void assertDependencyExtended( Dependency dependency, String artifactId )
536 assertDependencyBasic( dependency, artifactId );
537 assertEquals( true, dependency.isOptional() );
538 assertEquals( "classifier", dependency.getClassifier() );
539 assertEquals( "type", dependency.getType() );
540 assertEquals( "scope", dependency.getScope() );
541 assertEquals( "systemPath", dependency.getSystemPath() );
544 private Dependency createDependencyExtended( String artifactId )
546 Dependency dependency = createDependencyBasic( artifactId );
547 dependency.setClassifier( "classifier" );
548 dependency.setOptional( true );
549 dependency.setScope( "scope" );
550 dependency.setSystemPath( "systemPath" );
551 dependency.setType( "type" );
555 private Dependency createDependencyBasic( String artifactId )
557 Dependency dependency = new Dependency();
558 dependency.setArtifactId( artifactId );
559 dependency.setGroupId( "groupId" );
560 dependency.setVersion( "version" );
564 private void assertMailingList( MailingList mailingList, String name, String prefix )
566 assertEquals( name, mailingList.getName() );
567 assertEquals( prefix + "-post@", mailingList.getPostAddress() );
568 assertEquals( prefix + "-subscribe@", mailingList.getSubscribeAddress() );
569 assertEquals( prefix + "-unsubscribe@", mailingList.getUnsubscribeAddress() );
570 assertEquals( prefix + "-archive-url", mailingList.getMainArchiveUrl() );
571 assertEquals( Arrays.asList( "other-" + prefix + "-archive-url-1", "other-" + prefix + "-archive-url-2" ),
572 mailingList.getOtherArchives() );
575 private MailingList createMailingList( String name, String prefix )
577 MailingList ml1 = new MailingList();
579 ml1.setPostAddress( prefix + "-post@" );
580 ml1.setSubscribeAddress( prefix + "-subscribe@" );
581 ml1.setUnsubscribeAddress( prefix + "-unsubscribe@" );
582 ml1.setMainArchiveUrl( prefix + "-archive-url" );
583 ml1.setOtherArchives( Arrays.asList( "other-" + prefix + "-archive-url-1",
584 "other-" + prefix + "-archive-url-2" ) );
588 private void assertNoOutputFields()
590 assertNull( action.getModel() );
591 assertNull( action.getDependees() );
592 assertNull( action.getDependencies() );
593 assertNull( action.getMailingLists() );
594 assertTrue( action.getArtifacts().isEmpty() );
597 private void assertError( String result )
599 assertEquals( Action.ERROR, result );
600 assertEquals( 1, action.getActionErrors().size() );
603 private void assertDefaultModel( ProjectVersionMetadata model )
605 assertDefaultModel( model, TEST_VERSION );
608 private void setActionParameters()
610 action.setGroupId( TEST_GROUP_ID );
611 action.setArtifactId( TEST_ARTIFACT_ID );
612 action.setVersion( TEST_VERSION );
615 private void assertActionParameters( ShowArtifactAction action )
617 assertEquals( TEST_GROUP_ID, action.getGroupId() );
618 assertEquals( TEST_ARTIFACT_ID, action.getArtifactId() );
619 assertEquals( TEST_VERSION, action.getVersion() );
622 private void assertActionSuccess( ShowArtifactAction action, String result )
624 assertEquals( Action.SUCCESS, result );
625 assertTrue( action.getActionErrors().isEmpty() );
626 assertTrue( action.getActionMessages().isEmpty() );
629 protected void setUp()
633 action = (ShowArtifactAction) lookup( Action.class, ACTION_HINT );
634 metadataResolver = (TestMetadataResolver) action.getMetadataResolver();
636 RepositoryContentFactory factory = mock( RepositoryContentFactory.class );
637 action.setRepositoryFactory( factory );
639 ManagedRepositoryConfiguration config = new ManagedRepositoryConfiguration();
640 config.setId( TEST_REPO );
641 config.setLocation( getTestFile( "target/test-repo" ).getAbsolutePath() );
643 ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
644 content.setRepository( config );
645 when( factory.getManagedRepositoryContent( TEST_REPO ) ).thenReturn( content );
647 ArchivaConfiguration archivaConfig = mock( ArchivaConfiguration.class );
649 Configuration configuration = new Configuration();
650 configuration.addManagedRepository( config );
651 when( archivaConfig.getConfiguration() ).thenReturn( configuration );