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;
import org.easymock.MockControl;
/**
- * EditManagedRepositoryActionTest
+ * EditManagedRepositoryActionTest
*
* @version $Id$
*/
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 );
roleManagerControl.verify();
archivaConfigurationControl.verify();
+ repositoryStatisticsManagerControl.verify();
}
public void testEditRepositoryLocationChanged()
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 );
archivaConfigurationControl.verify();
repositoryStatisticsManagerControl.verify();
}
-
+
private void assertRepositoryEquals( ManagedRepositoryConfiguration expectedRepository,
ManagedRepositoryConfiguration actualRepository )
{