jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r792142 [20/35] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/ jackrabbit-core/ jackrabbit-core/src/main/java/org/apache/jackrab...
Date Wed, 08 Jul 2009 13:57:46 GMT
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionUUIDTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionUUIDTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionUUIDTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionUUIDTest.java Wed Jul  8 13:57:13 2009
@@ -129,7 +129,7 @@
         }
 
         // get the moving node with session 2
-        Session testSession = helper.getReadWriteSession();
+        Session testSession = getHelper().getReadWriteSession();
 
         try {
             Node refTargetNodeSession2 = (Node) testSession.getItem(refTargetNode.getPath());

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java Wed Jul  8 13:57:13 2009
@@ -374,7 +374,8 @@
         setUpNodeWithUndefinedProperty(false);
 
         Node referenceableNode = testRootNode.addNode(nodeName2);
-        referenceableNode.addMixin(mixReferenceable);
+        ensureMixinType(referenceableNode, mixReferenceable);
+
         // some implementations may require a save after addMixin()
         testRootNode.save();
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java Wed Jul  8 13:57:13 2009
@@ -19,7 +19,6 @@
 import org.apache.jackrabbit.test.AbstractJCRTest;
 
 import javax.jcr.Node;
-import javax.jcr.ValueFactory;
 
 import java.util.Calendar;
 import java.util.GregorianCalendar;
@@ -37,20 +36,16 @@
 
     private Node testNode;
 
-    private ValueFactory vFactory;
-
     private Calendar c1 = new GregorianCalendar(2005, 1, 10, 14, 8, 56);
     private Calendar c2 = new GregorianCalendar(1945, 1, 6, 16, 20, 0);
 
     protected void setUp() throws Exception {
         super.setUp();
         testNode = testRootNode.addNode(nodeName1, testNodeType);
-        vFactory = superuser.getValueFactory();
     }
 
     protected void tearDown() throws Exception {
         testNode = null;
-        vFactory = null;
         super.tearDown();
     }
 
@@ -62,7 +57,7 @@
         testNode.setProperty(propertyName1, c1);
         superuser.save();
         assertEquals("Setting property with Node.setProperty(String, Calendar) and Session.save() not working",
-                vFactory.createValue(c1),
+                vf.createValue(c1),
                 testNode.getProperty(propertyName1).getValue());
     }
 
@@ -76,7 +71,7 @@
         testNode.setProperty(propertyName1, c2);
         superuser.save();
         assertEquals("Modifying property with Node.setProperty(String, Calendar) and Session.save() not working",
-                vFactory.createValue(c2),
+                vf.createValue(c2),
                 testNode.getProperty(propertyName1).getValue());
     }
 
@@ -88,7 +83,7 @@
         testNode.setProperty(propertyName1, c1);
         testRootNode.save();
         assertEquals("Setting property with Node.setProperty(String, Calendar) and parentNode.save() not working",
-                vFactory.createValue(c1),
+                vf.createValue(c1),
                 testNode.getProperty(propertyName1).getValue());
     }
 
@@ -102,7 +97,7 @@
         testNode.setProperty(propertyName1, c2);
         testRootNode.save();
         assertEquals("Modifying property with Node.setProperty(String, Calendar) and parentNode.save() not working",
-                vFactory.createValue(c2),
+                vf.createValue(c2),
                 testNode.getProperty(propertyName1).getValue());
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java Wed Jul  8 13:57:13 2009
@@ -397,7 +397,7 @@
 
             // create a referenceable node not satisfying the constraint
             nodeNotSatisfied = testRootNode.addNode(nodeName4, nodeTypeNotSatisfied);
-            nodeNotSatisfied.addMixin(mixReferenceable);
+            ensureMixinType(nodeNotSatisfied, mixReferenceable);
 
             testRootNode.save();
         } catch (ConstraintViolationException e) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueBinaryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueBinaryTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueBinaryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueBinaryTest.java Wed Jul  8 13:57:13 2009
@@ -19,14 +19,16 @@
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.apache.jackrabbit.test.NotExecutableException;
 
-import javax.jcr.Property;
-import javax.jcr.Value;
-import javax.jcr.RepositoryException;
-import javax.jcr.Node;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.IOException;
 
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+
 /**
  * Tests the various {@link Property#setValue(Value)} methods.
  * <p>
@@ -113,6 +115,26 @@
     }
 
     /**
+     * Test the persistence of a property modified with an BinaryValue parameter
+     * and saved from the Session
+     */
+    public void testBinarySessionJcr2() throws RepositoryException, IOException {
+        property1.setValue(value);
+        superuser.save();
+        Binary bin = property1.getValue().getBinary();
+        try {
+            InputStream in = bin.getStream();
+            try {
+                compareStream(data, in);
+            } finally {
+                in.close();
+            }
+        } finally {
+            bin.dispose();
+        }
+    }
+
+    /**
      * Test the persistence of a property modified with an input stream
      * parameter and saved from the parent Node
      */
@@ -133,6 +155,27 @@
     }
 
     /**
+     * Test the persistence of a property modified with an input stream
+     * parameter and saved from the parent Node
+     */
+    public void testBinaryParentJcr2() throws RepositoryException, IOException {
+        Binary bin = value.getBinary();
+        try {
+            property1.setValue(bin);
+            node.save();
+            bin = property1.getValue().getBinary();
+            InputStream in = bin.getStream();
+            try {
+                compareStream(data, in);
+            } finally {
+                in.close();
+            }
+        } finally {
+            bin.dispose();
+        }
+    }
+
+    /**
      * Test the deletion of a property by assigning it a null value, saved from
      * the Session
      */

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java Wed Jul  8 13:57:13 2009
@@ -442,11 +442,11 @@
 
             // create a referenceable node satisfying the constraint
             nodeSatisfied = testRootNode.addNode(nodeName3, nodeTypeSatisfied);
-            nodeSatisfied.addMixin(mixReferenceable);
+            ensureMixinType(nodeSatisfied, mixReferenceable);
 
             // create a referenceable node not satisfying the constraint
             nodeNotSatisfied = testRootNode.addNode(nodeName4, nodeTypeNotSatisfied);
-            nodeNotSatisfied.addMixin(mixReferenceable);
+            ensureMixinType(nodeNotSatisfied, mixReferenceable);
 
             // some implementations may require a save after addMixin()
             testRootNode.save();
@@ -814,11 +814,11 @@
 
             // create a referenceable node satisfying the constraint
             nodeSatisfied = testRootNode.addNode(nodeName3, nodeTypeSatisfied);
-            nodeSatisfied.addMixin(mixReferenceable);
+            ensureMixinType(nodeSatisfied, mixReferenceable);
 
             // create a referenceable node not satisfying the constraint
             nodeNotSatisfied = testRootNode.addNode(nodeName4, nodeTypeNotSatisfied);
-            nodeNotSatisfied.addMixin(mixReferenceable);
+            ensureMixinType(nodeNotSatisfied, mixReferenceable);
 
             // some implementations may require a save after addMixin()
             testRootNode.save();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java Wed Jul  8 13:57:13 2009
@@ -152,15 +152,7 @@
      *                                referenceable nodes.
      */
     private void ensureReferenceable(Node n) throws RepositoryException, NotExecutableException {
-        if (n.isNodeType(mixReferenceable)) {
-            return;
-        }
-        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());
-        }
+        ensureMixinType(n, mixReferenceable);
+        n.getSession().save();
     }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueValueFormatExceptionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueValueFormatExceptionTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueValueFormatExceptionTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueValueFormatExceptionTest.java Wed Jul  8 13:57:13 2009
@@ -213,7 +213,7 @@
         try {
             Node referenceableNode = testRootNode.addNode(nodeName3, testNodeType);
             if (needsMixin(referenceableNode, mixReferenceable)) {
-                referenceableNode.addMixin(mixReferenceable);
+                ensureMixinType(referenceableNode, mixReferenceable);
             }
 
             // some implementations may require a save after addMixin()

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java Wed Jul  8 13:57:13 2009
@@ -58,7 +58,7 @@
      */
     protected void setUp() throws Exception {
         super.setUp();
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
 
         value = session.getValueFactory().createValue("abc");
         values = new Value[] {value};
@@ -70,13 +70,7 @@
         // create a node that is versionable
         node = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it versionable if it is not
-        if (!node.isNodeType(mixVersionable)) {
-            if (node.canAddMixin(mixVersionable)) {
-                node.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException("Failed to set up required test items");
-            }
-        }
+        ensureMixinType(node, mixVersionable);
 
         property = node.setProperty(propertyName1, value);
         multiProperty = node.setProperty(propertyName2, values);
@@ -280,13 +274,7 @@
             : testRootNode.addNode(nodeName3, nodeType3);
 
         // try to make it referenceable if it is not
-        if (!referenceableNode.isNodeType(mixReferenceable)) {
-            if (referenceableNode.canAddMixin(mixReferenceable)) {
-              referenceableNode.addMixin(mixReferenceable);
-            } else {
-                throw new NotExecutableException("Failed to set up required test items.");
-            }
-        }
+        ensureMixinType(referenceableNode, mixReferenceable);
 
         // implementation specific if mixin takes effect immediately or upon save
         testRootNode.save();
@@ -297,13 +285,7 @@
         Node node = testRootNode.addNode(nodeName4, nodeType);
 
         // try to make it versionable if it is not
-        if (!node.isNodeType(mixVersionable)) {
-            if (node.canAddMixin(mixVersionable)) {
-                node.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException("Failed to set up required test items.");
-            }
-        }
+        ensureMixinType(node, mixVersionable);
 
         // fail early when reference properties are not suppoerted
         ensureCanSetProperty(node, refPropName, node.getSession().getValueFactory().createValue(referenceableNode));

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java Wed Jul  8 13:57:13 2009
@@ -43,11 +43,14 @@
  * Tests features available with shareable nodes.
  */
 public class ShareableNodeTest extends AbstractJCRTest {
-    
+
+    private String mixShareable;
+
     protected void setUp() throws Exception {
         super.setUp();
         checkSupportedOption(Repository.OPTION_SHAREABLE_NODES_SUPPORTED);
-        ensureKnowsNodeType(superuser, "mix:shareable");
+        ensureKnowsNodeType(superuser, mixShareable);
+        mixShareable = superuser.getNamespacePrefix(NS_MIX_URI) + ":shareable";
     }
 
     protected void tearDown() throws Exception {
@@ -70,7 +73,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -100,7 +103,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -130,7 +133,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -160,7 +163,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -189,7 +192,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -220,7 +223,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -250,7 +253,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -272,7 +275,7 @@
         Node b = a.addNode("b");
         testRootNode.save();
 
-        b.addMixin("mix:shareable");
+        ensureMixinType(b, mixShareable);
         b.save();
     }
 
@@ -287,7 +290,7 @@
         testRootNode.save();
 
         // make b1 shareable
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -296,7 +299,7 @@
                 a2.getPath() + "/b2", false);
 
         // make a2 versionable
-        a2.addMixin("mix:versionable");
+        ensureMixinType(a2, mixVersionable);
         a2.save();
 
         // check in version and check out again
@@ -331,7 +334,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -365,7 +368,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -395,7 +398,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -427,7 +430,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -457,7 +460,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -493,7 +496,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -532,7 +535,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         Workspace workspace = b1.getSession().getWorkspace();
@@ -558,7 +561,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -594,7 +597,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -638,7 +641,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -692,7 +695,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -749,7 +752,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -806,7 +809,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -864,7 +867,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -913,14 +916,14 @@
     public void testLock() throws Exception {
         // setup parent nodes and first child
         Node a1 = testRootNode.addNode("a1");
-        a1.addMixin("mix:lockable");
+        ensureMixinType(a1, mixLockable);
         Node a2 = testRootNode.addNode("a2");
         Node b1 = a1.addNode("b1");
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
-        b1.addMixin("mix:lockable");
+        ensureMixinType(b1, mixShareable);
+        ensureMixinType(b1, mixLockable);
         b1.save();
 
         // add child c
@@ -968,7 +971,7 @@
         testRootNode.save();
 
         // make b1 shareable
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -981,7 +984,7 @@
         b1.save();
 
         // make a2 versionable
-        a2.addMixin("mix:versionable");
+        ensureMixinType(a2, mixVersionable);
         a2.save();
 
         // check in version and check out again
@@ -1031,7 +1034,7 @@
         }
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone (2nd attempt, with mix:shareable)
@@ -1051,7 +1054,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -1080,12 +1083,12 @@
         testRootNode.save();
 
         // add mixin
-        b.addMixin("mix:shareable");
+        ensureMixinType(b, mixShareable);
         b.save();
 
         try {
             // remove mixin
-            b.removeMixin("mix:shareable");
+            b.removeMixin(mixShareable);
             b.save();
             fail("Removing mix:shareable should fail.");
         } catch (UnsupportedRepositoryOperationException e) {
@@ -1105,7 +1108,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -1115,7 +1118,7 @@
 
         // add new referenceable child
         Node c = b1.addNode("c");
-        c.addMixin(mixReferenceable);
+        ensureMixinType(c, mixReferenceable);
         b1.save();
 
         String sql = "SELECT * FROM nt:unstructured WHERE jcr:uuid = '"+c.getUUID()+"'";
@@ -1144,7 +1147,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         Workspace workspace = b1.getSession().getWorkspace();
@@ -1170,7 +1173,7 @@
         testRootNode.save();
 
         // add mixin
-        b.addMixin("mix:shareable");
+        ensureMixinType(b, mixShareable);
         b.save();
 
         // move
@@ -1197,7 +1200,7 @@
         testRootNode.save();
 
         // add mixin
-        b.addMixin("mix:shareable");
+        ensureMixinType(b, mixShareable);
         b.save();
 
         // move
@@ -1227,7 +1230,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -1262,7 +1265,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -1300,7 +1303,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -1334,7 +1337,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -1377,7 +1380,7 @@
         testRootNode.save();
 
         // add mixin
-        b.addMixin("mix:shareable");
+        ensureMixinType(b, mixShareable);
         b.save();
 
         Workspace workspace = b.getSession().getWorkspace();
@@ -1402,7 +1405,7 @@
        Node a1 = testRootNode.addNode("a1");
        Node a2 = a1.addNode("a2");
        Node b1 = a1.addNode("b1");
-       b1.addMixin("mix:shareable");
+       ensureMixinType(b1, mixShareable);
        testRootNode.save();
 
        //now we have a shareable node N with path a1/b1

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java Wed Jul  8 13:57:13 2009
@@ -84,6 +84,7 @@
         suite.addTestSuite(SetValueBinaryTest.class);
         suite.addTestSuite(SetValueBooleanTest.class);
         suite.addTestSuite(SetValueDateTest.class);
+        suite.addTestSuite(SetValueDecimalTest.class);
         suite.addTestSuite(SetValueDoubleTest.class);
         suite.addTestSuite(SetValueLongTest.class);
         suite.addTestSuite(SetValueReferenceTest.class);
@@ -94,6 +95,7 @@
 
         suite.addTestSuite(SetPropertyBooleanTest.class);
         suite.addTestSuite(SetPropertyCalendarTest.class);
+        suite.addTestSuite(SetPropertyDecimalTest.class);
         suite.addTestSuite(SetPropertyDoubleTest.class);
         suite.addTestSuite(SetPropertyInputStreamTest.class);
         suite.addTestSuite(SetPropertyLongTest.class);
@@ -112,6 +114,8 @@
         suite.addTestSuite(NodeCanAddMixinTest.class);
         suite.addTestSuite(NodeRemoveMixinTest.class);
 
+        suite.addTestSuite(NodeSetPrimaryTypeTest.class);
+
         suite.addTestSuite(WorkspaceCloneReferenceableTest.class);
         suite.addTestSuite(WorkspaceCloneSameNameSibsTest.class);
         suite.addTestSuite(WorkspaceCloneTest.class);
@@ -139,10 +143,14 @@
         suite.addTestSuite(ValueFactoryTest.class);
 
         // JCR 2.0
-        
+
+        //// new node types
+        suite.addTestSuite(GetWeakReferencesTest.class);
+
         //// new Session features
         
         suite.addTestSuite(SessionRemoveItemTest.class);
+        suite.addTestSuite(HasPermissionTest.class);
 
         //// new Workspace features
         

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TreeComparator.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TreeComparator.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TreeComparator.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TreeComparator.java Wed Jul  8 13:57:13 2009
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.test.api;
 
-import org.apache.jackrabbit.test.AbstractJCRTest;
-
 import javax.jcr.Session;
 import javax.jcr.Workspace;
 import javax.jcr.Item;
@@ -35,6 +33,8 @@
 import java.util.Calendar;
 import java.io.ByteArrayInputStream;
 
+import junit.framework.Assert;
+
 /**
  * <code>TreeComparator</code> compares two trees. This allows re-use for
  * different tests, and it allows to test a function on any tree, not just a
@@ -43,7 +43,8 @@
  * TreeComparator also creates an example tree that contains as many features as
  * possible.
  */
-class TreeComparator extends AbstractJCRTest {
+class TreeComparator extends Assert {
+
     public SerializationContext sc;
 
     public final boolean WORKSPACE = true;
@@ -64,18 +65,11 @@
 
     public TreeComparator(SerializationContext sc, Session s) throws Exception {
         this.sc = sc;
-        setUp();
         session = s;
         workspace = session.getWorkspace();
         init();
     }
 
-    public void tearDown() throws Exception {
-        session = null;
-        workspace = null;
-        super.tearDown();
-    }
-
     public void setSession(Session session) {
         this.session = session;
     }
@@ -132,13 +126,13 @@
         try {
             Node src = (Node) session.getItem(sourceFolder);
             Node root = src.addNode(sc.rootNodeName);
-            root.addNode(nodeName1);
-            root.addNode(nodeName2, testNodeType);
+            root.addNode(sc.nodeName1);
+            root.addNode(sc.nodeName2, sc.testNodeType);
             byte[] byteArray = {(byte) 0, (byte) 255, (byte) 167, (byte) 100, (byte) 21, (byte) 6, (byte) 19, (byte) 71, (byte) 221};
-            root.setProperty(propertyName1, new ByteArrayInputStream(byteArray));
-            root.setProperty(nodeName3, "hello");
+            root.setProperty(sc.propertyName1, new ByteArrayInputStream(byteArray));
+            root.setProperty(sc.nodeName3, "hello");
         } catch (Exception e) {
-            log.println("Error while creating example tree: " + e.getMessage());
+            sc.log("Error while creating example tree: " + e.getMessage());
         }
         if (save) {
             try {
@@ -181,7 +175,7 @@
             rootNode.addNode(sc.orderChildrenTestNode);
             rootNode.addNode(sc.namespaceTestNode);
         } catch (RepositoryException e) {
-            log.println("Error while creating example tree: " + e.getMessage());
+            sc.log("Error while creating example tree: " + e.getMessage());
         }
 
         // Add nodes with mixin types
@@ -205,14 +199,14 @@
                 // try saving, because some exceptions are trown only at save time
                 session.save();
             } catch (RepositoryException e) {
-                log.println("Cannot create node with mixin node type: " + e);
+                sc.log("Cannot create node with mixin node type: " + e);
                 // if saving failed for a node, then remove it again (or else the next save will fail on it)
                 try {
                     if (n != null) {
                         n.remove();
                     }
                 } catch (RepositoryException e1) {
-                    log.println("Could not remove node: " + e);
+                    sc.log("Could not remove node: " + e);
                 }
             }
         }
@@ -235,16 +229,14 @@
             // Boolean
             pt.setProperty(sc.booleanTestProperty, true);
             // Name
-            pt.setProperty(sc.nameTestProperty, superuser.getValueFactory().createValue(jcrPrimaryType, PropertyType.NAME));
+            pt.setProperty(sc.nameTestProperty, session.getValueFactory().createValue(sc.jcrPrimaryType, PropertyType.NAME));
             // Path
-            pt.setProperty(sc.pathTestProperty, superuser.getValueFactory().createValue("paths/dont/have/to/point/anywhere", PropertyType.PATH));
+            pt.setProperty(sc.pathTestProperty, session.getValueFactory().createValue("paths/dont/have/to/point/anywhere", PropertyType.PATH));
             // Reference: Note that I only check if the node exists. We do not specify what happens with
             // the UUID during serialization.
-            if (!referenceable.isNodeType(mixReferenceable)) {
-                referenceable.addMixin(mixReferenceable);
-                // some implementations may require a save after addMixin()
-                session.save();
-            }
+            sc.ensureMixinType(referenceable, sc.mixReferenceable);
+            // some implementations may require a save after addMixin()
+            session.save();
 
             pt.setProperty(sc.referenceTestProperty, referenceable);
 
@@ -261,7 +253,7 @@
             mvp.setProperty(sc.multiValueTestProperty, s);
             session.save();
         } catch (RepositoryException e) {
-            log.println("Could not create multi-value property: " + e);
+            sc.log("Could not create multi-value property: " + e);
         }
 
         // Save to the workspace. Note that export is from session anyway.
@@ -374,7 +366,7 @@
      */
     public void compareNodes(Node a, Node b) {
         try {
-            log.println("Comparing " + a.getPath() + " to " + b.getPath());
+            sc.log("Comparing " + a.getPath() + " to " + b.getPath());
         } catch (RepositoryException e) {
             fail("Nodes not available: " + e.getMessage());
         }
@@ -382,8 +374,8 @@
         // check primary node type
         String primaryTypeA = null, primaryTypeB = null;
         try {
-            primaryTypeA = a.getProperty(jcrPrimaryType).getName();
-            primaryTypeB = b.getProperty(jcrPrimaryType).getName();
+            primaryTypeA = a.getProperty(sc.jcrPrimaryType).getName();
+            primaryTypeB = b.getProperty(sc.jcrPrimaryType).getName();
         } catch (RepositoryException e) {
             fail("Primary node type not available: " + e);
         }
@@ -565,7 +557,7 @@
             n = (Node) session.getItem(sc.testroot);
             showTree(n, 0);
         } catch (RepositoryException e) {
-            log.println("Cannot display tree diagnostics: " + e);
+            sc.log("Cannot display tree diagnostics: " + e);
         }
     }
 
@@ -573,17 +565,19 @@
      * Recursive display of source and target tree
      */
     public void showTree(Node n, int level) throws RepositoryException {
+        StringBuffer sb = new StringBuffer();
         for (int t = 0; t < level; t++) {
-            log.print("-");
+            sb.append("-");
         }
-        log.print(n.getName() + " ");
-        log.print(n.getPrimaryNodeType().getName() + " [ ");
+        sb.append(n.getName() + " ");
+        sb.append(n.getPrimaryNodeType().getName() + " [ ");
         PropertyIterator pi = n.getProperties();
         while (pi.hasNext()) {
             Property p = (Property) pi.next();
-            log.print(p.getName() + " ");
+            sb.append(p.getName() + " ");
         }
-        log.println("]");
+        sb.append("]");
+        sc.log(sb.toString());
 
         NodeIterator ni = n.getNodes();
         while (ni.hasNext()) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java Wed Jul  8 13:57:13 2009
@@ -55,7 +55,7 @@
      * Tests that no actual property with type Undefined exists.
      */
     public void testUndefinedProperty() throws RepositoryException {
-        Session session = helper.getReadOnlySession();
+        Session session = getHelper().getReadOnlySession();
         try {
             Property prop = PropertyUtil.searchProp(session, session.getRootNode().getNode(testPath), PropertyType.UNDEFINED, null);
             assertNull("Property with type Undefined found.", prop);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ValueFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ValueFactoryTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ValueFactoryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ValueFactoryTest.java Wed Jul  8 13:57:13 2009
@@ -72,7 +72,7 @@
 
     public void setUp() throws Exception {
         super.setUp();
-        session = helper.getReadWriteSession();
+        session = getHelper().getReadWriteSession();
         try {
             valueFactory = session.getValueFactory();
         } catch (UnsupportedRepositoryOperationException e) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java Wed Jul  8 13:57:13 2009
@@ -20,6 +20,8 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.ItemExistsException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>WorkspaceCloneReferenceableTest</code> contains tests for cloning
  * referenceable nodes between workspaces.
@@ -36,7 +38,8 @@
      * that the new node in the destination workspcace has the same UUID as the
      * node in the source workspace.
      */
-    public void testCloneNodesReferenceableNodesOriginalUUID() throws RepositoryException {
+    public void testCloneNodesReferenceableNodesOriginalUUID() throws RepositoryException,
+            NotExecutableException {
         // add mixin referenceable to node1
         addMixinReferenceableToNode(node1);
 
@@ -60,7 +63,8 @@
      * will reflect the clones state in srcWorkspace, in other words the
      * existing node will be moved and changed.
      */
-    public void testCloneNodesRemoveExistingTrue() throws RepositoryException {
+    public void testCloneNodesRemoveExistingTrue() throws RepositoryException,
+            NotExecutableException {
         // add mixin referenceable to node1
         addMixinReferenceableToNode(node1);
 
@@ -83,7 +87,8 @@
      * If removeExisting is false then a UUID collision causes this method to
      * throw a ItemExistsException and no changes are made.
      */
-    public void testCloneNodesRemoveExistingFalse() throws RepositoryException {
+    public void testCloneNodesRemoveExistingFalse() throws RepositoryException,
+            NotExecutableException {
         // add mixin referenceable to node1
         addMixinReferenceableToNode(node1);
 
@@ -102,7 +107,8 @@
     /**
      * The clone method clones both referenceable and nonreferenceable nodes.
      */
-    public void testCloneNodesReferenceableAndNonreferenceable() throws RepositoryException {
+    public void testCloneNodesReferenceableAndNonreferenceable() throws RepositoryException,
+            NotExecutableException {
         // clone referenceable node
 
         // add mixin referenceable to node1

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneSameNameSibsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneSameNameSibsTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneSameNameSibsTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneSameNameSibsTest.java Wed Jul  8 13:57:13 2009
@@ -51,7 +51,7 @@
         int cnt = 0;
         NodeIterator iter = node2.getNodes();
         while (iter.hasNext()) {
-            Node n = (Node) iter.nextNode();
+            Node n = iter.nextNode();
 
             assertTrue(n.getName().equals(orderList[cnt]));
             cnt++;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java Wed Jul  8 13:57:13 2009
@@ -25,6 +25,8 @@
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.lock.LockException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>WorkspaceCloneTest</code> contains tests for cloning nodes between
  * workspace.
@@ -53,12 +55,13 @@
      * If successful, the changes are persisted immediately, there is no need to
      * call save.
      */
-    public void testCloneNodesTwice() throws RepositoryException {
+    public void testCloneNodesTwice() throws RepositoryException,
+            NotExecutableException {
         // clone referenceable node below non-referenceable node
         String dstAbsPath = node2W2.getPath() + "/" + node1.getName();
 
         Node folder = node1.addNode(nodeName3);
-        folder.addMixin(mixReferenceable);
+        ensureMixinType(folder, mixReferenceable);
         node1.save();
         workspaceW2.clone(workspace.getName(), node1.getPath(), dstAbsPath, true);
         workspaceW2.clone(workspace.getName(), node1.getPath(), dstAbsPath, true);
@@ -124,7 +127,7 @@
      */
     public void testCloneNodesAccessDenied() throws RepositoryException {
         // get read only session
-        Session readOnlySuperuser = helper.getReadOnlySession();
+        Session readOnlySuperuser = getHelper().getReadOnlySession();
         try {
             String dstAbsPath = node2.getPath() + "/" + node1.getName();
             try {
@@ -169,7 +172,8 @@
     /**
      * A LockException is thrown if a lock prevents the copy.
      */
-    public void testCloneNodesLocked() throws RepositoryException {
+    public void testCloneNodesLocked()
+            throws RepositoryException, NotExecutableException {
         // we assume repository supports locking
         String dstAbsPath = node2W2.getPath() + "/" + node1.getName();
 
@@ -177,10 +181,8 @@
         Node lockTarget = (Node) rwSessionW2.getItem(node2W2.getPath());
 
         // add mixin "lockable" to be able to lock the node
-        if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
-            lockTarget.addMixin(mixLockable);
-            lockTarget.getParent().save();
-        }
+        ensureMixinType(lockTarget, mixLockable);
+        lockTarget.getParent().save();
 
         // lock dst parent node using other session
         lockTarget.lock(true, true);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneVersionableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneVersionableTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneVersionableTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneVersionableTest.java Wed Jul  8 13:57:13 2009
@@ -19,6 +19,8 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.version.VersionException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 
 /**
  * <code>WorkspaceCloneVersionableTest</code> contains tests for cloning
@@ -36,7 +38,8 @@
      * versionable and checked-in, or is non-versionable but its nearest
      * versionable ancestor is checked-in.
      */
-    public void testCloneNodesVersionableAndCheckedIn() throws RepositoryException {
+    public void testCloneNodesVersionableAndCheckedIn() throws RepositoryException,
+            NotExecutableException {
         // prepare the test data
         // create a non-versionable node below a versionable node
         // required for having a nearest versionable ancestor to a nonversionable sub node

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java Wed Jul  8 13:57:13 2009
@@ -19,6 +19,8 @@
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>WorkspaceCopyBetweenWorkspacesReferenceableTest</code> contains tests
  * for copying referenceable nodes between workspace.
@@ -34,7 +36,8 @@
      * Copies of referenceable nodes (nodes with UUIDs) are automatically given
      * new UUIDs.
      */
-    public void testCopyNodesReferenceableNodesNewUUID() throws RepositoryException {
+    public void testCopyNodesReferenceableNodesNewUUID() throws RepositoryException,
+            NotExecutableException {
         // add mixin referenceable to node1
         addMixinReferenceableToNode(node1);
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesSameNameSibsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesSameNameSibsTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesSameNameSibsTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesSameNameSibsTest.java Wed Jul  8 13:57:13 2009
@@ -50,7 +50,7 @@
         int cnt = 0;
         NodeIterator iter = node2.getNodes();
         while (iter.hasNext()) {
-            Node n = (Node) iter.nextNode();
+            Node n = iter.nextNode();
 
             assertTrue(n.getName().equals(orderList[cnt]));
             cnt++;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java Wed Jul  8 13:57:13 2009
@@ -109,7 +109,7 @@
      * sufficient access permissions to complete the operation.
      */
     public void testCopyNodesAccessDenied() throws RepositoryException {
-        Session readOnlySuperuser = helper.getReadOnlySession();
+        Session readOnlySuperuser = getHelper().getReadOnlySession();
         try {
             String dstAbsPath = node2.getPath() + "/" + node1.getName();
             try {
@@ -165,10 +165,8 @@
         Node lockTarget = (Node) rwSessionW2.getItem(node2W2.getPath());
 
         // add mixin "lockable" to be able to lock the node
-        if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
-            lockTarget.addMixin(mixLockable);
-            lockTarget.getParent().save();
-        }
+        ensureMixinType(lockTarget, mixLockable);
+        lockTarget.getParent().save();
 
         // lock dst parent node using other session
         lockTarget.lock(true, true);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesVersionableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesVersionableTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesVersionableTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesVersionableTest.java Wed Jul  8 13:57:13 2009
@@ -19,6 +19,8 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.version.VersionException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>WorkspaceCopyBetweenWorkspacesVersionableTest</code> contains tests for
  * copying versionable nodes between workspace.
@@ -35,7 +37,8 @@
      * versionable and checked-in, or is non-versionable but its nearest
      * versionable ancestor is checked-in.
      */
-    public void testCopyNodesVersionableAndCheckedIn() throws RepositoryException {
+    public void testCopyNodesVersionableAndCheckedIn() throws RepositoryException,
+            NotExecutableException {
         // prepare the test data
         // create a non-versionable node below a versionable node
         // required for having a nearest versionable ancestor to a nonversionable sub node

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java Wed Jul  8 13:57:13 2009
@@ -44,7 +44,8 @@
      * Copies of referenceable nodes (nodes with UUIDs) are automatically given
      * new UUIDs.
      */
-    public void testCopyNodesNewUUID() throws RepositoryException {
+    public void testCopyNodesNewUUID() throws RepositoryException,
+            NotExecutableException {
         // add mixin referenceable to node1
         addMixinReferenceableToNode(node1);
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopySameNameSibsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopySameNameSibsTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopySameNameSibsTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopySameNameSibsTest.java Wed Jul  8 13:57:13 2009
@@ -60,7 +60,7 @@
         int cnt = 0;
         NodeIterator iter = node2.getNodes();
         while (iter.hasNext()) {
-            Node n = (Node) iter.nextNode();
+            Node n = iter.nextNode();
 
             assertTrue(n.getName().equals(orderList[cnt]));
             cnt++;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java Wed Jul  8 13:57:13 2009
@@ -24,6 +24,8 @@
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>WorkspaceCopyTest</code> contains tests for copying nodes in one
  * workspace.
@@ -91,7 +93,7 @@
      * sufficient access permissions to complete the operation.
      */
     public void testCopyNodesAccessDenied() throws RepositoryException {
-        Session readOnlySuperuser = helper.getReadOnlySession();
+        Session readOnlySuperuser = getHelper().getReadOnlySession();
         try {
             String dstAbsPath = node2.getPath() + "/" + node1.getName();
             try {
@@ -136,22 +138,21 @@
     /**
      * A LockException is thrown if a lock prevents the copy.
      */
-    public void testCopyNodesLocked() throws RepositoryException {
+    public void testCopyNodesLocked() throws RepositoryException,
+            NotExecutableException {
         // we assume repository supports locking
         String dstAbsPath = node2.getPath() + "/" + node1.getName();
 
         // get other session
-        Session otherSession = helper.getReadWriteSession();
+        Session otherSession = getHelper().getReadWriteSession();
 
         try {
             // get lock target node in destination wsp through other session
             Node lockTarget = (Node) otherSession.getItem(node2.getPath());
 
             // add mixin "lockable" to be able to lock the node
-            if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
-                lockTarget.addMixin(mixLockable);
-                lockTarget.getParent().save();
-            }
+            ensureMixinType(lockTarget, mixLockable);
+            lockTarget.getParent().save();
 
             // lock dst parent node using other session
             lockTarget.lock(true, true);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java Wed Jul  8 13:57:13 2009
@@ -44,7 +44,8 @@
      * Copies of referenceable nodes (nodes with UUIDs) remains their original
      * UUIDs.
      */
-    public void testMoveNodesReferenceableNodesNewUUID() throws RepositoryException {
+    public void testMoveNodesReferenceableNodesNewUUID() throws RepositoryException,
+            NotExecutableException {
         // add mixin referenceable to node1
         addMixinReferenceableToNode(node1);
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveSameNameSibsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveSameNameSibsTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveSameNameSibsTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveSameNameSibsTest.java Wed Jul  8 13:57:13 2009
@@ -64,7 +64,7 @@
         int cnt = 0;
         NodeIterator iter = node2.getNodes();
         while (iter.hasNext()) {
-            Node n = (Node) iter.nextNode();
+            Node n = iter.nextNode();
 
             assertTrue(n.getName().equals(orderList[cnt]));
             cnt++;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java Wed Jul  8 13:57:13 2009
@@ -24,6 +24,8 @@
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>WorkspaceMoveTest</code> contains tests for copying nodes in one
  * workspace.
@@ -91,7 +93,7 @@
      * sufficient access permissions to complete the operation.
      */
     public void testMoveNodesAccessDenied() throws RepositoryException {
-        Session readOnlySuperuser = helper.getReadOnlySession();
+        Session readOnlySuperuser = getHelper().getReadOnlySession();
         try {
             String dstAbsPath = node2.getPath() + "/" + node1.getName();
             try {
@@ -137,22 +139,21 @@
     /**
      * A LockException is thrown if a lock prevents the copy.
      */
-    public void testMoveNodesLocked() throws RepositoryException {
+    public void testMoveNodesLocked() throws RepositoryException,
+            NotExecutableException {
         // we assume repository supports locking
         String dstAbsPath = node2.getPath() + "/" + node1.getName();
 
         // get other session
-        Session otherSession = helper.getReadWriteSession();
+        Session otherSession = getHelper().getReadWriteSession();
 
         try {
             // get lock target node in destination wsp through other session
             Node lockTarget = (Node) otherSession.getItem(node2.getPath());
 
             // add mixin "lockable" to be able to lock the node
-            if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
-                lockTarget.addMixin(mixLockable);
-                lockTarget.getParent().save();
-            }
+            ensureMixinType(lockTarget, mixLockable);
+            lockTarget.getParent().save();
 
             // lock dst parent node using other session
             lockTarget.lock(true, true);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceReadMethodsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceReadMethodsTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceReadMethodsTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceReadMethodsTest.java Wed Jul  8 13:57:13 2009
@@ -45,7 +45,7 @@
      * this workspace was requested from.
      */
     public void testGetSession() throws RepositoryException {
-        Session session = helper.getReadOnlySession();
+        Session session = getHelper().getReadOnlySession();
         try {
             Session otherSession = session.getWorkspace().getSession();
             assertSame("Workspace.getSession() returns not the same session object.",
@@ -60,7 +60,7 @@
      * used for login.
      */
     public void testGetName() throws RepositoryException {
-        Session session = helper.getReadOnlySession(workspaceName);
+        Session session = getHelper().getReadOnlySession(workspaceName);
         try {
             String name = session.getWorkspace().getName();
             if (workspaceName != null) {
@@ -77,7 +77,7 @@
      * QueryManager object.
      */
     public void testGetQueryManager() throws RepositoryException {
-        Workspace ws = helper.getReadOnlySession().getWorkspace();
+        Workspace ws = getHelper().getReadOnlySession().getWorkspace();
         try {
             assertNotNull("Workspace does not return a QueryManager object.", ws.getQueryManager());
         } finally {
@@ -91,12 +91,12 @@
      * used for accessing the current workspace.
      */
     public void testGetAccessibleWorkspaceNames() throws RepositoryException {
-        Session session = helper.getReadOnlySession();
+        Session session = getHelper().getReadOnlySession();
         try {
             String[] wsNames = session.getWorkspace().getAccessibleWorkspaceNames();
             for (int i = 0; i < wsNames.length; i++) {
                 // login
-                Session s = helper.getReadOnlySession(wsNames[i]);
+                Session s = getHelper().getReadOnlySession(wsNames[i]);
                 s.logout();
             }
         } finally {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java Wed Jul  8 13:57:13 2009
@@ -52,7 +52,7 @@
         super.setUp();
         
         lockedNode = testRootNode.addNode(nodeName1, testNodeType);
-        lockedNode.addMixin(mixLockable);
+        ensureMixinType(lockedNode, mixLockable);
         childNode = lockedNode.addNode(nodeName2, testNodeType);
         testRootNode.save();
 
@@ -75,6 +75,12 @@
     protected abstract boolean isSessionScoped();
     protected abstract boolean isDeep();
 
+    protected void assertLockable(Node n)
+            throws RepositoryException, NotExecutableException {
+        ensureMixinType(n, mixLockable);
+        n.getSession().save();
+    }
+
     protected long getTimeoutHint() throws RepositoryException {
         String timoutStr = getProperty(RepositoryStub.PROP_LOCK_TIMEOUT);
         long hint = Long.MAX_VALUE;
@@ -96,7 +102,7 @@
         return ownerStr;
     }
 
-    private static LockManager getLockManager(Session session) throws RepositoryException {
+    protected static LockManager getLockManager(Session session) throws RepositoryException {
         return session.getWorkspace().getLockManager();
     }
 
@@ -108,6 +114,42 @@
     }
 
     /**
+     * Test {@link javax.jcr.lock.Lock#isLive()}.
+     */
+    public void testIsLive() throws RepositoryException {
+        assertTrue("Lock.isLive must be true.", lock.isLive());
+    }
+
+    /**
+     * Test {@link javax.jcr.lock.Lock#refresh()} on a released lock.
+     *
+     * @throws Exception
+     */
+    public void testRefresh() throws RepositoryException {
+        // refresh must succeed
+        lock.refresh();
+    }
+
+    // TODO: test if timeout gets reset upon Lock.refresh()
+    
+    /**
+     * Test {@link javax.jcr.lock.Lock#refresh()} on a released lock.
+     *
+     * @throws Exception
+     */
+    public void testRefreshNotLive() throws Exception {
+        // release the lock
+        lockMgr.unlock(lockedNode.getPath());
+        // refresh
+        try {
+            lock.refresh();
+            fail("Refresh on a lock that is not alive must fail");
+        } catch (LockException e) {
+            // success
+        }
+    }
+
+    /**
      * Test {@link javax.jcr.lock.Lock#getNode()}.
      *
      * @throws RepositoryException If an execption occurs.
@@ -135,7 +177,23 @@
         assertTrue("Node must hold lock after lock creation.", lockedNode.holdsLock());
         assertTrue("Node must hold lock after lock creation.", lockMgr.holdsLock(lockedNode.getPath()));
     }
-    
+
+
+    /**
+     * A locked node must also be locked if accessed by some other session.
+     */
+    public void testLockVisibility() throws RepositoryException {
+        Session otherSession = getHelper().getReadWriteSession();
+        try {
+            Node ln = (Node) otherSession.getItem(lockedNode.getPath());
+            assertTrue("Locked node must also be locked for another session", ln.isLocked());
+            assertTrue("Locked node must also be locked for another session", ln.holdsLock());
+            assertTrue("Locked node must also be locked for another session", getLockManager(otherSession).holdsLock(ln.getPath()));
+        } finally {
+            otherSession.logout();
+        }
+    }
+
     /**
      * Test {@link javax.jcr.lock.Lock#isSessionScoped()}
      */
@@ -153,7 +211,7 @@
         assertTrue("Session must be lock owner", lockedNode.getLock().isLockOwningSession());
         assertTrue("Session must be lock owner", lockMgr.getLock(lockedNode.getPath()).isLockOwningSession());
 
-        Session otherSession = helper.getReadOnlySession();
+        Session otherSession = getHelper().getReadOnlySession();
         try {
             Lock lck = otherSession.getNode(lockedNode.getPath()).getLock();
             assertFalse("Session must not be lock owner", lck.isLockOwningSession());
@@ -164,7 +222,7 @@
             otherSession.logout();
         }
 
-        Session otherAdmin = helper.getSuperuserSession();
+        Session otherAdmin = getHelper().getSuperuserSession();
         try {
             Lock lck = otherAdmin.getNode(lockedNode.getPath()).getLock();
             assertFalse("Other Session for the same userID must not be lock owner", lck.isLockOwningSession());
@@ -234,6 +292,20 @@
             obsMgr.removeEventListener(listener);
         }
     }
+
+    /**
+     * Test if Lock is properly released.
+     * 
+     * @throws RepositoryException
+     */
+    public void testUnlock() throws RepositoryException {
+        // release the lock
+        lockMgr.unlock(lockedNode.getPath());
+        
+        // assert: lock must not be alive
+        assertFalse("lock must not be alive", lock.isLive());
+    }
+
     /**
      * Test {@link LockManager#unlock(String)} for a session that is not
      * lock owner.
@@ -242,7 +314,7 @@
      * @throws NotExecutableException
      */
     public void testUnlockByOtherSession() throws RepositoryException, NotExecutableException {
-        Session otherSession = helper.getReadWriteSession();
+        Session otherSession = getHelper().getReadWriteSession();
         try {
             getLockManager(otherSession).unlock(lockedNode.getPath());
             fail("Another session must not be allowed to unlock.");
@@ -339,7 +411,8 @@
         }
     }
 
-    public void testRemoveMixLockableFromLockedNode() throws RepositoryException {
+    public void testRemoveMixLockableFromLockedNode() throws RepositoryException,
+            NotExecutableException {
         try {
             lockedNode.removeMixin(mixLockable);
             lockedNode.save();
@@ -366,8 +439,8 @@
             assertTrue(msg, lockedNode.hasProperty(jcrlockIsDeep));
         } finally {
             // ev. re-add the mixin in order to be able to unlock the node
-            if (lockedNode.isLocked() && !lockedNode.isNodeType(mixLockable)) {
-                lockedNode.addMixin(mixLockable);
+            if (lockedNode.isLocked()) {
+                ensureMixinType(lockedNode, mixLockable);
                 lockedNode.save();
             }
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/DeepLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/DeepLockTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/DeepLockTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/DeepLockTest.java Wed Jul  8 13:57:13 2009
@@ -49,8 +49,9 @@
         assertTrue("Lock.getNode() must return the lock holding node even if lock is obtained from child node.", lock.getNode().isSame(lockedNode));
     }
 
-    public void testParentChildDeepLock() throws RepositoryException {
-        childNode.addMixin(mixLockable);
+    public void testParentChildDeepLock()
+            throws RepositoryException, NotExecutableException {
+        ensureMixinType(childNode, mixLockable);
         testRootNode.save();
 
         // try to lock child node
@@ -73,7 +74,7 @@
         Node parent = lockedNode.getParent();
         if (!parent.isNodeType(mixLockable)) {
             try {
-                parent.addMixin(mixLockable);
+                ensureMixinType(parent, mixLockable);
                 parent.save();
             } catch (RepositoryException e) {
                 throw new NotExecutableException();
@@ -96,14 +97,8 @@
 
     public void testShallowLockAboveLockedChild() throws RepositoryException, NotExecutableException {
         Node parent = lockedNode.getParent();
-        if (!parent.isNodeType(mixLockable)) {
-            try {
-                parent.addMixin(mixLockable);
-                parent.save();
-            } catch (RepositoryException e) {
-                throw new NotExecutableException();
-            }
-        }
+        ensureMixinType(parent, mixLockable);
+        parent.save();
 
         try {
             // creating a shallow lock on the parent must succeed.
@@ -120,7 +115,7 @@
     }
 
     public void testRemoveLockedChild() throws RepositoryException {
-        Session otherSession = helper.getReadWriteSession();
+        Session otherSession = getHelper().getReadWriteSession();
         try {
             Node child = (Node) otherSession.getItem(childNode.getPath());
             child.remove();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockManagerTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockManagerTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockManagerTest.java Wed Jul  8 13:57:13 2009
@@ -54,7 +54,6 @@
         testRootNode.save();
         testPath = testNode.getPath();
 
-        // TODO: rm cast and adjust call as soon as 283 is released
         lockMgr = getLockManager(superuser);
     }
 
@@ -65,11 +64,10 @@
         super.tearDown();
     }
 
-    private void assertLockable(Node n) throws RepositoryException {
-        if (!n.isNodeType(mixLockable)) {
-            n.addMixin(mixLockable);
-            n.getSession().save();
-        }
+    private void assertLockable(Node n) throws RepositoryException,
+            NotExecutableException {
+        ensureMixinType(n, mixLockable);
+        n.getSession().save();
     }
 
    private static LockManager getLockManager(Session session) throws RepositoryException {
@@ -101,7 +99,8 @@
         }
     }
 
-    public void testLockWithPendingChanges() throws RepositoryException {
+    public void testLockWithPendingChanges() throws RepositoryException,
+            NotExecutableException {
         assertLockable(testNode);
 
         // transient modification
@@ -114,14 +113,16 @@
         }
     }
 
-    public void testNullOwnerHint() throws RepositoryException {
+    public void testNullOwnerHint() throws RepositoryException,
+            NotExecutableException {
         assertLockable(testNode);
 
         Lock l = lockMgr.lock(testPath, true, true, Long.MAX_VALUE, null);
         assertNotNull(l.getLockOwner());
     }
 
-    public void testGetLockTokens() throws RepositoryException {
+    public void testGetLockTokens() throws RepositoryException,
+            NotExecutableException {
         assertLockable(testNode);
 
         boolean sessionScoped = false;
@@ -133,7 +134,8 @@
                 containsLockToken(superuser.getLockTokens(), ltoken));
     }
 
-    public void testGetLockTokensAfterUnlock() throws RepositoryException {
+    public void testGetLockTokensAfterUnlock() throws RepositoryException,
+            NotExecutableException {
         assertLockable(testNode);
 
         boolean sessionScoped = false;
@@ -147,7 +149,8 @@
                 containsLockToken(superuser.getLockTokens(), ltoken));
     }
 
-    public void testGetLockTokensSessionScoped() throws RepositoryException {
+    public void testGetLockTokensSessionScoped() throws RepositoryException,
+            NotExecutableException {
         assertLockable(testNode);
 
         List tokensBefore = Arrays.asList(lockMgr.getLockTokens());
@@ -161,7 +164,8 @@
                 tokensBefore, Arrays.asList(superuser.getLockTokens()));
     }
 
-    public void testAddLockToken() throws RepositoryException {
+    public void testAddLockToken() throws RepositoryException,
+            NotExecutableException {
         assertLockable(testNode);
 
         boolean sessionScoped = false;
@@ -181,8 +185,9 @@
         }
     }
 
-    public void testAddLockTokenToAnotherSession() throws RepositoryException {
-        // TODO: for 283 add config option for simutaneous tokens....
+    public void testAddLockTokenToAnotherSession() throws RepositoryException,
+            NotExecutableException {
+        // TODO: for 283 add config option for simultaneous tokens....
         
         assertLockable(testNode);
 
@@ -190,7 +195,7 @@
         Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
         String ltoken = l.getLockToken();
 
-        Session other = helper.getReadWriteSession();
+        Session other = getHelper().getReadWriteSession();
         try {
             LockManager otherLockMgr = getLockManager(other);
             assertFalse(containsLockToken(otherLockMgr, ltoken));
@@ -315,7 +320,7 @@
         Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
         String ltoken = l.getLockToken();
 
-        Session other = helper.getReadWriteSession();
+        Session other = getHelper().getReadWriteSession();
         LockManager otherLockMgr = getLockManager(other);
         try {
             lockMgr.removeLockToken(ltoken);
@@ -335,7 +340,7 @@
     }
 
     public void testLockTransfer2() throws Exception {
-        // TODO: for 283 add config option for simutaneous tokens....
+        // TODO: for 283 add config option for simultaneous tokens....
 
         assertLockable(testNode);
 
@@ -343,7 +348,7 @@
         Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
         String ltoken = l.getLockToken();
 
-        Session other = helper.getReadWriteSession();
+        Session other = getHelper().getReadWriteSession();
         LockManager otherLockMgr = getLockManager(other);
         try {
             lockMgr.removeLockToken(ltoken);
@@ -367,7 +372,7 @@
         Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
         String ltoken = l.getLockToken();
 
-        Session other = helper.getReadWriteSession();
+        Session other = getHelper().getReadWriteSession();
         LockManager otherLockMgr = getLockManager(other);
         try {
             lockMgr.removeLockToken(ltoken);



Mime
View raw message