@Test
public void shouldPreserveBinariesFronARestoredBackup() throws Exception {
loadBinaryContent();
makeBackup();
wipeRepository();
startFromBackup();
makeBackup();
wipeRepository();
startFromBackup();
makeBackup();
}
private void makeBackup() throws RepositoryException {
assertTrue(FileUtil.delete(backupDirectory));
JcrSession session = repository().login();
Problems problems = session.getWorkspace().getRepositoryManager().backupRepository(backupDirectory,
BackupOptions.DEFAULT);
assertNoProblems(problems);
session.logout();
}
private void wipeRepository() {
repository().doShutdown(false);
assertTrue(FileUtil.delete(backupRepoDir));
}
private void startFromBackup() throws Exception {
startRepositoryWithConfiguration(resourceStream("config/backup-repo-config.json"));
JcrSession session = repository().login();
Problems problems = session.getWorkspace().getRepositoryManager().restoreRepository(backupDirectory);
assertNoProblems(problems);
session.logout();
assertFilesInWorkspcae("default");
assertFilesInWorkspcae("ws2");
assertFilesInWorkspcae("ws3");
}