/** * @param version the version for which the frozen node should be returned * @return the frozen node for the given version * @throws RepositoryException if an error occurs accessing the repository */ AbstractJcrNode frozenNodeFor( Version version ) throws RepositoryException { return ((AbstractJcrNode)version).getNode(JcrLexicon.FROZEN_NODE); }
/** * @param version the version for which the frozen node should be returned * @return the frozen node for the given version * @throws RepositoryException if an error occurs accessing the repository */ AbstractJcrNode frozenNodeFor( Version version ) throws RepositoryException { return ((AbstractJcrNode)version).getNode(JcrLexicon.FROZEN_NODE); }
@Test public void shouldMoveToNewName() throws Exception { initializeData(); session.move("/a/b/c", "/a/b/d"); session.getRootNode().getNode("a").getNode("b").getNode("d"); try { session.getRootNode().getNode("a").getNode("b").getNode("c"); fail("Node still exists at /a/b/c after move"); } catch (PathNotFoundException e) { // Expected } }
@SuppressWarnings( "deprecation" ) @Test( expected = UnsupportedRepositoryOperationException.class ) public void shouldNotProvideUuidIfNotReferenceable() throws Exception { initializeData(); // The b node was not set up to be referenceable in this test, but does have a mixin type Node node = session.getRootNode().getNode("a").getNode("b").getNode("c"); node.getUUID(); }
@SuppressWarnings( "deprecation" ) @Test( expected = UnsupportedRepositoryOperationException.class ) public void shouldNotProvideUuidIfNoMixinTypes() throws Exception { initializeData(); // The c node was not set up to be referenceable in this test and has no mixin types Node node = session.getRootNode().getNode("a").getNode("b").getNode("c"); node.getUUID(); }
@Test public void shouldProvideIdentifierEvenIfNotReferenceable() throws Exception { initializeData(); // The b node was not set up to be referenceable in this test, but does have a mixin type Node node = session.getRootNode().getNode("a").getNode("b").getNode("c"); assertThat(node.getIdentifier(), is(notNullValue())); }
@Test public void shouldProvideIdentifierEvenIfNoMixinTypes() throws Exception { initializeData(); // The b node was not set up to be referenceable in this test, but does have a mixin type Node node = session.getRootNode().getNode("a").getNode("b").getNode("c"); assertThat(node.getIdentifier(), is(notNullValue())); }
@Test @FixFor( "MODE-2489" ) public void shouldSupportNameBasedTypeDetection() throws Exception { startRepositoryWithConfigurationFrom("config/repo-config-name-mimetype-detection.json"); tools.uploadFile(session, "/file1", resourceStream("io/file1.txt")); tools.uploadFile(session, "/file2.txt", resourceStream("io/file2.txt")); session.save(); Node content1 = session.getNode("/file1").getNode("jcr:content"); // because the name of the file does not have an extension, we're expecting a generic mime type here assertEquals("application/octet-stream", content1.getProperty("jcr:mimeType").getString()); Node content2 = session.getNode("/file2.txt").getNode("jcr:content"); // because the name of the file doe have an extension, we're expecting a specific mime type here assertEquals("text/plain", content2.getProperty("jcr:mimeType").getString()); }
@Test @FixFor( "MODE-2489" ) public void shouldSupportContentBasedTypeDetection() throws Exception { startRepositoryWithConfigurationFrom("config/repo-config-binaries-fs.json"); // upload 2 binaries but don't save tools.uploadFile(session, "/file1", resourceStream("io/file1.txt")); tools.uploadFile(session, "/file2", resourceStream("io/binary.pdf")); session.save(); Node content1 = session.getNode("/file1").getNode("jcr:content"); // even though the name of the file has no extension, full content based extraction should've been performed assertEquals(MediaType.TEXT_PLAIN.toString(), content1.getProperty("jcr:mimeType").getString()); Node content2 = session.getNode("/file2").getNode("jcr:content"); // even though the name of the file has no extension, full content based extraction should've been performed assertEquals("application/pdf", content2.getProperty("jcr:mimeType").getString()); }
@Test @FixFor( "MODE-2489" ) public void shouldSupportNoMimeTypeDetection() throws Exception { startRepositoryWithConfigurationFrom("config/repo-config-no-mimetype-detection.json"); // upload 2 binaries but don't save tools.uploadFile(session, "/file1.txt", resourceStream("io/file1.txt")); session.save(); Node content = session.getNode("/file1.txt").getNode("jcr:content"); try { content.getProperty("jcr:mimeType"); fail("No mimetype should have been extracted"); } catch (PathNotFoundException e) { //expected } }
@Override @Before public void beforeEach() throws Exception { super.beforeEach(); session2 = repository.login("workspace2"); rootNode = session.getRootNode(); cars = session.getNode("/Cars"); prius = session.getNode("/Cars/Hybrid/Toyota Prius"); altima = session.getNode("/Cars/Hybrid/Nissan Altima"); altimaModel = altima.getProperty("car:model"); binaryProp = rootNode.getNode("nodeWithBinaryProperty").getProperty("binProp"); assertThat(rootNode, is(notNullValue())); assertThat(cars, is(notNullValue())); assertThat(prius, is(notNullValue())); assertThat(altima, is(notNullValue())); assertThat(altimaModel, is(notNullValue())); assertThat(binaryProp, is(notNullValue())); prius2 = session2.getNode("/Cars/Hybrid/Toyota Prius"); assertThat(prius2, is(notNullValue())); }