mirror of https://github.com/apache/archiva.git
[MRM-1508] api to managed repository group : use it in webapp
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1165847 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0f4fdab10d
commit
cd252dc729
|
@ -21,6 +21,7 @@ package org.apache.archiva.admin.repository.group;
|
|||
import org.apache.archiva.admin.AuditInformation;
|
||||
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
|
||||
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
||||
import org.apache.archiva.admin.repository.managed.ManagedRepository;
|
||||
import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
|
||||
import org.apache.archiva.audit.AuditEvent;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -33,7 +34,9 @@ import org.springframework.stereotype.Service;
|
|||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -156,8 +159,8 @@ public class DefaultRepositoryGroupAdmin
|
|||
|
||||
if ( repositoryGroup.getRepositories().contains( repositoryId ) )
|
||||
{
|
||||
log.info( "repositoryGroup {} already contains repository {} so skip adding it" );
|
||||
return Boolean.TRUE;
|
||||
throw new RepositoryAdminException(
|
||||
"repositoryGroup with id " + repositoryGroupId + " already contain repository with id" + repositoryId );
|
||||
}
|
||||
validateManagedRepositoriesExists( Arrays.asList( repositoryId ) );
|
||||
|
||||
|
@ -180,8 +183,9 @@ public class DefaultRepositoryGroupAdmin
|
|||
|
||||
if ( !repositoryGroup.getRepositories().contains( repositoryId ) )
|
||||
{
|
||||
log.info( "repositoryGroup {} already contains repository {} so skip removing it" );
|
||||
return Boolean.TRUE;
|
||||
throw new RepositoryAdminException(
|
||||
"repositoryGroup with id " + repositoryGroupId + " doesn't not contains repository with id"
|
||||
+ repositoryId );
|
||||
}
|
||||
|
||||
repositoryGroup.removeRepository( repositoryId );
|
||||
|
@ -190,6 +194,65 @@ public class DefaultRepositoryGroupAdmin
|
|||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
public Map<String, RepositoryGroup> getRepositoryGroupsAsMap()
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
List<RepositoryGroup> repositoriesGroups = getRepositoriesGroups();
|
||||
Map<String, RepositoryGroup> map = new HashMap<String, RepositoryGroup>( repositoriesGroups.size() );
|
||||
for ( RepositoryGroup repositoryGroup : repositoriesGroups )
|
||||
{
|
||||
map.put( repositoryGroup.getId(), repositoryGroup );
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getGroupToRepositoryMap()
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
|
||||
java.util.Map<String, java.util.List<String>> map = new java.util.HashMap<String, java.util.List<String>>();
|
||||
|
||||
for ( ManagedRepository repo : getManagedRepositoryAdmin().getManagedRepositories() )
|
||||
{
|
||||
for ( RepositoryGroup group : getRepositoriesGroups() )
|
||||
{
|
||||
if ( !group.getRepositories().contains( repo.getId() ) )
|
||||
{
|
||||
String groupId = group.getId();
|
||||
java.util.List<String> repos = map.get( groupId );
|
||||
if ( repos == null )
|
||||
{
|
||||
repos = new java.util.ArrayList<String>();
|
||||
map.put( groupId, repos );
|
||||
}
|
||||
repos.add( repo.getId() );
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getRepositoryToGroupMap()
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
java.util.Map<String, java.util.List<String>> map = new java.util.HashMap<String, java.util.List<String>>();
|
||||
|
||||
for ( RepositoryGroup group : getRepositoriesGroups() )
|
||||
{
|
||||
for ( String repositoryId : group.getRepositories() )
|
||||
{
|
||||
java.util.List<String> groups = map.get( repositoryId );
|
||||
if ( groups == null )
|
||||
{
|
||||
groups = new java.util.ArrayList<String>();
|
||||
map.put( repositoryId, groups );
|
||||
}
|
||||
groups.add( group.getId() );
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public Boolean validateRepositoryGroup( RepositoryGroup repositoryGroup, boolean updateMode )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.archiva.admin.AuditInformation;
|
|||
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
|
@ -50,4 +51,25 @@ public interface RepositoryGroupAdmin
|
|||
Boolean deleteRepositoryFromGroup( String repositoryGroupId, String repositoryId,
|
||||
AuditInformation auditInformation )
|
||||
throws RepositoryAdminException;
|
||||
|
||||
/**
|
||||
* @return Map with key repoGroupId and value repoGroup
|
||||
* @throws RepositoryAdminException
|
||||
*/
|
||||
Map<String, RepositoryGroup> getRepositoryGroupsAsMap()
|
||||
throws RepositoryAdminException;
|
||||
|
||||
/**
|
||||
* @return Map with key repoGroupId and value List of ManagedRepositories
|
||||
* @throws RepositoryAdminException
|
||||
*/
|
||||
Map<String, List<String>> getGroupToRepositoryMap()
|
||||
throws RepositoryAdminException;
|
||||
|
||||
/**
|
||||
* @return Map with key managedRepo id and value List of repositoryGroup ids where the repo is
|
||||
* @throws RepositoryAdminException
|
||||
*/
|
||||
Map<String, List<String>> getRepositoryToGroupMap()
|
||||
throws RepositoryAdminException;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.maven.archiva.web.action.admin.repositories;
|
|||
|
||||
import com.opensymphony.xwork2.Preparable;
|
||||
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
||||
import org.apache.archiva.admin.repository.group.RepositoryGroupAdmin;
|
||||
import org.apache.archiva.admin.repository.managed.ManagedRepository;
|
||||
import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
|
||||
import org.apache.archiva.admin.repository.remote.RemoteRepository;
|
||||
|
@ -73,6 +74,9 @@ public class RepositoriesAction
|
|||
@Inject
|
||||
private RemoteRepositoryAdmin remoteRepositoryAdmin;
|
||||
|
||||
@Inject
|
||||
private RepositoryGroupAdmin repositoryGroupAdmin;
|
||||
|
||||
private List<ManagedRepository> managedRepositories;
|
||||
|
||||
private List<RemoteRepository> remoteRepositories;
|
||||
|
@ -115,7 +119,7 @@ public class RepositoriesAction
|
|||
|
||||
remoteRepositories = new ArrayList<RemoteRepository>( getRemoteRepositoryAdmin().getRemoteRepositories() );
|
||||
managedRepositories = new ArrayList<ManagedRepository>( getManagedRepositoryAdmin().getManagedRepositories() );
|
||||
repositoryToGroupMap = config.getRepositoryToGroupMap();
|
||||
repositoryToGroupMap = getRepositoryGroupAdmin().getRepositoryToGroupMap();
|
||||
|
||||
Collections.sort( managedRepositories, new RepositoryComparator() );
|
||||
Collections.sort( remoteRepositories, new RepositoryComparator() );
|
||||
|
@ -202,4 +206,24 @@ public class RepositoriesAction
|
|||
{
|
||||
this.remoteRepositoryAdmin = remoteRepositoryAdmin;
|
||||
}
|
||||
|
||||
public RepositoryGroupAdmin getRepositoryGroupAdmin()
|
||||
{
|
||||
return repositoryGroupAdmin;
|
||||
}
|
||||
|
||||
public void setRepositoryGroupAdmin( RepositoryGroupAdmin repositoryGroupAdmin )
|
||||
{
|
||||
this.repositoryGroupAdmin = repositoryGroupAdmin;
|
||||
}
|
||||
|
||||
public RepositoryStatisticsManager getRepositoryStatisticsManager()
|
||||
{
|
||||
return repositoryStatisticsManager;
|
||||
}
|
||||
|
||||
public void setRepositoryStatisticsManager( RepositoryStatisticsManager repositoryStatisticsManager )
|
||||
{
|
||||
this.repositoryStatisticsManager = repositoryStatisticsManager;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,21 +21,18 @@ package org.apache.maven.archiva.web.action.admin.repositories;
|
|||
|
||||
import com.opensymphony.xwork2.Preparable;
|
||||
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
||||
import org.apache.archiva.admin.repository.group.RepositoryGroup;
|
||||
import org.apache.archiva.admin.repository.group.RepositoryGroupAdmin;
|
||||
import org.apache.archiva.admin.repository.managed.ManagedRepository;
|
||||
import org.apache.archiva.audit.AuditEvent;
|
||||
import org.apache.archiva.web.util.ContextUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
|
||||
import org.apache.struts2.interceptor.ServletRequestAware;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
|
@ -47,9 +44,13 @@ public class RepositoryGroupsAction
|
|||
extends AbstractRepositoriesAdminAction
|
||||
implements ServletRequestAware, Preparable
|
||||
{
|
||||
private RepositoryGroupConfiguration repositoryGroup;
|
||||
|
||||
private Map<String, RepositoryGroupConfiguration> repositoryGroups;
|
||||
@Inject
|
||||
private RepositoryGroupAdmin repositoryGroupAdmin;
|
||||
|
||||
private RepositoryGroup repositoryGroup;
|
||||
|
||||
private Map<String, RepositoryGroup> repositoryGroups;
|
||||
|
||||
private Map<String, ManagedRepository> managedRepositories;
|
||||
|
||||
|
@ -74,163 +75,73 @@ public class RepositoryGroupsAction
|
|||
public void prepare()
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
Configuration config = archivaConfiguration.getConfiguration();
|
||||
|
||||
repositoryGroup = new RepositoryGroupConfiguration();
|
||||
repositoryGroups = config.getRepositoryGroupsAsMap();
|
||||
repositoryGroup = new RepositoryGroup();
|
||||
repositoryGroups = getRepositoryGroupAdmin().getRepositoryGroupsAsMap();
|
||||
managedRepositories = getManagedRepositoryAdmin().getManagedRepositoriesAsMap();
|
||||
groupToRepositoryMap = config.getGroupToRepositoryMap();
|
||||
groupToRepositoryMap = getRepositoryGroupAdmin().getGroupToRepositoryMap();
|
||||
}
|
||||
|
||||
public String addRepositoryGroup()
|
||||
{
|
||||
Configuration configuration = archivaConfiguration.getConfiguration();
|
||||
|
||||
String repoGroupId = repositoryGroup.getId();
|
||||
|
||||
if ( repoGroupId == null || "".equals( repoGroupId.trim() ) )
|
||||
try
|
||||
{
|
||||
addActionError( "Identifier field is required." );
|
||||
getRepositoryGroupAdmin().addRepositoryGroup( repositoryGroup, getAuditInformation() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
addActionError( e.getMessage() );
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if ( repoGroupId.length() > 100 )
|
||||
{
|
||||
addActionError( "Identifier [" + repoGroupId + "] is over the maximum limit of 100 characters" );
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
Matcher matcher = REPO_GROUP_ID_PATTERN.matcher( repoGroupId );
|
||||
if ( !matcher.matches() )
|
||||
{
|
||||
addActionError(
|
||||
"Invalid character(s) found in identifier. Only the following characters are allowed: alphanumeric, '.', '-' and '_'" );
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if ( StringUtils.isBlank( repoGroupId ) )
|
||||
{
|
||||
addActionError( "You must enter a repository group id." );
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if ( configuration.getRepositoryGroupsAsMap().containsKey( repoGroupId ) )
|
||||
{
|
||||
addActionError( "Unable to add new repository group with id [" + repoGroupId
|
||||
+ "], that id already exists as a repository group." );
|
||||
return ERROR;
|
||||
}
|
||||
else if ( configuration.getManagedRepositoriesAsMap().containsKey( repoGroupId ) )
|
||||
{
|
||||
addActionError( "Unable to add new repository group with id [" + repoGroupId
|
||||
+ "], that id already exists as a managed repository." );
|
||||
return ERROR;
|
||||
}
|
||||
else if ( configuration.getRemoteRepositoriesAsMap().containsKey( repoGroupId ) )
|
||||
{
|
||||
addActionError( "Unable to add new repository group with id [" + repoGroupId
|
||||
+ "], that id already exists as a remote repository." );
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
configuration.addRepositoryGroup( repositoryGroup );
|
||||
triggerAuditEvent( AuditEvent.ADD_REPO_GROUP + " " + repoGroupId );
|
||||
return saveConfiguration( configuration );
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String addRepositoryToGroup()
|
||||
{
|
||||
Configuration config = archivaConfiguration.getConfiguration();
|
||||
RepositoryGroupConfiguration group = config.findRepositoryGroupById( repoGroupId );
|
||||
|
||||
validateRepository();
|
||||
|
||||
if ( hasErrors() )
|
||||
try
|
||||
{
|
||||
getRepositoryGroupAdmin().addRepositoryToGroup( repoGroupId, repoId, getAuditInformation() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
addActionError( e.getMessage() );
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if ( group.getRepositories().contains( repoId ) )
|
||||
{
|
||||
addActionError( "Repository with id [" + repoId + "] is already in the group" );
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
// remove the old repository group configuration
|
||||
config.removeRepositoryGroup( group );
|
||||
|
||||
// save repository group configuration
|
||||
group.addRepository( repoId );
|
||||
config.addRepositoryGroup( group );
|
||||
|
||||
triggerAuditEvent( repoId, null, AuditEvent.ADD_REPO_TO_GROUP + " " + repoGroupId );
|
||||
|
||||
return saveConfiguration( config );
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String removeRepositoryFromGroup()
|
||||
{
|
||||
Configuration config = archivaConfiguration.getConfiguration();
|
||||
RepositoryGroupConfiguration group = config.findRepositoryGroupById( repoGroupId );
|
||||
|
||||
validateRepository();
|
||||
|
||||
if ( hasErrors() )
|
||||
try
|
||||
{
|
||||
getRepositoryGroupAdmin().deleteRepositoryFromGroup( repoGroupId, repoId, getAuditInformation() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
addActionError( e.getMessage() );
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if ( !group.getRepositories().contains( repoId ) )
|
||||
{
|
||||
addActionError( "No repository with id[" + repoId + "] found in the group" );
|
||||
return ERROR;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// remove the old repository group configuration
|
||||
config.removeRepositoryGroup( group );
|
||||
|
||||
// save repository group configuration
|
||||
group.removeRepository( repoId );
|
||||
config.addRepositoryGroup( group );
|
||||
|
||||
triggerAuditEvent( repoId, null, AuditEvent.DELETE_REPO_FROM_GROUP + " " + repoGroupId );
|
||||
|
||||
return saveConfiguration( config );
|
||||
}
|
||||
|
||||
public void validateRepository()
|
||||
{
|
||||
Configuration config = archivaConfiguration.getConfiguration();
|
||||
RepositoryGroupConfiguration group = config.findRepositoryGroupById( repoGroupId );
|
||||
ManagedRepositoryConfiguration repo = config.findManagedRepositoryById( repoId );
|
||||
|
||||
if ( group == null )
|
||||
{
|
||||
addActionError( "A repository group with that id does not exist." );
|
||||
}
|
||||
|
||||
if ( repo == null )
|
||||
{
|
||||
addActionError( "A repository with that id does not exist." );
|
||||
}
|
||||
}
|
||||
|
||||
public RepositoryGroupConfiguration getRepositoryGroup()
|
||||
public RepositoryGroup getRepositoryGroup()
|
||||
{
|
||||
return repositoryGroup;
|
||||
}
|
||||
|
||||
public void setRepositoryGroup( RepositoryGroupConfiguration repositoryGroup )
|
||||
public void setRepositoryGroup( RepositoryGroup repositoryGroup )
|
||||
{
|
||||
this.repositoryGroup = repositoryGroup;
|
||||
}
|
||||
|
||||
public Map<String, RepositoryGroupConfiguration> getRepositoryGroups()
|
||||
public Map<String, RepositoryGroup> getRepositoryGroups()
|
||||
{
|
||||
return repositoryGroups;
|
||||
}
|
||||
|
||||
public void setRepositoryGroups( Map<String, RepositoryGroupConfiguration> repositoryGroups )
|
||||
public void setRepositoryGroups( Map<String, RepositoryGroup> repositoryGroups )
|
||||
{
|
||||
this.repositoryGroups = repositoryGroups;
|
||||
}
|
||||
|
@ -269,4 +180,14 @@ public class RepositoryGroupsAction
|
|||
{
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public RepositoryGroupAdmin getRepositoryGroupAdmin()
|
||||
{
|
||||
return repositoryGroupAdmin;
|
||||
}
|
||||
|
||||
public void setRepositoryGroupAdmin( RepositoryGroupAdmin repositoryGroupAdmin )
|
||||
{
|
||||
this.repositoryGroupAdmin = repositoryGroupAdmin;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.apache.maven.archiva.web.action.admin.repositories;
|
|||
import com.meterware.servletunit.ServletRunner;
|
||||
import com.meterware.servletunit.ServletUnitClient;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
|
||||
import org.apache.archiva.metadata.repository.MetadataRepository;
|
||||
import org.apache.archiva.metadata.repository.RepositorySession;
|
||||
import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
|
||||
|
@ -48,8 +49,6 @@ public class RepositoriesActionTest
|
|||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
//action = (RepositoriesAction) lookup( Action.class.getName(), "repositoriesAction" );
|
||||
action = (RepositoriesAction) getActionProxy( "/admin/index.action" ).getAction();
|
||||
|
||||
}
|
||||
|
@ -87,6 +86,7 @@ public class RepositoriesActionTest
|
|||
ServletUnitClient sc = sr.newClient();
|
||||
|
||||
action.setServletRequest( sc.newInvocation( "http://localhost/admin/repositories.action" ).getRequest() );
|
||||
|
||||
action.prepare();
|
||||
String result = action.execute();
|
||||
assertEquals( Action.SUCCESS, result );
|
||||
|
|
|
@ -23,6 +23,9 @@ import com.meterware.servletunit.ServletRunner;
|
|||
import com.meterware.servletunit.ServletUnitClient;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
||||
import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin;
|
||||
import org.apache.archiva.admin.repository.group.RepositoryGroup;
|
||||
import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
|
@ -63,13 +66,17 @@ public class RepositoryGroupsActionTest
|
|||
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
|
||||
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
|
||||
action.setArchivaConfiguration( archivaConfiguration );
|
||||
( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).setArchivaConfiguration(
|
||||
archivaConfiguration );
|
||||
( (DefaultManagedRepositoryAdmin) ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).getManagedRepositoryAdmin() ).setArchivaConfiguration(
|
||||
archivaConfiguration );
|
||||
}
|
||||
|
||||
public void testSecureActionBundle()
|
||||
throws SecureActionException, RepositoryAdminException
|
||||
{
|
||||
archivaConfiguration.getConfiguration();
|
||||
archivaConfigurationControl.setReturnValue( new Configuration() );
|
||||
archivaConfigurationControl.setReturnValue( new Configuration(), 3 );
|
||||
archivaConfigurationControl.replay();
|
||||
|
||||
action.prepare();
|
||||
|
@ -83,19 +90,20 @@ public class RepositoryGroupsActionTest
|
|||
{
|
||||
Configuration configuration = new Configuration();
|
||||
archivaConfiguration.getConfiguration();
|
||||
archivaConfigurationControl.setReturnValue( configuration, 2 );
|
||||
archivaConfigurationControl.setReturnValue( configuration, 6 );
|
||||
|
||||
archivaConfiguration.save( configuration );
|
||||
archivaConfigurationControl.replay();
|
||||
|
||||
action.prepare();
|
||||
RepositoryGroupConfiguration repositoryGroup = action.getRepositoryGroup();
|
||||
RepositoryGroup repositoryGroup = action.getRepositoryGroup();
|
||||
repositoryGroup.setId( REPO_GROUP_ID );
|
||||
|
||||
String status = action.addRepositoryGroup();
|
||||
assertEquals( Action.SUCCESS, status );
|
||||
|
||||
assertEquals( Collections.singletonList( repositoryGroup ), configuration.getRepositoryGroups() );
|
||||
assertEquals( Collections.singletonList( repositoryGroup ),
|
||||
action.getRepositoryGroupAdmin().getRepositoriesGroups() );
|
||||
|
||||
archivaConfigurationControl.verify();
|
||||
}
|
||||
|
@ -105,7 +113,7 @@ public class RepositoryGroupsActionTest
|
|||
{
|
||||
Configuration configuration = new Configuration();
|
||||
archivaConfiguration.getConfiguration();
|
||||
archivaConfigurationControl.setReturnValue( configuration, 2 );
|
||||
archivaConfigurationControl.setReturnValue( configuration, 5 );
|
||||
|
||||
archivaConfiguration.save( configuration );
|
||||
|
||||
|
@ -124,26 +132,28 @@ public class RepositoryGroupsActionTest
|
|||
{
|
||||
Configuration configuration = new Configuration();
|
||||
archivaConfiguration.getConfiguration();
|
||||
archivaConfigurationControl.setReturnValue( configuration, 3 );
|
||||
archivaConfigurationControl.setReturnValue( configuration, 8 );
|
||||
|
||||
archivaConfiguration.save( configuration );
|
||||
|
||||
archivaConfigurationControl.replay();
|
||||
|
||||
action.prepare();
|
||||
RepositoryGroupConfiguration repositoryGroup = action.getRepositoryGroup();
|
||||
RepositoryGroup repositoryGroup = action.getRepositoryGroup();
|
||||
repositoryGroup.setId( REPO_GROUP_ID );
|
||||
|
||||
String status = action.addRepositoryGroup();
|
||||
assertEquals( Action.SUCCESS, status );
|
||||
|
||||
assertEquals( Collections.singletonList( repositoryGroup ), configuration.getRepositoryGroups() );
|
||||
assertEquals( Collections.singletonList( repositoryGroup ),
|
||||
action.getRepositoryGroupAdmin().getRepositoriesGroups() );
|
||||
|
||||
repositoryGroup.setId( REPO_GROUP_ID );
|
||||
status = action.addRepositoryGroup();
|
||||
|
||||
assertEquals( Action.ERROR, status );
|
||||
assertEquals( Collections.singletonList( repositoryGroup ), configuration.getRepositoryGroups() );
|
||||
assertEquals( Collections.singletonList( repositoryGroup ),
|
||||
action.getRepositoryGroupAdmin().getRepositoriesGroups() );
|
||||
}
|
||||
|
||||
public void testGetRepositoryGroups()
|
||||
|
@ -155,7 +165,7 @@ public class RepositoryGroupsActionTest
|
|||
Configuration configuration = createInitialConfiguration();
|
||||
|
||||
archivaConfiguration.getConfiguration();
|
||||
archivaConfigurationControl.setReturnValue( configuration );
|
||||
archivaConfigurationControl.setReturnValue( configuration, 6 );
|
||||
archivaConfigurationControl.replay();
|
||||
|
||||
action.setServletRequest( sc.newInvocation( "http://localhost/admin/repositoryGroups.action" ).getRequest() );
|
||||
|
@ -169,7 +179,7 @@ public class RepositoryGroupsActionTest
|
|||
assertEquals( 1, action.getRepositoryGroups().size() );
|
||||
assertEquals( 2, action.getManagedRepositories().size() );
|
||||
|
||||
RepositoryGroupConfiguration repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
|
||||
RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
|
||||
|
||||
assertEquals( 1, repoGroup.getRepositories().size() );
|
||||
assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
|
||||
|
@ -187,7 +197,7 @@ public class RepositoryGroupsActionTest
|
|||
Configuration configuration = createInitialConfiguration();
|
||||
|
||||
archivaConfiguration.getConfiguration();
|
||||
archivaConfigurationControl.setReturnValue( configuration, 6 );
|
||||
archivaConfigurationControl.setReturnValue( configuration, 17 );
|
||||
archivaConfiguration.save( configuration );
|
||||
archivaConfigurationControl.replay();
|
||||
|
||||
|
@ -199,7 +209,7 @@ public class RepositoryGroupsActionTest
|
|||
assertEquals( 1, action.getRepositoryGroups().size() );
|
||||
assertEquals( 2, action.getManagedRepositories().size() );
|
||||
|
||||
RepositoryGroupConfiguration repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
|
||||
RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
|
||||
assertEquals( 1, repoGroup.getRepositories().size() );
|
||||
assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
|
||||
|
||||
|
@ -236,7 +246,7 @@ public class RepositoryGroupsActionTest
|
|||
Configuration configuration = createInitialConfiguration();
|
||||
|
||||
archivaConfiguration.getConfiguration();
|
||||
archivaConfigurationControl.setReturnValue( configuration, 6 );
|
||||
archivaConfigurationControl.setReturnValue( configuration, 13 );
|
||||
archivaConfiguration.save( configuration );
|
||||
archivaConfigurationControl.replay();
|
||||
|
||||
|
@ -248,7 +258,7 @@ public class RepositoryGroupsActionTest
|
|||
assertEquals( 1, action.getRepositoryGroups().size() );
|
||||
assertEquals( 2, action.getManagedRepositories().size() );
|
||||
|
||||
RepositoryGroupConfiguration repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
|
||||
RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
|
||||
assertEquals( 1, repoGroup.getRepositories().size() );
|
||||
assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
|
||||
|
||||
|
@ -299,7 +309,7 @@ public class RepositoryGroupsActionTest
|
|||
assertEquals( 1, action.getRepositoryGroups().size() );
|
||||
assertEquals( 2, action.getManagedRepositories().size() );
|
||||
|
||||
RepositoryGroupConfiguration repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
|
||||
RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
|
||||
assertEquals( 1, repoGroup.getRepositories().size() );
|
||||
assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
|
||||
|
||||
|
@ -335,7 +345,7 @@ public class RepositoryGroupsActionTest
|
|||
assertEquals( 1, action.getRepositoryGroups().size() );
|
||||
assertEquals( 2, action.getManagedRepositories().size() );
|
||||
|
||||
RepositoryGroupConfiguration repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
|
||||
RepositoryGroup repoGroup = action.getRepositoryGroups().get( REPO_GROUP_ID );
|
||||
assertEquals( 1, repoGroup.getRepositories().size() );
|
||||
assertEquals( REPO1_ID, repoGroup.getRepositories().get( 0 ) );
|
||||
|
||||
|
|
|
@ -52,6 +52,28 @@
|
|||
<level value="error"/>
|
||||
</logger>
|
||||
|
||||
<!-- reduce noise for unit tests -->
|
||||
|
||||
<logger name="org.springframework">
|
||||
<level value="error"/>
|
||||
</logger>
|
||||
|
||||
<logger name="org.codehaus.plexus">
|
||||
<level value="error"/>
|
||||
</logger>
|
||||
|
||||
<logger name="org.codehaus.redback">
|
||||
<level value="error"/>
|
||||
</logger>
|
||||
|
||||
<logger name="org.apache.cxf">
|
||||
<level value="error"/>
|
||||
</logger>
|
||||
|
||||
<logger name="org.quartz">
|
||||
<level value="error"/>
|
||||
</logger>
|
||||
|
||||
<root>
|
||||
<priority value ="info" />
|
||||
<appender-ref ref="console" />
|
||||
|
|
Loading…
Reference in New Issue