protected void repositoryFullBackupRestoreBackupSingleToIsolatedOnIsolated(String repositoryName) throws Exception
{
// prepare
addConent(repositoryName);
BackupManagerImpl backupManagerImpl = (BackupManagerImpl)getBackupManager();
backupManagerImpl.start();
// backup
File backDir = new File("target/backup/" + IdGenerator.generate());
backDir.mkdirs();
RepositoryBackupConfig config = new RepositoryBackupConfig();
config.setRepository(repositoryName);
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
config.setBackupDir(backDir);
RepositoryBackupChain bch = backupManagerImpl.startBackup(config);
// wait till full backup will stop
while (bch.getState() != BackupJob.FINISHED)
{
Thread.yield();
Thread.sleep(30);
}
if (bch != null)
{
backupManagerImpl.stopBackup(bch);
}
TesterConfigurationHelper helper = TesterConfigurationHelper.getInstance();
RepositoryEntry repositoryEntryIsolated = helper.copyRepositoryEntry(repositoryService.getRepository(repositoryName).getConfiguration());
for (WorkspaceEntry we : repositoryEntryIsolated.getWorkspaceEntries())
{
we.getContainer().addParameter(
new SimpleParameterEntry(JDBCWorkspaceDataContainer.DB_STRUCTURE_TYPE, DatabaseStructureType.ISOLATED
.toString()));
}
// restore single backup on structure single to isolated
{
RepositoryEntry newRE = helper.copyRepositoryEntry(repositoryEntryIsolated);
File backLog = new File(bch.getLogFilePath());
assertTrue(backLog.exists());
RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
backupManagerImpl.restoreExistingRepository(bchLog, newRE, false);
checkConent(newRE.getName());
String dbStructureType = repositoryService.getRepository(repositoryName).getConfiguration().getWorkspaceEntries().get(0).getContainer().getParameterValue(JDBCWorkspaceDataContainer.DB_STRUCTURE_TYPE);
assertTrue(DatabaseStructureType.ISOLATED.toString().equalsIgnoreCase(dbStructureType));
}
// restore single backup on structure isolated to isolated
{
RepositoryEntry newRE = helper.copyRepositoryEntry(repositoryEntryIsolated);
File backLog = new File(bch.getLogFilePath());
assertTrue(backLog.exists());
RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
backupManagerImpl.restoreExistingRepository(bchLog, newRE, false);
checkConent(newRE.getName());
String dbStructureType = repositoryService.getRepository(repositoryName).getConfiguration().getWorkspaceEntries().get(0).getContainer().getParameterValue(JDBCWorkspaceDataContainer.DB_STRUCTURE_TYPE);
assertTrue(DatabaseStructureType.ISOLATED.toString().equalsIgnoreCase(dbStructureType));
}
// revert the single structure in repository
{
File backLog = new File(bch.getLogFilePath());
assertTrue(backLog.exists());
RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
backupManagerImpl.restoreExistingRepository(bchLog.getBackupId(), false);
checkConent(repositoryName);
String dbStructureType = repositoryService.getRepository(repositoryName).getConfiguration().getWorkspaceEntries().get(0).getContainer().getParameterValue(JDBCWorkspaceDataContainer.DB_STRUCTURE_TYPE);
assertTrue(DatabaseStructureType.SINGLE.toString().equalsIgnoreCase(dbStructureType));
}
}