managedRepository.setId( id );
managedRepository.setName( "name of " + id );
managedRepository.setLocation( System.getProperty( "basedir" ) + "/src/test/repositories/test-repo" );
managedRepository.setIndexDirectory( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex/" + id );
ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService();
if ( managedRepositoriesService.getManagedRepository( id ) != null )
{
managedRepositoriesService.deleteManagedRepository( id, false );
}
getManagedRepositoriesService().addManagedRepository( managedRepository );
RepositoriesService repositoriesService = getRepositoriesService();
repositoriesService.scanRepositoryNow( id, true );
// wait a bit to ensure index is finished
int timeout = 20000;
while ( timeout > 0 && repositoriesService.alreadyScanning( id ) )
{
Thread.sleep( 500 );
timeout -= 500;
}
RepositoryGroupService repositoryGroupService = getRepositoryGroupService();
String repoGroupId = "test-group";
if ( repositoryGroupService.getRepositoryGroup( repoGroupId ) != null )
{
repositoryGroupService.deleteRepositoryGroup( repoGroupId );
}
RepositoryGroup repositoryGroup = new RepositoryGroup();
repositoryGroup.setId( repoGroupId );
String path = ".fooooo";
repositoryGroup.setRepositories( Arrays.asList( id ) );
repositoryGroup.setMergedIndexPath( path );
repositoryGroupService.addRepositoryGroup( repositoryGroup );
// create a repo with a remote on the one with index
id = Long.toString( System.currentTimeMillis() );
managedRepository = new ManagedRepository();
managedRepository.setId( id );
managedRepository.setName( "name of " + id );
managedRepository.setLocation( System.getProperty( "basedir" ) + "/src/test/repositories/test-repo" );
managedRepository.setIndexDirectory( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex/" + id );
if ( managedRepositoriesService.getManagedRepository( id ) != null )
{
managedRepositoriesService.deleteManagedRepository( id, false );
}
getManagedRepositoriesService().addManagedRepository( managedRepository );
String remoteId = Long.toString( System.currentTimeMillis() );