@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(); }
/** * 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(); }
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(); } } }
protected void addFilesToWorkspace(String workspaceName) throws Exception { 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 { for (int i = 0; i < BINARY_RESOURCES.length; i++) { tools.uploadFile(session, "file_" + i, resourceStream(BINARY_RESOURCES[i])); } session.save(); } finally { session.logout(); } }
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();
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();
@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-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"); }
@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();