*/
import com.opensymphony.xwork.Action;
+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.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
import org.easymock.MockControl;
+import java.io.File;
import java.util.Collections;
/**
private static final String REPO_ID = "repo-ident";
+ private File location;
+
protected void setUp()
throws Exception
{
roleManagerControl = MockControl.createControl( RoleManager.class );
roleManager = (RoleManager) roleManagerControl.getMock();
action.setRoleManager( roleManager );
+ location = getTestFile( "location" );
}
public void testAddRepositoryInitialPage()
public void testAddRepository()
throws Exception
{
+ FileUtils.deleteDirectory( location );
+
// TODO: should be in the business model
roleManager.createTemplatedRole( "archiva-repository-manager", REPO_ID );
roleManager.createTemplatedRole( "archiva-repository-observer", REPO_ID );
AdminRepositoryConfiguration repository = action.getRepository();
populateRepository( repository );
+ assertFalse( location.exists() );
String status = action.save();
assertEquals( Action.SUCCESS, status );
+ assertTrue( location.exists() );
assertEquals( configuration.getManagedRepositories(), Collections.singletonList( repository ) );
assertEquals( expectedRepository.isSnapshots(), actualRepository.isSnapshots() );
}
- private static Configuration createConfigurationForEditing()
+ private Configuration createConfigurationForEditing()
{
Configuration configuration = new Configuration();
ManagedRepositoryConfiguration r = createRepository();
return configuration;
}
- private static ManagedRepositoryConfiguration createRepository()
+ private ManagedRepositoryConfiguration createRepository()
{
ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
r.setId( REPO_ID );
archivaConfigurationControl.verify();
}
- private static void populateRepository( ManagedRepositoryConfiguration repository )
+ private void populateRepository( ManagedRepositoryConfiguration repository )
{
repository.setId( REPO_ID );
repository.setName( "repo name" );
- repository.setLocation( getTestFile( "location" ).getAbsolutePath() );
+ repository.setLocation( location.getAbsolutePath() );
repository.setLayout( "default" );
repository.setRefreshCronExpression( "* 0/5 * * * ?" );
repository.setDaysOlder( 31 );