[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
This commit is contained in:
Brett Porter 2010-01-19 07:45:04 +00:00
parent 0e58834406
commit 06a035aacd
1 changed files with 17 additions and 8 deletions

View File

@ -25,6 +25,7 @@ import java.util.Collections;
import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.Action;
import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager; 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.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
@ -141,6 +142,13 @@ public class EditManagedRepositoryActionTest
populateRepository( repository ); populateRepository( repository );
repository.setName( "new repo name" ); 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(); String status = action.commit();
assertEquals( Action.SUCCESS, status ); assertEquals( Action.SUCCESS, status );
@ -151,6 +159,7 @@ public class EditManagedRepositoryActionTest
roleManagerControl.verify(); roleManagerControl.verify();
archivaConfigurationControl.verify(); archivaConfigurationControl.verify();
repositoryStatisticsManagerControl.verify();
} }
public void testEditRepositoryLocationChanged() public void testEditRepositoryLocationChanged()
@ -181,9 +190,7 @@ public class EditManagedRepositoryActionTest
RepositoryStatisticsManager repositoryStatisticsManager = RepositoryStatisticsManager repositoryStatisticsManager =
(RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock(); (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
action.setRepositoryStatisticsManager( repositoryStatisticsManager ); action.setRepositoryStatisticsManager( repositoryStatisticsManager );
repositoryStatisticsManager.deleteStatistics( REPO_ID ); repositoryStatisticsManager.deleteStatistics( REPO_ID );
repositoryStatisticsManagerControl.replay(); repositoryStatisticsManagerControl.replay();
action.setRepoid( REPO_ID ); action.setRepoid( REPO_ID );
@ -192,7 +199,9 @@ public class EditManagedRepositoryActionTest
ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration(); ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
populateRepository( repository ); 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 ); action.setRepository( repository );
String status = action.commit(); String status = action.commit();
assertEquals( Action.SUCCESS, status ); assertEquals( Action.SUCCESS, status );