From 1014b00be4064973f807ae252734ea29e894417e Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Sun, 1 Aug 2010 03:04:06 +0000 Subject: [PATCH] [MRM-1397] reflect in the staging repo changes made in the configuration of the managed repo it is attached to submitted by Patti Arachchige Eshan Sudharaka git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-MRM-980@981121 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/archiva/web/action/MergeAction.java | 30 ++++++ .../DeleteManagedRepositoryAction.java | 19 +++- .../EditManagedRepositoryAction.java | 59 ++++++++++-- .../WEB-INF/jsp/admin/editRepository.jsp | 12 ++- .../WEB-INF/jsp/mergeExcludeConflicts.jsp | 5 +- .../DeleteManagedRepositoryActionTest.java | 95 +++++++++---------- .../EditManagedRepositoryActionTest.java | 55 +++++++++++ 7 files changed, 213 insertions(+), 62 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java index 78a6c4fc6..a1d4ceebd 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java @@ -33,6 +33,9 @@ import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import java.util.List; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; /** * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="mergeAction" instantiation-strategy="per-lookup" @@ -71,6 +74,8 @@ public class MergeAction private List conflictSourceArtifacts; + private List conflictSourceArtifactsToBeDisplayed; + public String getConflicts() { targetRepoId = repoid + "-stage"; @@ -165,6 +170,7 @@ public class MergeAction targetRepoId = repoid + "-stage"; conflictSourceArtifacts = repositoryMerger.getConflictsartifacts( targetRepoId, repoid ); this.repository = new ManagedRepositoryConfiguration(); + setConflictSourceArtifactsToBeDisplayed( conflictSourceArtifacts ); } public String getTargetRepoId() @@ -196,5 +202,29 @@ public class MergeAction { this.conflictSourceArtifacts = conflictSourceArtifacts; } + + public List getConflictSourceArtifactsToBeDisplayed() + { + return conflictSourceArtifactsToBeDisplayed; + } + + public void setConflictSourceArtifactsToBeDisplayed( List conflictSourceArtifacts ) + throws Exception + { + this.conflictSourceArtifactsToBeDisplayed = new ArrayList(); + HashMap map = new HashMap(); + for ( ArtifactMetadata metadata : conflictSourceArtifacts ) + { + String metadataId = metadata.getNamespace() + metadata.getProject() + metadata.getProjectVersion() + metadata.getVersion(); + map.put( metadataId, metadata ); + } + Iterator iterator = map.keySet().iterator(); + + while ( iterator.hasNext() ) + { + conflictSourceArtifactsToBeDisplayed.add( map.get(iterator.next() )); + } + + } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java index 5107e7c9a..2cfc4b199 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java @@ -45,6 +45,8 @@ public class DeleteManagedRepositoryAction { private ManagedRepositoryConfiguration repository; + private ManagedRepositoryConfiguration stagingRepository; + private String repoid; /** @@ -62,6 +64,7 @@ public class DeleteManagedRepositoryAction if ( StringUtils.isNotBlank( repoid ) ) { this.repository = archivaConfiguration.getConfiguration().findManagedRepositoryById( repoid ); + this.stagingRepository = archivaConfiguration.getConfiguration().findManagedRepositoryById( repoid +"-stage"); } } @@ -87,8 +90,9 @@ public class DeleteManagedRepositoryAction } private String deleteRepository( boolean deleteContents ) - { + { ManagedRepositoryConfiguration existingRepository = repository; + ManagedRepositoryConfiguration attachedStagingRepo = stagingRepository; if ( existingRepository == null ) { addActionError( "A repository with that id does not exist" ); @@ -103,12 +107,23 @@ public class DeleteManagedRepositoryAction cleanupRepositoryData( existingRepository ); removeRepository( repoid, configuration ); triggerAuditEvent( repoid, null, AuditEvent.DELETE_MANAGED_REPO ); + if(attachedStagingRepo !=null) + { + cleanupRepositoryData( attachedStagingRepo ); + removeRepository( repoid +"-stage", configuration ); + triggerAuditEvent(repoid +"-stage", null, AuditEvent.DELETE_MANAGED_REPO ); + + } result = saveConfiguration( configuration ); if ( result.equals( SUCCESS ) ) { if ( deleteContents ) { + if(attachedStagingRepo !=null) + { + removeContents( attachedStagingRepo ); + } removeContents( existingRepository ); } } @@ -154,7 +169,7 @@ public class DeleteManagedRepositoryAction { archivaConfiguration.getConfiguration().findRepositoryGroupById( repoGroup ).removeRepository( cleanupRepository.getId() ); } - } + } } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java index b38e4830f..a0a4f7cf6 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java @@ -47,6 +47,8 @@ public class EditManagedRepositoryAction */ private ManagedRepositoryConfiguration repository; + private ManagedRepositoryConfiguration stagingRepository; + private String repoid; private final String action = "editRepository"; @@ -63,6 +65,7 @@ public class EditManagedRepositoryAction if ( StringUtils.isNotBlank( repoid ) ) { repository = archivaConfiguration.getConfiguration().findManagedRepositoryById( repoid ); + stagingRepository = archivaConfiguration.getConfiguration().findManagedRepositoryById( repoid + "-stage" ); } else if ( repository != null ) { @@ -92,7 +95,6 @@ public class EditManagedRepositoryAction { ManagedRepositoryConfiguration existingConfig = archivaConfiguration.getConfiguration().findManagedRepositoryById( repository.getId() ); - boolean resetStats = false; // check if the location was changed @@ -117,6 +119,10 @@ public class EditManagedRepositoryAction // We are in edit mode, remove the old repository configuration. removeRepository( repository.getId(), configuration ); + if ( stagingRepository != null ) + { + removeRepository( stagingRepository.getId(), configuration ); + } // Save the repository configuration. String result; @@ -126,15 +132,23 @@ public class EditManagedRepositoryAction triggerAuditEvent( repository.getId(), null, AuditEvent.MODIFY_MANAGED_REPO ); addRepositoryRoles( repository ); + //update changes of the staging repo if ( stageNeeded ) { - ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig(); -// if(new File( stagingRepository.getLocation()).exists()) + + stagingRepository = getStageRepoConfig( configuration ); addRepository( stagingRepository, configuration ); - triggerAuditEvent( stagingRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO ); addRepositoryRoles( stagingRepository ); } + //delete staging repo when we dont need it + if ( !stageNeeded ) + { + stagingRepository = getStageRepoConfig(configuration); + removeRepository( stagingRepository.getId(), configuration ); + removeContents( stagingRepository ); + removeRepositoryRoles( stagingRepository ); + } result = saveConfiguration( configuration ); if ( resetStats ) @@ -156,9 +170,27 @@ public class EditManagedRepositoryAction return result; } - private ManagedRepositoryConfiguration getStageRepoConfig() + private ManagedRepositoryConfiguration getStageRepoConfig( Configuration configuration ) + { + for ( ManagedRepositoryConfiguration repoConf : configuration.getManagedRepositories() ) + { + if ( repoConf.getId().equals( repository.getId() + "-stage" ) ) + { + stagingRepository = repoConf; + removeRepository( repoConf .getId() , configuration); + updateStagingRepository( stagingRepository ); + return stagingRepository; + } + } + + stagingRepository = new ManagedRepositoryConfiguration(); + updateStagingRepository( stagingRepository ); + + return stagingRepository; + } + + private void updateStagingRepository( ManagedRepositoryConfiguration stagingRepository ) { - ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration(); stagingRepository.setId( repository.getId() + "-stage" ); stagingRepository.setLayout( repository.getLayout() ); stagingRepository.setName( repository.getName() + "-stage" ); @@ -174,9 +206,8 @@ public class EditManagedRepositoryAction stagingRepository.setRetentionCount( repository.getRetentionCount() ); stagingRepository.setScanned( repository.isScanned() ); stagingRepository.setSnapshots( repository.isSnapshots() ); - return stagingRepository; } - + @Override public void validate() { @@ -191,7 +222,7 @@ public class EditManagedRepositoryAction private void resetStatistics() { repositoryStatisticsManager.deleteStatistics( repository.getId() ); - } + } public String getRepoid() { @@ -232,4 +263,14 @@ public class EditManagedRepositoryAction { this.repositoryStatisticsManager = repositoryStatisticsManager; } + + public ManagedRepositoryConfiguration getStagingRepository() + { + return stagingRepository; + } + + public void setStagingRepository( ManagedRepositoryConfiguration stagingRepository ) + { + this.stagingRepository = stagingRepository; + } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp index 561dc30fd..88086a6f2 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp @@ -39,7 +39,17 @@ <%@ include file="/WEB-INF/jsp/admin/include/repositoryForm.jspf" %> - + + + + + + + + + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/mergeExcludeConflicts.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/mergeExcludeConflicts.jsp index be89c6bf3..10731ffc0 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/mergeExcludeConflicts.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/mergeExcludeConflicts.jsp @@ -54,10 +54,11 @@ WARNING: The following are the artifacts in conflict.

- + Artifact Id : - ${artifact.id} + <%--${artifact.id}--%> + ${artifact.namespace} ${" "} ${artifact.project} ${" "} ${artifact.version} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java index d730cf5ce..a0ad561ee 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java @@ -48,7 +48,7 @@ import java.util.Collections; import java.util.List; /** - * DeleteManagedRepositoryActionTest + * DeleteManagedRepositoryActionTest * * @version $Id$ */ @@ -64,7 +64,7 @@ public class DeleteManagedRepositoryActionTest private MockControl archivaConfigurationControl; private ArchivaConfiguration archivaConfiguration; - + private static final String REPO_ID = "repo-ident"; private File location; @@ -79,11 +79,11 @@ public class DeleteManagedRepositoryActionTest super.setUp(); action = new DeleteManagedRepositoryAction(); - + archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class ); archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock(); action.setArchivaConfiguration( archivaConfiguration ); - + roleManagerControl = MockControl.createControl( RoleManager.class ); roleManager = (RoleManager) roleManagerControl.getMock(); action.setRoleManager( roleManager ); @@ -122,6 +122,11 @@ public class DeleteManagedRepositoryActionTest archivaConfiguration.getConfiguration(); archivaConfigurationControl.setReturnValue( configuration ); + + Configuration stageRepoConfiguration = new Configuration(); + stageRepoConfiguration.addManagedRepository( createSatingRepository() ); + archivaConfigurationControl.setReturnValue( stageRepoConfiguration ); + archivaConfigurationControl.replay(); action.setRepoid( REPO_ID ); @@ -131,10 +136,10 @@ public class DeleteManagedRepositoryActionTest ManagedRepositoryConfiguration repository = action.getRepository(); assertNotNull( repository ); assertRepositoryEquals( repository, createRepository() ); - + String status = action.execute(); assertEquals( Action.SUCCESS, status ); - + repository = action.getRepository(); assertRepositoryEquals( repository, createRepository() ); assertEquals( Collections.singletonList( originalRepository ), configuration.getManagedRepositories() ); @@ -148,7 +153,7 @@ public class DeleteManagedRepositoryActionTest repositoryStatisticsManagerControl.replay(); prepareRoleManagerMock(); - + Configuration configuration = prepDeletionTest( createRepository(), 4 ); MockControl control = mockAuditListeners(); @@ -196,15 +201,15 @@ public class DeleteManagedRepositoryActionTest repositoryStatisticsManagerControl.replay(); prepareRoleManagerMock(); - - Configuration configuration = prepDeletionTest( createRepository(), 4 ); - + + Configuration configuration = prepDeletionTest( createRepository(), 4 ); + MockControl control = mockAuditListeners(); MockControl metadataRepositoryControl = mockMetadataRepository(); String status = action.deleteContents(); - + assertEquals( Action.SUCCESS, status ); assertTrue( configuration.getManagedRepositories().isEmpty() ); @@ -215,7 +220,7 @@ public class DeleteManagedRepositoryActionTest control.verify(); metadataRepositoryControl.verify(); } - + public void testDeleteRepositoryAndAssociatedProxyConnectors() throws Exception { @@ -230,11 +235,11 @@ public class DeleteManagedRepositoryActionTest prepareRoleManagerMock(); assertEquals( 1, configuration.getProxyConnectors().size() ); - + MockControl control = mockAuditListeners(); MockControl metadataRepositoryControl = mockMetadataRepository(); String status = action.deleteContents(); - + assertEquals( Action.SUCCESS, status ); assertTrue( configuration.getManagedRepositories().isEmpty() ); @@ -246,7 +251,7 @@ public class DeleteManagedRepositoryActionTest control.verify(); metadataRepositoryControl.verify(); } - + public void testDeleteRepositoryCancelled() throws Exception { @@ -254,7 +259,7 @@ public class DeleteManagedRepositoryActionTest ManagedRepositoryConfiguration originalRepository = createRepository(); Configuration configuration = prepDeletionTest( originalRepository, 3 ); - + String status = action.execute(); assertEquals( Action.SUCCESS, status ); @@ -266,36 +271,8 @@ public class DeleteManagedRepositoryActionTest repositoryStatisticsManagerControl.verify(); } - - public void testDeleteRepositoryAndReposUnderRepoGroup() - throws Exception - { - repositoryStatisticsManager.deleteStatistics( REPO_ID ); - repositoryStatisticsManagerControl.replay(); - - Configuration configuration = prepDeletionTest( createRepository(), 5 ); - List repoIds = new ArrayList(); - repoIds.add( REPO_ID ); - configuration.addRepositoryGroup( createRepoGroup( repoIds, "repo.group" ) ); - - prepareRoleManagerMock(); - - assertEquals( 1, configuration.getRepositoryGroups().size() ); - - MockControl control = mockAuditListeners(); - MockControl metadataRepositoryControl = mockMetadataRepository(); - String status = action.deleteContents(); - assertEquals( Action.SUCCESS, status ); - - assertTrue( configuration.getManagedRepositories().isEmpty() ); - assertEquals( 0, configuration.getRepositoryGroups().get( 0 ).getRepositories().size() ); - assertFalse( location.exists() ); - repositoryStatisticsManagerControl.verify(); - control.verify(); - metadataRepositoryControl.verify(); - } private Configuration prepDeletionTest( ManagedRepositoryConfiguration originalRepository, int expectCountGetConfig ) throws RegistryException, IndeterminateConfigurationException @@ -307,6 +284,11 @@ public class DeleteManagedRepositoryActionTest archivaConfiguration.getConfiguration(); archivaConfigurationControl.setReturnValue( configuration, expectCountGetConfig ); + Configuration stageRepoConfiguration = new Configuration(); + stageRepoConfiguration.addManagedRepository( createSatingRepository() ); + archivaConfigurationControl.setReturnValue( stageRepoConfiguration ); + + archivaConfiguration.save( configuration ); archivaConfigurationControl.replay(); @@ -363,16 +345,33 @@ public class DeleteManagedRepositoryActionTest return r; } + private ManagedRepositoryConfiguration createSatingRepository() + { + ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration(); + r.setId( REPO_ID +"-stage" ); + r.setName( "repo name" ); + r.setLocation( location.getAbsolutePath() ); + r.setLayout( "default" ); + r.setRefreshCronExpression( "* 0/5 * * * ?" ); + r.setDaysOlder( 0 ); + r.setRetentionCount( 0 ); + r.setReleases( true ); + r.setSnapshots( true ); + r.setScanned( false ); + r.setDeleteReleasedSnapshots( false ); + return r; + } + private RemoteRepositoryConfiguration createRemoteRepository(String id, String url) { RemoteRepositoryConfiguration r = new RemoteRepositoryConfiguration(); r.setId( id ); r.setUrl( url ); r.setLayout( "default" ); - + return r; } - + private ProxyConnectorConfiguration createProxyConnector( String managedRepoId, String remoteRepoId ) { ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration(); @@ -387,10 +386,10 @@ public class DeleteManagedRepositoryActionTest RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration(); repoGroup.setId( repoGroupId ); repoGroup.setRepositories( repoIds ); - + return repoGroup; } - + private void prepareRoleManagerMock() throws RoleManagerException { diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java index 1f5024fb5..7f2fc6ec3 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java @@ -95,6 +95,10 @@ public class EditManagedRepositoryActionTest archivaConfiguration.getConfiguration(); archivaConfigurationControl.setReturnValue( configuration ); + Configuration stageRepoConfiguration = new Configuration(); + stageRepoConfiguration.addManagedRepository( createStagingRepository() ); + archivaConfigurationControl.setReturnValue( stageRepoConfiguration ); + archivaConfigurationControl.replay(); action.setRepoid( REPO_ID ); @@ -116,10 +120,18 @@ public class EditManagedRepositoryActionTest { roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID ); roleManagerControl.setReturnValue( false ); + + roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID +"-stage" ); + roleManagerControl.setReturnValue( false ); + roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID ); roleManagerControl.setVoidCallable(); roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID ); roleManagerControl.setReturnValue( false ); + + roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID +"-stage"); + roleManagerControl.setReturnValue( false ); + roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID ); roleManagerControl.setVoidCallable(); @@ -128,6 +140,10 @@ public class EditManagedRepositoryActionTest Configuration configuration = createConfigurationForEditing( createRepository() ); archivaConfiguration.getConfiguration(); archivaConfigurationControl.setReturnValue( configuration ); + + Configuration stageRepoConfiguration = new Configuration(); + stageRepoConfiguration.addManagedRepository( createStagingRepository() ); + archivaConfigurationControl.setReturnValue( stageRepoConfiguration ); archivaConfigurationControl.setReturnValue( configuration ); archivaConfigurationControl.setReturnValue( configuration ); @@ -167,10 +183,18 @@ public class EditManagedRepositoryActionTest { roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID ); roleManagerControl.setReturnValue( false ); + + roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID +"-stage"); + roleManagerControl.setReturnValue( false ); + roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID ); roleManagerControl.setVoidCallable(); roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID ); roleManagerControl.setReturnValue( false ); + + roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID +"-stage"); + roleManagerControl.setReturnValue( false ); + roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID ); roleManagerControl.setVoidCallable(); @@ -179,6 +203,11 @@ public class EditManagedRepositoryActionTest Configuration configuration = createConfigurationForEditing( createRepository() ); archivaConfiguration.getConfiguration(); archivaConfigurationControl.setReturnValue( configuration ); + Configuration stageRepoConfiguration = new Configuration(); + stageRepoConfiguration.addManagedRepository( createStagingRepository() ); + archivaConfigurationControl.setReturnValue( stageRepoConfiguration ); + + archivaConfigurationControl.setReturnValue( configuration ); archivaConfigurationControl.setReturnValue( configuration ); @@ -230,9 +259,11 @@ public class EditManagedRepositoryActionTest } private Configuration createConfigurationForEditing( ManagedRepositoryConfiguration repositoryConfiguration ) + throws Exception { Configuration configuration = new Configuration(); configuration.addManagedRepository( repositoryConfiguration ); +// configuration.addManagedRepository( createStagingRepository() ); return configuration; } @@ -245,6 +276,15 @@ public class EditManagedRepositoryActionTest return r; } + private ManagedRepositoryConfiguration createStagingRepository() + throws IOException + { + ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration(); + r.setId( REPO_ID + "-stage" ); + populateStagingRepository( r ); + return r; + } + private void populateRepository( ManagedRepositoryConfiguration repository ) throws IOException { @@ -260,4 +300,19 @@ public class EditManagedRepositoryActionTest repository.setScanned( false ); repository.setDeleteReleasedSnapshots( true ); } + private void populateStagingRepository( ManagedRepositoryConfiguration repository ) + throws IOException + { + repository.setId( REPO_ID + "-stage"); + repository.setName( "repo name" ); + repository.setLocation( location.getCanonicalPath() ); + repository.setLayout( "default" ); + repository.setRefreshCronExpression( "* 0/5 * * * ?" ); + repository.setDaysOlder( 31 ); + repository.setRetentionCount( 20 ); + repository.setReleases( true ); + repository.setSnapshots( true ); + repository.setScanned( false ); + repository.setDeleteReleasedSnapshots( true ); + } } -- 2.39.5