jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r480938 - /jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/
Date Thu, 30 Nov 2006 14:23:45 GMT
Author: mreutegg
Date: Thu Nov 30 06:23:44 2006
New Revision: 480938

URL: http://svn.apache.org/viewvc?view=rev&rev=480938
Log:
JCR-654: Some implementations require a save() after a mixin has been assigned

Modified:
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeAddMixinTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeUUIDTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/ReferencesTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SessionUUIDTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeAddMixinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeAddMixinTest.java?view=diff&rev=480938&r1=480937&r2=480938
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeAddMixinTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeAddMixinTest.java
Thu Nov 30 06:23:44 2006
@@ -61,8 +61,7 @@
         // test if mixin is written to property jcr:mixinTypes immediately
         Value mixinValues[] = node.getProperty(jcrMixinTypes).getValues();
         if (mixinValues.length != 1) {
-            fail("Mixin node must be added to property " +
-                    jcrMixinTypes + " immediately.");
+            fail("Mixin node must be added to property " + jcrMixinTypes + " immediately.");
         }
         assertEquals("Mixin was not properly assigned to property " + jcrMixinTypes + ":
",
                 mixinName,
@@ -151,7 +150,10 @@
             node2.lock(true, true);
 
             try {
+                // implementation specific: either throw LockException upon
+                // addMixin or upon save.
                 node.addMixin(mixinName);
+                node.save();
                 fail("Node.addMixin(String mixinName) must throw a LockException " +
                         "if the node is locked.");
             } catch (LockException e) {
@@ -225,6 +227,8 @@
         Node node = testRootNode.addNode(nodeName1, testNodeType);
 
         node.addMixin(mixReferenceable);
+        // implementation specific: mixin may take effect only upon save
+        testRootNode.save();
 
         // test if jcr:uuid is not null, empty or throws a exception
         // (format of value is not defined so we can only test if not empty)

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java?view=diff&rev=480938&r1=480937&r2=480938
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java
Thu Nov 30 06:23:44 2006
@@ -176,7 +176,10 @@
             node2.lock(true, true);
 
             try {
+                // remove mixin on locked node must throw either directly upon
+                // removeMixin or upon save.
                 node.removeMixin(mixinName);
+                node.save();
                 fail("Node.removeMixin(String mixinName) must throw a " +
                         "LockException if the node is locked.");
             } catch (LockException e) {

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeTest.java?view=diff&rev=480938&r1=480937&r2=480938
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeTest.java
Thu Nov 30 06:23:44 2006
@@ -693,8 +693,9 @@
 
             try {
                 subNode.remove();
-                fail("Node.remove() must throw a LockException if the parent " +
-                        "of the node is locked");
+                session.save();
+                fail("Removal of a Node must throw a LockException upon remove() " +
+                     "or upon save() if the parent of the node is locked");
             } catch (LockException e) {
                 // success
             }

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeUUIDTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeUUIDTest.java?view=diff&rev=480938&r1=480937&r2=480938
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeUUIDTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeUUIDTest.java
Thu Nov 30 06:23:44 2006
@@ -62,6 +62,9 @@
 
         // create a node with a jcr:uuid property to serve as target
         Node refTargetNode = defaultRootNode.addNode(nodeName2, getProperty("nodetype2"));
+        // make sure, mix:referenceable is effective. some impls may require a save() call.
+        defaultRootNode.save();
+
 
         // set the reference
         referencingNode.setProperty(propertyName1, refTargetNode);
@@ -146,4 +149,4 @@
             throw new NotExecutableException("Repository does not support mix:referenceable");
         }
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/ReferencesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/ReferencesTest.java?view=diff&rev=480938&r1=480937&r2=480938
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/ReferencesTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/ReferencesTest.java
Thu Nov 30 06:23:44 2006
@@ -36,7 +36,10 @@
     public void testReferences() throws RepositoryException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
 	n1.addMixin(mixReferenceable);
-	// create references: n2.p1 -> n1
+        // with some impls. the mixin type has only affect upon save
+        testRootNode.save();
+
+        // create references: n2.p1 -> n1
 	Node n2 = testRootNode.addNode(nodeName2, testNodeType);
 	Property p1 = n2.setProperty(propertyName1, new Value[]{superuser.getValueFactory().createValue(n1)});
 	testRootNode.save();
@@ -97,7 +100,10 @@
     public void testReferenceTarget() throws RepositoryException {
 	Node n1 = testRootNode.addNode(nodeName1, testNodeType);
 	n1.addMixin(mixReferenceable);
-	// create references: n2.p1 -> n1
+        // with some impls. the mixin type has only affect upon save
+        testRootNode.save();
+
+        // create references: n2.p1 -> n1
 	Node n2 = testRootNode.addNode(nodeName2, testNodeType);
 	n2.setProperty(propertyName1, n1);
 	testRootNode.save();
@@ -114,7 +120,10 @@
 	n1.addMixin(mixReferenceable);
 	Node n2 = testRootNode.addNode(nodeName2, testNodeType);
 	n2.addMixin(mixReferenceable);
-	// create references: n3.p1 -> n1
+        // with some impls. the mixin type has only affect upon save
+        testRootNode.save();
+
+        // create references: n3.p1 -> n1
 	Node n3 = testRootNode.addNode(nodeName3, testNodeType);
 	n3.setProperty(propertyName1, n1);
 	testRootNode.save();
@@ -153,6 +162,5 @@
 	if (iter.hasNext()) {
 	    fail("too many referers: " + iter.nextProperty().getPath());
 	}
-
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SessionUUIDTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SessionUUIDTest.java?view=diff&rev=480938&r1=480937&r2=480938
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SessionUUIDTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SessionUUIDTest.java
Thu Nov 30 06:23:44 2006
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.test.api;
 
 import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
@@ -50,7 +51,7 @@
      * <li><code>javax.jcr.tck.SessionUUIDTest.nodetype2</code> must have
the mixin type <code>mix:referenceable</code> assigned.</li>
      * </ul>
      */
-    public void testSaveReferentialIntegrityException() throws RepositoryException {
+    public void testSaveReferentialIntegrityException() throws RepositoryException, NotExecutableException
{
         // get default workspace test root node using superuser session
         Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
 
@@ -59,6 +60,12 @@
 
         // create a node with a jcr:uuid property to serve as target
         Node refTargetNode = defaultRootNode.addNode(nodeName2, getProperty("nodetype2"));
+        // implementations may only have the mix:referenceable active upon save
+        defaultRootNode.save();
+
+        if (!refTargetNode.isNodeType(mixReferenceable)) {
+            throw new NotExecutableException("Cannot test referential integrity. Node is
not referenceable.");
+        }
 
         // set the reference
         referencingNode.setProperty(propertyName1, refTargetNode);
@@ -97,7 +104,7 @@
      * name of a property that can be modified in <code>nodetype2</code> for
testing</li>
      * </ul>
      */
-    public void testSaveMovedRefNode() throws RepositoryException {
+    public void testSaveMovedRefNode() throws RepositoryException, NotExecutableException
{
         // get default workspace test root node using superuser session
         Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
 
@@ -110,6 +117,10 @@
         // save the new nodes
         superuser.save();
 
+        if (!refTargetNode.isNodeType(mixReferenceable)) {
+            throw new NotExecutableException("Cannot test referential integrity. Node is
not referenceable.");
+        }
+
         // get the moving node with session 2
         Session testSession = helper.getReadWriteSession();
 
@@ -133,4 +144,4 @@
             testSession.logout();
         }
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java?view=diff&rev=480938&r1=480937&r2=480938
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java
Thu Nov 30 06:23:44 2006
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.test.api;
 
 import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
 
 import javax.jcr.Node;
 
@@ -42,6 +43,21 @@
 
         n1 = testRootNode.addNode(nodeName2, testNodeType);
         n2 = testRootNode.addNode(nodeName3, testNodeType);
+        /*
+        JSR170 section 4.9 Referenceable Nodes:
+        The UUID of a referenceable node is assigned on node creation (or at
+        least on node persistence) by the system itself.
+        => call save in order to make sure, that the uuid is created and contains
+           a value generated by the system.
+        */
+        testRootNode.save();
+
+        if (!n1.isNodeType(mixReferenceable)) {
+            throw new NotExecutableException("Node " + nodeName2 + " with nodetype " + testNodeType
+ " is not mix:referenceable.");
+        }
+        if (!n2.isNodeType(mixReferenceable)) {
+            throw new NotExecutableException("Node " + nodeName3 + " with nodetype " + testNodeType
+ " is not mix:referenceable.");
+        }
     }
 
     /**
@@ -124,4 +140,4 @@
                 testNode.hasProperty(propertyName1));
     }
 
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java?view=diff&rev=480938&r1=480937&r2=480938
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java
Thu Nov 30 06:23:44 2006
@@ -148,6 +148,8 @@
         }
         if (n.canAddMixin(mixReferenceable)) {
             n.addMixin(mixReferenceable);
+            // some implementations may require a save after addMixin()
+            n.getSession().save();
         } else {
             throw new NotExecutableException("Node is not referenceable: " + n.getPath());
         }

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java?view=diff&rev=480938&r1=480937&r2=480938
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java
Thu Nov 30 06:23:44 2006
@@ -267,6 +267,8 @@
         // create a referenceable node
         Node referenceableNode = testRootNode.addNode(nodeName3);
         referenceableNode.addMixin(mixReferenceable);
+        // implementation specific if mixin takes effect immediately or upon save
+        testRootNode.save();
 
         String refPropName = getProperty("propertyname3");
         String nodeType = getProperty("nodetype2");
@@ -283,7 +285,6 @@
         }
 
         Property property = node.setProperty(refPropName, referenceableNode);
-
         testRootNode.save();
 
         node.checkin();



Mime
View raw message