wsEntry = entry;
break;
}
}
BackupManagerImpl backupManagerImpl = (BackupManagerImpl)getBackupManager();
backupManagerImpl.start();
File backDir = new File("target/backup/" + repositoryName);
backDir.mkdirs();
BackupConfig config = new BackupConfig();
config.setRepository(repositoryName);
config.setWorkspace(workspaceName);
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
config.setBackupDir(backDir);
BackupChain bch = backupManagerImpl.startBackup(config);
// wait till full backup will stop
while (bch.getFullBackupState() != BackupChain.FINISHED)
{
Thread.yield();
Thread.sleep(30);
}
if (bch != null)
{
backupManagerImpl.stopBackup(bch);
}
// restore
File backLog = new File(bch.getLogFilePath());
if (backLog.exists())
{
BackupChainLog bchLog = new BackupChainLog(backLog);
assertNotNull(bchLog.getStartedTime());
assertNotNull(bchLog.getFinishedTime());
backupManagerImpl.restoreExistingWorkspace(bchLog, repositoryName, wsEntry, false);
JobWorkspaceRestore restore = backupManagerImpl.getLastRestore(repositoryName, workspaceName);
assertNotNull(restore);
}
else
{
fail("There are no backup files in " + backDir.getAbsolutePath());