fix unit test due to refactoring

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1170160 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-09-13 12:56:02 +00:00
parent 4ae58b1684
commit 667064686c
2 changed files with 19 additions and 4 deletions

View File

@ -108,4 +108,14 @@ public class DeleteRepositoryGroupAction
{ {
this.repoGroupId = repoGroupId; this.repoGroupId = repoGroupId;
} }
public RepositoryGroupAdmin getRepositoryGroupAdmin()
{
return repositoryGroupAdmin;
}
public void setRepositoryGroupAdmin( RepositoryGroupAdmin repositoryGroupAdmin )
{
this.repositoryGroupAdmin = repositoryGroupAdmin;
}
} }

View File

@ -22,6 +22,7 @@ package org.apache.maven.archiva.web.action.admin.repositories;
import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.Action;
import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.group.RepositoryGroup; import org.apache.archiva.admin.model.group.RepositoryGroup;
import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin;
import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration; import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
@ -51,12 +52,14 @@ public class DeleteRepositoryGroupActionTest
{ {
super.setUp(); super.setUp();
//action = (DeleteRepositoryGroupAction) lookup ( Action.class.getName(), "deleteRepositoryGroupAction" );
action = (DeleteRepositoryGroupAction) getActionProxy( "/admin/deleteRepositoryGroup.action" ).getAction(); action = (DeleteRepositoryGroupAction) getActionProxy( "/admin/deleteRepositoryGroup.action" ).getAction();
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class ); archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock(); archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
action.setArchivaConfiguration( archivaConfiguration ); action.setArchivaConfiguration( archivaConfiguration );
( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).setArchivaConfiguration(
archivaConfiguration );
} }
public void testSecureActionBundle() public void testSecureActionBundle()
@ -98,7 +101,7 @@ public class DeleteRepositoryGroupActionTest
Configuration configuration = createConfigurationForEditing( createRepositoryGroup() ); Configuration configuration = createConfigurationForEditing( createRepositoryGroup() );
archivaConfiguration.getConfiguration(); archivaConfiguration.getConfiguration();
archivaConfigurationControl.setReturnValue( configuration, 3 ); archivaConfigurationControl.setReturnValue( configuration, 5 );
archivaConfiguration.save( configuration ); archivaConfiguration.save( configuration );
archivaConfigurationControl.replay(); archivaConfigurationControl.replay();
@ -108,7 +111,8 @@ public class DeleteRepositoryGroupActionTest
assertEquals( REPO_GROUP_ID, action.getRepoGroupId() ); assertEquals( REPO_GROUP_ID, action.getRepoGroupId() );
RepositoryGroup repoGroup = action.getRepositoryGroup(); RepositoryGroup repoGroup = action.getRepositoryGroup();
assertNotNull( repoGroup ); assertNotNull( repoGroup );
assertEquals( Collections.singletonList( repoGroup ), configuration.getRepositoryGroups() ); assertEquals( Collections.singletonList( repoGroup ),
action.getRepositoryGroupAdmin().getRepositoriesGroups() );
String status = action.delete(); String status = action.delete();
assertEquals( Action.SUCCESS, status ); assertEquals( Action.SUCCESS, status );
@ -136,7 +140,8 @@ public class DeleteRepositoryGroupActionTest
String status = action.execute(); String status = action.execute();
assertEquals( Action.SUCCESS, status ); assertEquals( Action.SUCCESS, status );
assertEquals( Collections.singletonList( repoGroup ), configuration.getRepositoryGroups() ); assertEquals( Collections.singletonList( repoGroup ),
action.getRepositoryGroupAdmin().getRepositoriesGroups() );
} }
private Configuration createConfigurationForEditing( RepositoryGroupConfiguration repoGroup ) private Configuration createConfigurationForEditing( RepositoryGroupConfiguration repoGroup )