From 06a035aacd3acaf98eddea5a110d4593323137a1 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Tue, 19 Jan 2010 07:45:04 +0000 Subject: [PATCH] [MRM-1282] clean up edit test, note that a location change does not delete audit events git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@900692 13f79535-47bb-0310-9956-ffa450edef68 --- .../EditManagedRepositoryActionTest.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) 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 7c894ea32..1f5024fb5 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 @@ -25,6 +25,7 @@ import java.util.Collections; import com.opensymphony.xwork2.Action; import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager; +import org.apache.commons.io.FileUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; @@ -36,7 +37,7 @@ import org.codehaus.redback.integration.interceptor.SecureActionException; import org.easymock.MockControl; /** - * EditManagedRepositoryActionTest + * EditManagedRepositoryActionTest * * @version $Id$ */ @@ -140,10 +141,17 @@ public class EditManagedRepositoryActionTest ManagedRepositoryConfiguration repository = action.getRepository(); populateRepository( repository ); repository.setName( "new repo name" ); - + + MockControl repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class ); + RepositoryStatisticsManager repositoryStatisticsManager = + (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock(); + action.setRepositoryStatisticsManager( repositoryStatisticsManager ); + // no deletion + repositoryStatisticsManagerControl.replay(); + String status = action.commit(); assertEquals( Action.SUCCESS, status ); - + ManagedRepositoryConfiguration newRepository = createRepository(); newRepository.setName( "new repo name" ); assertRepositoryEquals( repository, newRepository ); @@ -151,6 +159,7 @@ public class EditManagedRepositoryActionTest roleManagerControl.verify(); archivaConfigurationControl.verify(); + repositoryStatisticsManagerControl.verify(); } public void testEditRepositoryLocationChanged() @@ -181,18 +190,18 @@ public class EditManagedRepositoryActionTest RepositoryStatisticsManager repositoryStatisticsManager = (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock(); action.setRepositoryStatisticsManager( repositoryStatisticsManager ); - repositoryStatisticsManager.deleteStatistics( REPO_ID ); - repositoryStatisticsManagerControl.replay(); action.setRepoid( REPO_ID ); action.prepare(); assertEquals( REPO_ID, action.getRepoid() ); - + ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration(); populateRepository( repository ); - repository.setLocation( new File( "target/test/location/new" ).getCanonicalPath() ); + File testFile = getTestFile( "target/test/location/new" ); + FileUtils.deleteDirectory( testFile ); + repository.setLocation( testFile.getCanonicalPath() ); action.setRepository( repository ); String status = action.commit(); assertEquals( Action.SUCCESS, status ); @@ -202,7 +211,7 @@ public class EditManagedRepositoryActionTest archivaConfigurationControl.verify(); repositoryStatisticsManagerControl.verify(); } - + private void assertRepositoryEquals( ManagedRepositoryConfiguration expectedRepository, ManagedRepositoryConfiguration actualRepository ) {