protected void loadBinaryContent() throws Exception { addFilesToWorkspace("default"); addFilesToWorkspace("ws2"); addFilesToWorkspace("ws3"); }
@Test @FixFor( "MODE-2253" ) public void shouldBackupAndRestoreWithExistingUserTransaction() throws Exception { loadContent(); startTransaction(); Problems problems = session().getWorkspace().getRepositoryManager().backupRepository(backupDirectory); assertNoProblems(problems); problems = session().getWorkspace().getRepositoryManager().restoreRepository(backupDirectory); assertNoProblems(problems); rollbackTransaction(); assertContentInWorkspace(repository(), "default"); assertContentInWorkspace(repository(), "ws2"); assertContentInWorkspace(repository(), "ws3"); }
private void verifyBinaryContent() throws Exception { assertFilesInWorkspace("default"); assertFilesInWorkspace("ws2"); assertFilesInWorkspace("ws3"); }
@Test @FixFor( "MODE-2584" ) public void shouldPreserveBinariesFromRestoredBackup() throws Exception { loadBinaryContent(); makeBackup(BackupOptions.DEFAULT); wipeRepository(); restoreBackup(); makeBackup(BackupOptions.DEFAULT); wipeRepository(); restoreBackup(); verifyBinaryContent(); }
loadContent(); assertContentInWorkspace(repository(), "default"); assertContentInWorkspace(repository(), "ws2"); assertContentInWorkspace(repository(), "ws3"); Problems problems = session().getWorkspace().getRepositoryManager().backupRepository(backupDirectory); assertNoProblems(problems); session().getRootNode().addNode("node-not-in-backup"); session().save(); assertContentInWorkspace(repository(), "default", "/node-not-in-backup"); assertContentInWorkspace(repository(), "ws2"); assertContentInWorkspace(repository(), "ws3"); JcrSession newSession = repository().login(); try { Problems restoreProblems = newSession.getWorkspace().getRepositoryManager().restoreRepository(backupDirectory); assertNoProblems(restoreProblems); } finally { newSession.logout(); assertWorkspaces(repository(), "default", "ws2", "ws3"); assertContentInWorkspace(repository(), "default"); assertContentInWorkspace(repository(), "ws2"); assertContentInWorkspace(repository(), "ws3"); assertContentNotInWorkspace(repository(), "default", "/node-not-in-backup"); queryContentInWorkspace(repository(), null);
importIntoWorkspace("default", "io/cars-system-view.xml"); assertWorkspaces(repository(), "default"); assertContentInWorkspace(repository(), "default"); Node prius = session().getNode("/Cars/Hybrid/Toyota Prius"); prius.setProperty("crlfproperty", "test\r\ntest\r\ntest"); prius.setProperty("lfprop", "value\nvalue\nvalue"); session().save(); Problems problems = session().getWorkspace().getRepositoryManager().backupRepository(backupDirectory); assertNoProblems(problems); session().getRootNode().addNode("node-not-in-backup"); session().save(); assertContentInWorkspace(repository(), "default", "/node-not-in-backup"); JcrSession newSession = repository().login(); try { Problems restoreProblems = newSession.getWorkspace().getRepositoryManager().restoreRepository(backupDirectory); assertNoProblems(restoreProblems); } finally { newSession.logout(); assertWorkspaces(repository(), "default"); assertContentInWorkspace(repository(), "default"); assertContentNotInWorkspace(repository(), "default", "/node-not-in-backup"); queryContentInWorkspace(repository(), null);
@Test @FixFor( "MODE-2440" ) public void shouldRestoreBinaryReferencesWhenExcludedFromBackup() throws Exception { loadBinaryContent(); verifyBinaryContent(); // Make the backup, and check that there are no problems ... BackupOptions backupOptions = new BackupOptions() { @Override public boolean includeBinaries() { return false; } }; Problems problems = session().getWorkspace().getRepositoryManager().backupRepository(backupDirectory, backupOptions); assertNoProblems(problems); // shutdown the repo and remove just the repo main store (not the binary store) assertTrue(repository().shutdown().get()); FileUtil.delete(backupRepoDir.getPath() + "/store"); // start a fresh empty repo and then restore just the data without binaries startRepositoryWithConfigurationFrom("config/backup-repo-config.json"); RestoreOptions restoreOptions = new RestoreOptions() { @Override public boolean includeBinaries() { return false; } }; problems = session().getWorkspace().getRepositoryManager().restoreRepository(backupDirectory, restoreOptions); assertNoProblems(problems); verifyBinaryContent(); }
@Test @FixFor( "MODE-2440" ) public void shouldRestoreLegacy450BackupWithCompressedBinaries() throws Exception { // extract the old repo backup File legacyBackupDir = extractZip("legacy_backup/repoBackups450.zip", this.backupArea); assertTrue("Zip content not extracted correctly", legacyBackupDir.exists() && legacyBackupDir.canRead() && legacyBackupDir.isDirectory()); Problems problems = session().getWorkspace().getRepositoryManager().restoreRepository(legacyBackupDir); assertNoProblems(problems); verifyBinaryContent(); }
private void restoreBackup() throws Exception { startRepositoryWithConfiguration(resourceStream("config/backup-repo-config.json")); JcrSession session = repository().login(); Problems problems = session.getWorkspace().getRepositoryManager().restoreRepository(backupDirectory); assertNoProblems(problems); session.logout(); }
protected void importIntoWorkspace( String workspaceName, String resourcePath ) throws IOException, RepositoryException { Session session = null; try { session = repository().login(workspaceName); } catch (NoSuchWorkspaceException e) { // Create the workspace ... session().getWorkspace().createWorkspace(workspaceName); // Create a new session ... session = repository().login(workspaceName); } try { importContent(session.getRootNode(), resourcePath, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW); } finally { session.logout(); } } }
public void shouldRestoreLegacy381RepositoryWithDifferentName() throws Exception { File legacyBackupDir = extractZip("legacy_backup/repoBackups381_2.zip", this.backupArea); assertTrue("Zip content not extracted correctly", legacyBackupDir.exists() && legacyBackupDir.canRead() && legacyBackupDir.isDirectory()); Problems problems = session().getWorkspace().getRepositoryManager().restoreRepository(legacyBackupDir); assertNoProblems(problems); final Session session = repository.login(); final AtomicInteger totalCount = new AtomicInteger(0);
private void makeBackup(BackupOptions options) throws RepositoryException { TestingUtil.waitUntilFolderCleanedUp(backupDirectory.getPath()); JcrSession session = repository().login(); try { Problems problems = session.getWorkspace().getRepositoryManager().backupRepository(backupDirectory, options); assertNoProblems(problems); } finally { session.logout(); } }
protected void loadContent() throws Exception { importIntoWorkspace("default", "io/cars-system-view.xml"); importIntoWorkspace("ws2", "io/cars-system-view.xml"); importIntoWorkspace("ws3", "io/cars-system-view.xml"); }
@Test public void shouldBackupRepositoryWithMultipleWorkspaces() throws Exception { loadContent(); Problems problems = session().getWorkspace().getRepositoryManager().backupRepository(backupDirectory); assertNoProblems(problems); session().getRootNode().addNode("node-not-in-backup"); session().save(); assertContentInWorkspace(repository(), "default", "/node-not-in-backup"); assertContentInWorkspace(repository(), "ws2"); assertContentInWorkspace(repository(), "ws3"); try { Problems restoreProblems = newSession.getWorkspace().getRepositoryManager().restoreRepository(backupDirectory); assertNoProblems(restoreProblems); } finally { newSession.logout(); assertContentNotInWorkspace(newRepository, "default", "/node-not-in-backup"); try { Problems backupProblems = newSession.getWorkspace().getRepositoryManager().backupRepository(backupDirectory2); assertNoProblems(backupProblems); } finally { newSession.logout(); assertWorkspaces(newRepository, "default", "ws2", "ws3"); assertContentInWorkspace(newRepository, null);
@Test @FixFor( "MODE-2440" ) public void shouldBackupRepositoryWhichIncludesBinaryValuesCompressed() throws Exception { loadBinaryContent(); makeBackup(BackupOptions.DEFAULT); wipeRepository(); restoreBackup(); verifyBinaryContent(); }
/** * Test that a repository containing the same binary data (files) as the ones from this test backed up using ModeShape 3.8.1 * is restored correctly. */ @Test @FixFor( "MODE-2440" ) public void shouldRestoreLegacy381RepositoryWithSameName() throws Exception { // extract the old repo backup File legacyBackupDir = extractZip("legacy_backup/repoBackups381.zip", this.backupArea); assertTrue("Zip content not extracted correctly", legacyBackupDir.exists() && legacyBackupDir.canRead() && legacyBackupDir.isDirectory()); Problems problems = session().getWorkspace().getRepositoryManager().restoreRepository(legacyBackupDir); assertNoProblems(problems); verifyBinaryContent(); }
@Test @FixFor( "MODE-2559" ) public void shouldBackupRepositoryWhichIncludesBinaryValuesUncompressed() throws Exception { BackupOptions backupOptions = new BackupOptions() { @Override public boolean compress() { return false; } }; loadBinaryContent(); makeBackup(backupOptions); wipeRepository(); restoreBackup(); verifyBinaryContent(); }