You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2025/04/03 11:02:52 UTC
(jackrabbit) branch JCR-5138 created (now 9d4fa44fe)
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a change to branch JCR-5138
in repository https://gitbox.apache.org/repos/asf/jackrabbit.git
at 9d4fa44fe JCR-5138: Borrow JackrabbitSessionImpl tests from Oak
This branch includes the following new commits:
new 9d4fa44fe JCR-5138: Borrow JackrabbitSessionImpl tests from Oak
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(jackrabbit) 01/01: JCR-5138: Borrow JackrabbitSessionImpl tests from Oak
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch JCR-5138
in repository https://gitbox.apache.org/repos/asf/jackrabbit.git
commit 9d4fa44fedbd61067a698a636a35cc52768e1816
Author: Julian Reschke <re...@apache.org>
AuthorDate: Thu Apr 3 12:02:18 2025 +0100
JCR-5138: Borrow JackrabbitSessionImpl tests from Oak
---
.../jackrabbit/api/JackrabbitSessionTest.java | 112 +++++++++++++++++++++
1 file changed, 112 insertions(+)
diff --git a/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/JackrabbitSessionTest.java b/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/JackrabbitSessionTest.java
new file mode 100644
index 000000000..90d9140a1
--- /dev/null
+++ b/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/JackrabbitSessionTest.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.api;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.junit.Ignore;
+
+import javax.jcr.GuestCredentials;
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+
+import java.util.Arrays;
+
+import static org.mockito.Mockito.mock;
+
+// copied from org.apache.jackrabbit.oak.jcr.session.JackrabbitSessionTest
+// please keep in sync
+
+public class JackrabbitSessionTest extends AbstractJCRTest {
+
+ private JackrabbitSession s;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ if (superuser instanceof JackrabbitSession) {
+ s = (JackrabbitSession) superuser;
+ } else {
+ throw new NotExecutableException("JackrabbitSession expected");
+ }
+ }
+
+ public void testGetParentOrNullRootNode() throws Exception {
+ assertNull(s.getParentOrNull(s.getRootNode()));
+ }
+
+ public void testGetParentOrNull() throws Exception {
+ Node n = s.getNode(testRoot);
+ assertEquivalentNode(n, s.getParentOrNull(n.getProperty(Property.JCR_PRIMARY_TYPE)));
+ assertEquivalentNode(n.getParent(), s.getParentOrNull(n));
+ }
+
+ private static void assertEquivalentNode(Node expected, Node result) throws Exception {
+ assertNotNull(result);
+ assertEquals(expected.getPath(), result.getPath());
+ }
+
+ @Ignore("Jackrabbit does not check session identity")
+ public void testGetParentOrNullSessionMismatch() throws Exception {
+ JackrabbitSession guest = (JackrabbitSession) getHelper().getRepository().login(new GuestCredentials());
+ try {
+ guest.getParentOrNull(s.getNode(testRoot));
+ fail("RepositoryException expected");
+ } catch (RepositoryException e) {
+ fail("got " + Arrays.asList(e.getStackTrace()));
+ } finally {
+ guest.logout();
+ }
+ }
+
+ @Ignore("Jackrabbit does not very Item implementation being Jackrabbit's")
+ public void testGetParentOrNullImplMismatch() {
+ try {
+ Item item = mock(Item.class);
+ s.getParentOrNull(item);
+ fail("RepositoryException expected");
+ } catch (RepositoryException e) {
+ fail("got " + Arrays.asList(e.getStackTrace()));
+ }
+ }
+
+ @Ignore("JCR-5137")
+ public void testGetExpandedName() throws RepositoryException {
+ // empty namespace uri
+ assertEquals("{}testroot", s.getExpandedName(testRootNode));
+ Node n = testRootNode.addNode("test:bar");
+ assertEquals("{http://www.apache.org/jackrabbit/test}bar", s.getExpandedName(n));
+ // now remap namespace uri
+ s.setNamespacePrefix("test", "urn:foo");
+ assertEquals("{urn:foo}bar", s.getExpandedName(n));
+ // use special namespace uri
+ n = testRootNode.addNode("rep:bar");
+ assertEquals("{internal}bar", s.getExpandedName(n));
+ }
+
+ @Ignore("JCR-5137")
+ public void testGetExpandedPath() throws RepositoryException {
+ assertEquals("/{}testroot", s.getExpandedPath(testRootNode));
+ Node n = testRootNode.addNode("test:bar").addNode("rep:bar");
+ assertEquals("/{}testroot/{http://www.apache.org/jackrabbit/test}bar/{internal}bar", s.getExpandedPath(n));
+ // now remap namespace uri
+ s.setNamespacePrefix("test", "urn:foo");
+ assertEquals("/{}testroot/{urn:foo}bar/{internal}bar", s.getExpandedPath(n));
+ }
+}
\ No newline at end of file