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.RepositorySession;
30 import org.apache.archiva.metadata.repository.RepositorySessionFactory;
31 import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
32 import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
33 import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
34 import org.apache.maven.archiva.common.utils.VersionUtil;
35 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
36 import org.apache.maven.archiva.configuration.Configuration;
37 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
38 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
39 import org.apache.maven.archiva.repository.RepositoryContentFactory;
40 import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
43 import java.util.Arrays;
44 import java.util.Collections;
45 import java.util.List;
48 import static org.mockito.Mockito.mock;
49 import static org.mockito.Mockito.when;
51 public class ShowArtifactActionTest
52 extends AbstractActionTestCase
54 private static final String ACTION_HINT = "showArtifactAction";
56 private static final String TEST_VERSION = "version";
58 private static final String TEST_SNAPSHOT_VERSION = "1.0-SNAPSHOT";
60 private static final String TEST_TS_SNAPSHOT_VERSION = "1.0-20091120.111111-1";
62 private static final String OTHER_TEST_REPO = "first-repo";
64 private ShowArtifactAction action;
66 private static final List<ArtifactMetadata> TEST_SNAPSHOT_ARTIFACTS = Arrays.asList( createArtifact(
67 TEST_TS_SNAPSHOT_VERSION ), createArtifact( "1.0-20091120.222222-2", "20091120.222222", 2 ), createArtifact(
68 "1.0-20091123.333333-3", "20091123.333333", 3 ) );
70 private static final long TEST_SIZE = 12345L;
72 private static final String TEST_TYPE = "jar";
74 public void testInstantiation()
76 assertFalse( action == getActionProxy( "/showArtifact.action" ).getAction() );
79 public void testGetArtifactUniqueRelease()
81 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
84 setActionParameters();
86 String result = action.artifact();
88 assertActionSuccess( action, result );
90 assertActionParameters( action );
91 ProjectVersionMetadata model = action.getModel();
92 assertDefaultModel( model );
94 assertEquals( TEST_REPO, action.getRepositoryId() );
96 assertNull( action.getDependees() );
97 assertNull( action.getDependencies() );
98 assertNull( action.getMailingLists() );
99 assertTrue( action.getArtifacts().isEmpty() );
102 public void testGetArtifactUniqueSnapshot()
104 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
105 TEST_SNAPSHOT_VERSION ) );
106 metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
107 TEST_SNAPSHOT_ARTIFACTS );
109 action.setGroupId( TEST_GROUP_ID );
110 action.setArtifactId( TEST_ARTIFACT_ID );
111 action.setVersion( TEST_SNAPSHOT_VERSION );
113 String result = action.artifact();
115 assertActionSuccess( action, result );
117 assertEquals( TEST_GROUP_ID, action.getGroupId() );
118 assertEquals( TEST_ARTIFACT_ID, action.getArtifactId() );
119 assertEquals( TEST_SNAPSHOT_VERSION, action.getVersion() );
120 ProjectVersionMetadata model = action.getModel();
121 assertDefaultModel( model, TEST_SNAPSHOT_VERSION );
123 assertEquals( TEST_REPO, action.getRepositoryId() );
125 assertArtifacts( TEST_SNAPSHOT_ARTIFACTS, action.getArtifacts() );
127 assertNull( action.getDependees() );
128 assertNull( action.getDependencies() );
129 assertNull( action.getMailingLists() );
132 public void testGetArtifactUniqueSnapshotTimestamped()
134 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
135 TEST_SNAPSHOT_VERSION ) );
136 metadataResolver.setArtifacts( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_SNAPSHOT_VERSION,
137 TEST_SNAPSHOT_ARTIFACTS );
139 action.setGroupId( TEST_GROUP_ID );
140 action.setArtifactId( TEST_ARTIFACT_ID );
141 action.setVersion( TEST_TS_SNAPSHOT_VERSION );
143 String result = action.artifact();
144 assertError( result );
145 assertNoOutputFields();
148 public void testGetMissingProject()
150 setActionParameters();
152 String result = action.artifact();
153 assertError( result );
155 assertActionParameters( action );
156 assertNoOutputFields();
159 public void testGetArtifactNoObservableRepos()
161 setObservableRepos( Collections.<String>emptyList() );
163 setActionParameters();
165 String result = action.artifact();
167 // Actually, it'd be better to have an error:
168 assertError( result );
169 assertActionParameters( action );
170 assertNoOutputFields();
173 public void testGetArtifactNotInObservableRepos()
175 metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
178 setActionParameters();
180 String result = action.artifact();
181 assertError( result );
183 assertActionParameters( action );
184 assertNoOutputFields();
187 public void testGetArtifactOnlySeenInSecondObservableRepo()
189 setObservableRepos( Arrays.asList( OTHER_TEST_REPO, TEST_REPO ) );
190 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
193 setActionParameters();
195 String result = action.artifact();
197 assertActionSuccess( action, result );
199 assertActionParameters( action );
200 ProjectVersionMetadata model = action.getModel();
201 assertDefaultModel( model );
203 assertEquals( TEST_REPO, action.getRepositoryId() );
205 assertNull( action.getDependees() );
206 assertNull( action.getDependencies() );
207 assertNull( action.getMailingLists() );
208 assertTrue( action.getArtifacts().isEmpty() );
211 public void testGetArtifactSeenInBothObservableRepo()
213 setObservableRepos( Arrays.asList( TEST_REPO, OTHER_TEST_REPO ) );
214 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
216 metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
219 setActionParameters();
221 String result = action.artifact();
223 assertActionSuccess( action, result );
225 assertActionParameters( action );
226 ProjectVersionMetadata model = action.getModel();
227 assertDefaultModel( model );
229 assertEquals( TEST_REPO, action.getRepositoryId() );
231 assertNull( action.getDependees() );
232 assertNull( action.getDependencies() );
233 assertNull( action.getMailingLists() );
234 assertTrue( action.getArtifacts().isEmpty() );
237 public void testGetArtifactCanOnlyObserveInOneOfTwoRepos()
239 setObservableRepos( Arrays.asList( TEST_REPO ) );
240 metadataResolver.setProjectVersion( OTHER_TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
242 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, createProjectModel(
245 setActionParameters();
247 String result = action.artifact();
249 assertActionSuccess( action, result );
251 assertActionParameters( action );
252 ProjectVersionMetadata model = action.getModel();
253 assertDefaultModel( model );
255 assertEquals( TEST_REPO, action.getRepositoryId() );
257 assertNull( action.getDependees() );
258 assertNull( action.getDependencies() );
259 assertNull( action.getMailingLists() );
260 assertTrue( action.getArtifacts().isEmpty() );
263 public void testGetArtifactNoMavenFacet()
265 ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata();
266 versionMetadata.setId( TEST_VERSION );
267 versionMetadata.setUrl( TEST_URL );
268 versionMetadata.setName( TEST_NAME );
269 versionMetadata.setDescription( TEST_DESCRIPTION );
271 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
273 setActionParameters();
275 String result = action.artifact();
277 assertActionSuccess( action, result );
279 assertActionParameters( action );
280 ProjectVersionMetadata model = action.getModel();
281 assertEquals( TEST_VERSION, model.getVersion() );
282 assertEquals( TEST_URL, model.getUrl() );
283 assertEquals( TEST_NAME, model.getName() );
284 assertEquals( TEST_DESCRIPTION, model.getDescription() );
286 assertEquals( TEST_REPO, action.getRepositoryId() );
288 assertNull( action.getDependees() );
289 assertNull( action.getDependencies() );
290 assertNull( action.getMailingLists() );
291 assertTrue( action.getArtifacts().isEmpty() );
294 public void testGetMailingLists()
296 ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
297 MailingList ml1 = createMailingList( "Users List", "users" );
298 MailingList ml2 = createMailingList( "Developers List", "dev" );
299 versionMetadata.setMailingLists( Arrays.asList( ml1, ml2 ) );
300 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
302 setActionParameters();
304 String result = action.mailingLists();
306 assertActionSuccess( action, result );
308 assertActionParameters( action );
309 ProjectVersionMetadata model = action.getModel();
310 assertDefaultModel( model );
312 assertNotNull( action.getMailingLists() );
313 assertMailingList( action.getMailingLists().get( 0 ), "Users List", "users" );
314 assertMailingList( action.getMailingLists().get( 1 ), "Developers List", "dev" );
316 assertEquals( TEST_REPO, action.getRepositoryId() );
317 assertNull( action.getDependees() );
318 assertNull( action.getDependencies() );
319 assertTrue( action.getArtifacts().isEmpty() );
322 public void testGetDependencies()
324 ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
325 Dependency dependency1 = createDependencyBasic( "artifactId1" );
326 Dependency dependency2 = createDependencyExtended( "artifactId2" );
327 versionMetadata.setDependencies( Arrays.asList( dependency1, dependency2 ) );
328 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
330 setActionParameters();
332 String result = action.dependencies();
334 assertActionSuccess( action, result );
336 assertActionParameters( action );
337 ProjectVersionMetadata model = action.getModel();
338 assertDefaultModel( model );
340 assertNotNull( action.getDependencies() );
341 assertDependencyBasic( action.getDependencies().get( 0 ), "artifactId1" );
342 assertDependencyExtended( action.getDependencies().get( 1 ), "artifactId2" );
344 assertEquals( TEST_REPO, action.getRepositoryId() );
345 assertNull( action.getDependees() );
346 assertNull( action.getMailingLists() );
347 assertTrue( action.getArtifacts().isEmpty() );
350 public void testGetDependees()
353 ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
354 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
355 ProjectVersionReference dependee1 = createReference( "artifactId1" );
356 ProjectVersionReference dependee2 = createReference( "artifactId2" );
357 metadataResolver.setProjectReferences( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION, Arrays.asList(
358 dependee1, dependee2 ) );
360 setActionParameters();
362 String result = action.dependees();
364 assertActionSuccess( action, result );
366 assertActionParameters( action );
367 ProjectVersionMetadata model = action.getModel();
368 assertDefaultModel( model );
370 assertNotNull( action.getDependees() );
371 assertCoordinate( action.getDependees().get( 0 ), "artifactId1" );
372 assertCoordinate( action.getDependees().get( 1 ), "artifactId2" );
374 assertEquals( TEST_REPO, action.getRepositoryId() );
375 assertNull( action.getDependencies() );
376 assertNull( action.getMailingLists() );
377 assertTrue( action.getArtifacts().isEmpty() );
380 public void testGetProjectMetadata()
382 ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
384 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
386 setActionParameters();
388 String result = action.projectMetadata();
390 assertActionSuccess( action, result );
392 assertActionParameters( action );
394 Map<String, String> genericMetadata = action.getGenericMetadata();
395 assertNotNull( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ) );
396 assertEquals( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ),
397 TEST_GENERIC_METADATA_PROPERTY_VALUE );
399 assertEquals( TEST_REPO, action.getRepositoryId() );
400 assertNotNull( action.getModel() );
401 assertNull( action.getDependees() );
402 assertNull( action.getDependencies() );
403 assertNull( action.getMailingLists() );
404 assertTrue( action.getArtifacts().isEmpty() );
407 public void testAddAndDeleteMetadataProperty()
409 ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
411 metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
413 setActionParameters();
414 action.setPropertyName( "foo" );
415 action.setPropertyValue( "bar" );
416 action.setRepositoryId( TEST_REPO );
418 String result = action.addMetadataProperty();
420 assertActionSuccess( action, result );
421 assertActionParameters( action );
423 Map<String, String> genericMetadata = action.getGenericMetadata();
424 assertNotNull( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ) );
425 assertEquals( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ),
426 TEST_GENERIC_METADATA_PROPERTY_VALUE );
428 assertNotNull( genericMetadata.get( "foo" ) );
429 assertEquals( "bar", genericMetadata.get( "foo" ) );
431 assertEquals( TEST_REPO, action.getRepositoryId() );
432 assertNotNull( action.getModel() );
433 assertNull( action.getDependees() );
434 assertNull( action.getDependencies() );
435 assertNull( action.getMailingLists() );
436 assertTrue( action.getArtifacts().isEmpty() );
438 // test delete property
439 setActionParameters();
440 action.setDeleteItem( "foo" );
442 result = action.deleteMetadataEntry();
444 assertEquals( Action.SUCCESS, result );
445 assertActionParameters( action );
446 assertTrue( !action.getActionMessages().isEmpty() );
447 assertTrue( action.getActionMessages().contains( "Property successfully deleted." ) );
449 genericMetadata = action.getGenericMetadata();
450 assertNotNull( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ) );
451 assertEquals( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ),
452 TEST_GENERIC_METADATA_PROPERTY_VALUE );
454 assertNull( genericMetadata.get( "foo" ) );
456 assertEquals( TEST_REPO, action.getRepositoryId() );
457 assertNotNull( action.getModel() );
458 assertNull( action.getDependees() );
459 assertNull( action.getDependencies() );
460 assertNull( action.getMailingLists() );
461 assertTrue( action.getArtifacts().isEmpty() );
464 private void assertArtifacts( List<ArtifactMetadata> expectedArtifacts,
465 Map<String, List<ShowArtifactAction.ArtifactDownloadInfo>> artifactMap )
467 // assuming only one of each version at this point
468 assertEquals( expectedArtifacts.size(), artifactMap.size() );
469 for ( ArtifactMetadata artifact : expectedArtifacts )
471 assertTrue( artifactMap.containsKey( artifact.getVersion() ) );
472 List<ShowArtifactAction.ArtifactDownloadInfo> list = artifactMap.get( artifact.getVersion() );
473 ShowArtifactAction.ArtifactDownloadInfo actual = list.get( 0 );
474 assertEquals( artifact.getNamespace(), actual.getNamespace() );
475 assertEquals( artifact.getId(), actual.getId() );
476 assertEquals( artifact.getProject(), actual.getProject() );
477 assertEquals( artifact.getRepositoryId(), actual.getRepositoryId() );
478 assertEquals( artifact.getVersion(), actual.getVersion() );
479 assertEquals( TEST_TYPE, actual.getType() );
480 assertEquals( "12.06 K", actual.getSize() );
481 assertEquals( artifact.getNamespace() + "/" + artifact.getProject() + "/" + TEST_SNAPSHOT_VERSION + "/" +
482 artifact.getId(), actual.getPath() );
486 private static ArtifactMetadata createArtifact( String version )
488 return createArtifact( version, null, 0 );
491 private static ArtifactMetadata createArtifact( String version, String timestamp, int buildNumber )
493 ArtifactMetadata metadata = new ArtifactMetadata();
494 metadata.setProject( TEST_ARTIFACT_ID );
495 metadata.setId( TEST_ARTIFACT_ID + "-" + version + ".jar" );
496 metadata.setNamespace( TEST_GROUP_ID );
497 metadata.setRepositoryId( TEST_REPO );
498 metadata.setSize( TEST_SIZE );
499 metadata.setProjectVersion( VersionUtil.getBaseVersion( version ) );
500 metadata.setVersion( version );
502 MavenArtifactFacet facet = new MavenArtifactFacet();
503 facet.setType( "jar" );
504 facet.setTimestamp( timestamp );
505 facet.setBuildNumber( buildNumber );
506 metadata.addFacet( facet );
511 private ProjectVersionReference createReference( String projectId )
513 ProjectVersionReference reference = new ProjectVersionReference();
514 reference.setNamespace( "groupId" );
515 reference.setProjectId( projectId );
516 reference.setProjectVersion( "version" );
517 reference.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY );
521 private void assertCoordinate( ProjectVersionReference dependee, String artifactId )
523 assertEquals( artifactId, dependee.getProjectId() );
524 assertEquals( "groupId", dependee.getNamespace() );
525 assertEquals( "version", dependee.getProjectVersion() );
528 private void assertDependencyBasic( Dependency dependency, String artifactId )
530 assertEquals( artifactId, dependency.getArtifactId() );
531 assertEquals( "groupId", dependency.getGroupId() );
532 assertEquals( "version", dependency.getVersion() );
535 private void assertDependencyExtended( Dependency dependency, String artifactId )
537 assertDependencyBasic( dependency, artifactId );
538 assertEquals( true, dependency.isOptional() );
539 assertEquals( "classifier", dependency.getClassifier() );
540 assertEquals( "type", dependency.getType() );
541 assertEquals( "scope", dependency.getScope() );
542 assertEquals( "systemPath", dependency.getSystemPath() );
545 private Dependency createDependencyExtended( String artifactId )
547 Dependency dependency = createDependencyBasic( artifactId );
548 dependency.setClassifier( "classifier" );
549 dependency.setOptional( true );
550 dependency.setScope( "scope" );
551 dependency.setSystemPath( "systemPath" );
552 dependency.setType( "type" );
556 private Dependency createDependencyBasic( String artifactId )
558 Dependency dependency = new Dependency();
559 dependency.setArtifactId( artifactId );
560 dependency.setGroupId( "groupId" );
561 dependency.setVersion( "version" );
565 private void assertMailingList( MailingList mailingList, String name, String prefix )
567 assertEquals( name, mailingList.getName() );
568 assertEquals( prefix + "-post@", mailingList.getPostAddress() );
569 assertEquals( prefix + "-subscribe@", mailingList.getSubscribeAddress() );
570 assertEquals( prefix + "-unsubscribe@", mailingList.getUnsubscribeAddress() );
571 assertEquals( prefix + "-archive-url", mailingList.getMainArchiveUrl() );
572 assertEquals( Arrays.asList( "other-" + prefix + "-archive-url-1", "other-" + prefix + "-archive-url-2" ),
573 mailingList.getOtherArchives() );
576 private MailingList createMailingList( String name, String prefix )
578 MailingList ml1 = new MailingList();
580 ml1.setPostAddress( prefix + "-post@" );
581 ml1.setSubscribeAddress( prefix + "-subscribe@" );
582 ml1.setUnsubscribeAddress( prefix + "-unsubscribe@" );
583 ml1.setMainArchiveUrl( prefix + "-archive-url" );
584 ml1.setOtherArchives( Arrays.asList( "other-" + prefix + "-archive-url-1",
585 "other-" + prefix + "-archive-url-2" ) );
589 private void assertNoOutputFields()
591 assertNull( action.getModel() );
592 assertNull( action.getDependees() );
593 assertNull( action.getDependencies() );
594 assertNull( action.getMailingLists() );
595 assertTrue( action.getArtifacts().isEmpty() );
598 private void assertError( String result )
600 assertEquals( Action.ERROR, result );
601 assertEquals( 1, action.getActionErrors().size() );
604 private void assertDefaultModel( ProjectVersionMetadata model )
606 assertDefaultModel( model, TEST_VERSION );
609 private void setActionParameters()
611 action.setGroupId( TEST_GROUP_ID );
612 action.setArtifactId( TEST_ARTIFACT_ID );
613 action.setVersion( TEST_VERSION );
616 private void assertActionParameters( ShowArtifactAction action )
618 assertEquals( TEST_GROUP_ID, action.getGroupId() );
619 assertEquals( TEST_ARTIFACT_ID, action.getArtifactId() );
620 assertEquals( TEST_VERSION, action.getVersion() );
623 private void assertActionSuccess( ShowArtifactAction action, String result )
625 assertEquals( Action.SUCCESS, result );
626 assertTrue( action.getActionErrors().isEmpty() );
627 assertTrue( action.getActionMessages().isEmpty() );
630 protected void setUp()
634 action = (ShowArtifactAction) getActionProxy( "/showArtifact.action" ).getAction();
636 metadataResolver = new TestMetadataResolver();
637 MetadataRepository repo = mock( MetadataRepository.class );
638 RepositorySession repositorySession = mock( RepositorySession.class );
639 when( repositorySession.getResolver() ).thenReturn( metadataResolver );
640 when( repositorySession.getRepository() ).thenReturn( repo );
641 //TestRepositorySessionFactory repositorySessionFactory = (TestRepositorySessionFactory) lookup(
642 // RepositorySessionFactory.class );
643 TestRepositorySessionFactory repositorySessionFactory = new TestRepositorySessionFactory();
644 repositorySessionFactory.setRepositorySession( repositorySession );
646 RepositoryContentFactory factory = mock( RepositoryContentFactory.class );
647 action.setRepositoryFactory( factory );
649 ManagedRepositoryConfiguration config = new ManagedRepositoryConfiguration();
650 config.setId( TEST_REPO );
651 config.setLocation( new File( "target/test-repo" ).getAbsolutePath() );
653 ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
654 content.setRepository( config );
655 when( factory.getManagedRepositoryContent( TEST_REPO ) ).thenReturn( content );
657 ArchivaConfiguration archivaConfig = mock( ArchivaConfiguration.class );
659 Configuration configuration = new Configuration();
660 configuration.addManagedRepository( config );
661 when( archivaConfig.getConfiguration() ).thenReturn( configuration );