public void testCreateRepositorySingleDB() throws Exception
{
// prepare
String dsName = helper.createDatasource();
ManageableRepository repository = helper.createRepository(container, false, dsName);
WorkspaceEntry wsEntry = helper.createWorkspaceEntry(false, dsName);
helper.addWorkspace(repository, wsEntry);
addConent(repository, wsEntry.getName());
// backup
File backDir = new File("target/backup");
backDir.mkdirs();
RepositoryBackupConfig config = new RepositoryBackupConfig();
config.setRepository(repository.getConfiguration().getName());
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
config.setBackupDir(backDir);
RepositoryBackupChain bch = backup.startBackup(config);
waitEndOfBackup(bch);
backup.stopBackup(bch);
// restore with RepositoryCreatorService
RepositoryCreationService creatorService =
(RepositoryCreationService)container.getComponentInstanceOfType(RepositoryCreationService.class);
assertNotNull(creatorService);
String tenantName = "new_repository_single-db";
String repoToken = creatorService.reserveRepositoryName(tenantName);
// restore
String newDSName = IdGenerator.generate();
RepositoryEntry newRE =
helper.createRepositoryEntry(false, repository.getConfiguration().getSystemWorkspaceName(), newDSName);
newRE.setName(tenantName);
WorkspaceEntry newWSEntry = helper.createWorkspaceEntry(false, newDSName);
newWSEntry.setName(wsEntry.getName());
newRE.addWorkspace(newWSEntry);
creatorService.createRepository(bch.getBackupId(), newRE, repoToken);
// check