}
@Test
public void shouldBackupRepositoryWithMultipleWorkspaces() throws Exception {
loadContent();
Problems problems = session().getWorkspace().getRepositoryManager().backupRepository(backupDirectory);
assertNoProblems(problems);
// Make some changes that will not be in the backup ...
session().getRootNode().addNode("node-not-in-backup");
session().save();
assertContentInWorkspace(repository(), "default", "/node-not-in-backup");
assertContentInWorkspace(repository(), "ws2");
assertContentInWorkspace(repository(), "ws3");
// Start up a new repository
((LocalEnvironment)environment).setShared(true);
RepositoryConfiguration config = RepositoryConfiguration.read("config/restore-repo-config.json").with(environment);
JcrRepository newRepository = new JcrRepository(config);
try {
newRepository.start();
// And restore it from the contents ...
JcrSession newSession = newRepository.login();
try {
Problems restoreProblems = newSession.getWorkspace().getRepositoryManager().restoreRepository(backupDirectory);
assertNoProblems(restoreProblems);
} finally {
newSession.logout();
}
// Check that the node that was added *after* the backup is not there ...
assertContentNotInWorkspace(newRepository, "default", "/node-not-in-backup");
// Before we assert the content, create a backup of it (for comparison purposes when debugging) ...
newSession = newRepository.login();
try {
Problems backupProblems = newSession.getWorkspace().getRepositoryManager().backupRepository(backupDirectory2);
assertNoProblems(backupProblems);
} finally {
newSession.logout();
}