managedRepository.setId( id );
managedRepository.setName( "name of " + id );
managedRepository.setLocation( "src/test/repositories/test-repo" );
managedRepository.setIndexDirectory( "target/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();
RepositoryGroup repositoryGroup = new RepositoryGroup();
repositoryGroup.setId( "test-group" );
repositoryGroup.setRepositories( Arrays.asList( id ) );
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( "src/test/repositories/test-repo" );
managedRepository.setIndexDirectory( "target/tmpIndex/" + id );
if ( managedRepositoriesService.getManagedRepository( id ) != null )
{
managedRepositoriesService.deleteManagedRepository( id, false );
}
getManagedRepositoriesService().addManagedRepository( managedRepository );
RemoteRepository remoteRepository = new RemoteRepository();