private void expectReferentialIntegrityException() throws RepositoryException { try { session.save(); fail("Expected a referential integrity exception"); } catch (ReferentialIntegrityException e) { // expected session.refresh(false); } }
@Test public void shouldNotAllowRemovingNodesInReadOnlyProjection() throws Exception { Node file = session.getNode("/testRoot/readonly/dir3/simple.json"); try { session.refresh(false); file.remove(); session.save(); fail("failed to throw read-only exception"); } catch (RepositoryException e) { // expected } }
session.refresh(false); allChildrenPaths.add(child1Path);
session.refresh(false); col = session.getRootNode().addNode("smallCol", "test:smallCollection"); col.addNode("child");
private void assertChangesVisibleViaListener(JcrSession session1, JcrSession session2) throws RepositoryException, InterruptedException { int eventTypes = Event.NODE_ADDED | Event.PROPERTY_ADDED; ClusteringEventListener listener = new ClusteringEventListener(3); session2.getWorkspace().getObservationManager().addEventListener(listener, eventTypes, null, true, null, null, true); Node testNode = session1.getRootNode().addNode("testNode"); String binary = "test string"; testNode.setProperty("binaryProperty", session1.getValueFactory().createBinary(binary.getBytes())); session1.save(); final String testNodePath = testNode.getPath(); listener.waitForEvents(); List<String> paths = listener.getPaths(); assertEquals(3, paths.size()); assertTrue(paths.contains("/testNode")); assertTrue(paths.contains("/testNode/binaryProperty")); assertTrue(paths.contains("/testNode/jcr:primaryType")); // check whether the node can be found in the second repository ... Thread.sleep(500); try { session2.refresh(false); session2.getNode(testNodePath); } catch (PathNotFoundException e) { fail("Should have found the '/testNode' created in other repository in this repository: "); } }
} catch (RepositoryException e) { assertTrue(e.getCause() instanceof IllegalStateException); session.refresh(false);
@Test @FixFor( "MODE-1302" ) public void shouldHaveVersionHistoryWhenRefreshIsCalled() throws Exception { Node outerNode = session.getRootNode().addNode("outerFolder"); Node innerNode = outerNode.addNode("innerFolder"); Node fileNode = innerNode.addNode("testFile.dat"); fileNode.setProperty("jcr:mimeType", "text/plain"); fileNode.setProperty("jcr:data", "Original content"); session.save(); assertFalse(hasVersionHistory(fileNode)); fileNode.addMixin("mix:versionable"); // Version history is not created until save assertFalse(hasVersionHistory(fileNode)); session.refresh(true); // Version history is not created until save assertFalse(hasVersionHistory(fileNode)); session.save(); assertTrue(hasVersionHistory(fileNode)); }
session.refresh(false); prius = session.getNode(prius.getPath()); sharedNode = session.getNode(sharedNode.getPath());
getSession().getWorkspace().deepClone(sourceSession, sourceNode.key(), cloneSession, key()); session().refresh(false);
getSession().getWorkspace().deepClone(sourceSession, sourceNode.key(), cloneSession, key()); session().refresh(false);
} catch (RepositoryException e) { assertTrue(e.getCause() instanceof IllegalStateException); session.refresh(false);
session2.refresh(false); session2.getNode(testNodePath);
private void checkBinaryUsageAfterSaving() throws Exception { assertEquals("There should be no binaries in store", 0, binariesCount()); // upload 2 binaries but don't save tools.uploadFile(session, "/file1.txt", resourceStream("io/file1.txt")); tools.uploadFile(session, "/file2.txt", resourceStream("io/file2.txt")); // run a cleanup Thread.sleep(2); binaryStore().removeValuesUnusedLongerThan(1, TimeUnit.MILLISECONDS); // check that the binaries have been removed assertEquals("There should be no binaries in store", 0, binariesCount()); // discard all previous changes session.refresh(false); // upload a new file tools.uploadFile(session, "/file3.txt", resourceStream("io/file3.txt")); // and save session.save(); // now check there is a binary assertEquals(1, binariesCount()); // run a cleanup Thread.sleep(2); binaryStore().removeValuesUnusedLongerThan(1, TimeUnit.MILLISECONDS); //check the binary are still there assertEquals(1, binariesCount()); }
/** * Verify that it is possible to copy a (proxy) node in a shared set. * * @throws RepositoryException */ @Test public void shouldAllowingCopyingSharedNode() throws RepositoryException { String originalPath = "/Cars/Utility"; String sharedPath = "/NewArea/SharedUtility"; // Make the original a shareable node ... Node original = makeShareable(originalPath); session.save(); // Now create the share ... Node sharedNode = makeShare(originalPath, sharedPath); assertSharedSetIncludes(original, originalPath, sharedPath); assertSharedSetIncludes(sharedNode, originalPath, sharedPath); // Now move the new shared node ... workspace.copy("/NewArea", "/NewSecondArea/NewArea"); // Verify ... String copiedSharedPath = "/NewSecondArea" + sharedPath; session.refresh(false); Node node = session.getNode(copiedSharedPath); assertSharedSetIncludes(original, originalPath, sharedPath, copiedSharedPath); assertSharedSetIncludes(sharedNode, originalPath, sharedPath, copiedSharedPath); assertSharedSetIncludes(node, originalPath, sharedPath, copiedSharedPath); verifyShare(original, node); }