jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1453337 - /jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
Date Wed, 06 Mar 2013 14:13:16 GMT
Author: alexparvulescu
Date: Wed Mar  6 14:13:15 2013
New Revision: 1453337

URL: http://svn.apache.org/r1453337
Log:
OAK-14 Identify and document changes in behaviour wrt. Jackrabbit 2

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java?rev=1453337&r1=1453336&r2=1453337&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java
Wed Mar  6 14:13:15 2013
@@ -20,6 +20,7 @@ import javax.jcr.InvalidItemStateExcepti
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.nodetype.ConstraintViolationException;
 
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
@@ -35,7 +36,8 @@ import static org.junit.Assert.fail;
 
 /**
  * This class contains test cases which demonstrate changes in behaviour wrt. to Jackrabbit
2.
- * See OAK-14: Identify and document changes in behaviour wrt. Jackrabbit 2
+ * 
+ * @see <a href="https://issues.apache.org/jira/browse/OAK-14">OAK-14: Identify and
document changes in behaviour wrt. Jackrabbit 2</a>
  */
 public class CompatibilityIssuesTest extends AbstractRepositoryTest {
 
@@ -141,4 +143,54 @@ public class CompatibilityIssuesTest ext
         assertEquals("", x.getParent().getName());      // fails on JR2, passes on Oak
     }
 
+    /**
+     * Type checks are deferred to the Session#save call instead of the
+     * Node#addNode method like in Jackrabbit2.
+     * <p>Stacktrace in JR2:</p>
+     * <pre>
+     * {@code
+     * javax.jcr.nodetype.ConstraintViolationException: No child node definition for fail
found in node /f1362578560413
+     *     at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1276)
+     *     at org.apache.jackrabbit.core.session.AddNodeOperation.perform(AddNodeOperation.java:111)
+     *     at org.apache.jackrabbit.core.session.AddNodeOperation.perform(AddNodeOperation.java:1)
+     *     at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:216)
+     *     at org.apache.jackrabbit.core.ItemImpl.perform(ItemImpl.java:91)
+     *     at org.apache.jackrabbit.core.NodeImpl.addNodeWithUuid(NodeImpl.java:1814)
+     *     at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1774)
+     * }
+     * <pre>
+     * <p>Stacktrace in Oak:</p>
+     * <pre>
+     * {@code
+     *javax.jcr.nodetype.ConstraintViolationException
+     *    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
+     *    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
+     *    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
+     *    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
+     *    at org.apache.jackrabbit.oak.api.CommitFailedException.throwRepositoryException(CommitFailedException.java:57)
+     *    at org.apache.jackrabbit.oak.jcr.SessionDelegate.save(SessionDelegate.java:258)
+     *    at org.apache.jackrabbit.oak.jcr.SessionImpl.save(SessionImpl.java:277)
+     *    ...
+     *Caused by: org.apache.jackrabbit.oak.api.CommitFailedException: Cannot add node 'f1362578685631'
at /
+     *    at org.apache.jackrabbit.oak.plugins.nodetype.TypeValidator.childNodeAdded(TypeValidator.java:128)
+     *    at org.apache.jackrabbit.oak.spi.commit.CompositeValidator.childNodeAdded(CompositeValidator.java:68)
+     *    at org.apache.jackrabbit.oak.spi.commit.ValidatingHook$ValidatorDiff.childNodeAdded(ValidatingHook.java:159)
+     *    at org.apache.jackrabbit.oak.core.RootImpl.commit(RootImpl.java:250)
+     *    at org.apache.jackrabbit.oak.jcr.SessionDelegate.save(SessionDelegate.java:255)
+     *    ...
+     *Caused by: javax.jcr.nodetype.ConstraintViolationException: Node 'jcr:content' in 'nt:file'
is mandatory
+     *    at org.apache.jackrabbit.oak.plugins.nodetype.EffectiveNodeTypeImpl.checkMandatoryItems(EffectiveNodeTypeImpl.java:288)
+     *    at org.apache.jackrabbit.oak.plugins.nodetype.TypeValidator.childNodeAdded(TypeValidator.java:125)
+     *    ...
+     * }
+     * <pre>
+     */
+    @Test(expected = ConstraintViolationException.class)
+    public void typeChecksOnSave() throws RepositoryException {
+        Session session = getAdminSession();
+        Node f = session.getNode("/").addNode("f" + System.currentTimeMillis(), "nt:file");
+        f.addNode("fail", "nt:unstructured"); // this is where JR2 throws ConstraintViolationException
+        session.save(); // // this is where OAK throws ConstraintViolationException
+    }
+
 }



Mime
View raw message