jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r792142 [21/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/lock/LockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockTest.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/LockTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockTest.java Wed Jul  8 13:57:13 2009
@@ -49,9 +49,7 @@
     public void testAddRemoveLockToken() throws Exception {
         // create new node
         Node n = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n, mixLockable)) {
-            n.addMixin(mixLockable);
-        }
+        ensureMixinType(n, mixLockable);
         testRootNode.save();
 
         // lock node and get lock token
@@ -107,9 +105,7 @@
     public void testNodeLocked() throws Exception {
         // create new node and lock it
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         testRootNode.save();
 
         // lock node
@@ -119,7 +115,7 @@
         assertTrue("Lock must be live", lock.isLive());
 
         // create new session
-        Session otherSuperuser = helper.getSuperuserSession();
+        Session otherSuperuser = getHelper().getSuperuserSession();
 
         try {
             // get same node
@@ -147,13 +143,9 @@
     public void testGetNode() throws Exception {
         // create new node with a sub node and lock it
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n1Sub = n1.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1Sub, mixLockable)) {
-            n1Sub.addMixin(mixLockable);
-        }
+        ensureMixinType(n1Sub, mixLockable);
         testRootNode.save();
 
         // lock node
@@ -177,9 +169,7 @@
     public void testGetLockOwnerProperty() throws Exception {
         // create new node and lock it
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         testRootNode.save();
 
         // lock node
@@ -205,9 +195,7 @@
     public void testGetLockOwner() throws Exception {
         // create new node and lock it
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         testRootNode.save();
 
         // lock node
@@ -227,9 +215,7 @@
     public void testShallowLock() throws Exception {
         // create new nodes
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n2 = n1.addNode(nodeName2, testNodeType);
         testRootNode.save();
 
@@ -252,19 +238,9 @@
 
         // create a node that is lockable and versionable
         Node node = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(node, mixLockable)) {
-            node.addMixin(mixLockable);
-        }
+        ensureMixinType(node, mixLockable);
         // try to make it versionable if it is not
-        if (!node.isNodeType(mixVersionable)) {
-            if (node.canAddMixin(mixVersionable)) {
-                node.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException("Node " + nodeName1 + " is " +
-                        "not versionable and does not allow to add " +
-                        "mix:versionable");
-            }
-        }
+        ensureMixinType(node, mixVersionable);
         testRootNode.save();
 
         node.checkin();
@@ -292,13 +268,9 @@
     public void testParentChildLock() throws Exception {
         // create new nodes
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n2 = n1.addNode(nodeName2, testNodeType);
-        if (needsMixin(n2, mixLockable)) {
-            n2.addMixin(mixLockable);
-        }
+        ensureMixinType(n2, mixLockable);
         testRootNode.save();
 
         // lock parent node
@@ -320,13 +292,9 @@
     public void testParentChildDeepLock() throws Exception {
         // create new nodes
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n2 = n1.addNode(nodeName2, testNodeType);
-        if (needsMixin(n2, mixLockable)) {
-            n2.addMixin(mixLockable);
-        }
+        ensureMixinType(n2, mixLockable);
         testRootNode.save();
 
         // lock child node
@@ -344,16 +312,12 @@
     /**
      * Test Lock.isDeep()
      */
-    public void testIsDeep() throws RepositoryException {
+    public void testIsDeep() throws RepositoryException, NotExecutableException {
         // create two lockable nodes
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n2 = testRootNode.addNode(nodeName2, testNodeType);
-        if (needsMixin(n2, mixLockable)) {
-            n2.addMixin(mixLockable);
-        }
+        ensureMixinType(n2, mixLockable);
         testRootNode.save();
 
         // lock node 1 "undeeply"
@@ -372,16 +336,13 @@
     /**
      * Test Lock.isSessionScoped()
      */
-    public void testIsSessionScoped() throws RepositoryException {
+    public void testIsSessionScoped() throws RepositoryException,
+            NotExecutableException {
         // create two lockable nodes
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n2 = testRootNode.addNode(nodeName2, testNodeType);
-        if (needsMixin(n2, mixLockable)) {
-            n2.addMixin(mixLockable);
-        }
+        ensureMixinType(n2, mixLockable);
         testRootNode.save();
 
         // lock node 1 session-scoped
@@ -405,13 +366,11 @@
     public void testLogout() throws Exception {
         // add node
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         testRootNode.save();
 
         // create new session
-        Session otherSuperuser = helper.getSuperuserSession();
+        Session otherSuperuser = getHelper().getSuperuserSession();
 
         Lock lock;
         try {
@@ -447,13 +406,11 @@
     public void testLockTransfer() throws Exception {
         // add node
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         testRootNode.save();
 
         // create new session
-        Session otherSuperuser = helper.getSuperuserSession();
+        Session otherSuperuser = getHelper().getSuperuserSession();
 
         try {
             // get node created above
@@ -490,13 +447,11 @@
     public void testOpenScopedLocks() throws Exception {
         // add node
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         testRootNode.save();
 
         // create new session
-        Session otherSuperuser = helper.getSuperuserSession();
+        Session otherSuperuser = getHelper().getSuperuserSession();
 
         try {
             // get node created above
@@ -524,9 +479,7 @@
     public void testRefresh() throws Exception {
         // create new node
         Node n = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n, mixLockable)) {
-            n.addMixin(mixLockable);
-        }
+        ensureMixinType(n, mixLockable);
         testRootNode.save();
 
         // lock node and get lock token
@@ -551,9 +504,7 @@
     public void testRefreshNotLive() throws Exception {
         // create new node
         Node n = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n, mixLockable)) {
-            n.addMixin(mixLockable);
-        }
+        ensureMixinType(n, mixLockable);
         testRootNode.save();
 
         // lock node and get lock token
@@ -583,13 +534,9 @@
     public void testGetLock() throws Exception {
         // create new nodes
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n2 = n1.addNode(nodeName2, testNodeType);
-        if (needsMixin(n2, mixLockable)) {
-            n2.addMixin(mixLockable);
-        }
+        ensureMixinType(n2, mixLockable);
         testRootNode.save();
 
         // deep lock parent node
@@ -612,10 +559,8 @@
 
         // set up versionable and lockable node
         Node testNode = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(testNode, mixLockable)) {
-            testNode.addMixin(mixLockable);
-        }
-        testNode.addMixin(mixVersionable);
+        ensureMixinType(testNode, mixLockable);
+        ensureMixinType(testNode, mixVersionable);
         testRootNode.save();
 
         // lock and check-in
@@ -691,13 +636,9 @@
 
         // create two nodes, parent and child
         Node testNode1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(testNode1, mixLockable)) {
-            testNode1.addMixin(mixLockable);
-        }
+        ensureMixinType(testNode1, mixLockable);
         Node testNode2 = testNode1.addNode(nodeName2, testNodeType);
-        if (needsMixin(testNode2, mixLockable)) {
-            testNode2.addMixin(mixLockable);
-        }
+        ensureMixinType(testNode2, mixLockable);
         testRootNode.save();
 
         // lock child node
@@ -737,8 +678,8 @@
             throw new NotExecutableException("Node does not seem to allow same name siblings");
         }
 
-        n1.addMixin("mix:lockable");
-        n2.addMixin("mix:lockable");
+        ensureMixinType(n1, mixLockable);
+        ensureMixinType(n2, mixLockable);
         session.save();
 
         // lock both nodes
@@ -778,17 +719,11 @@
         // create three lockable nodes with same name
         try {
             Node testNode = testRootNode.addNode(nodeName1, testNodeType);
-            if (needsMixin(testNode, mixLockable)) {
-                testNode.addMixin(mixLockable);
-            }
+            ensureMixinType(testNode, mixLockable);
             testNode = testRootNode.addNode(nodeName1, testNodeType);
-            if (needsMixin(testNode, mixLockable)) {
-                testNode.addMixin(mixLockable);
-            }
+            ensureMixinType(testNode, mixLockable);
             testNode = testRootNode.addNode(nodeName1, testNodeType);
-            if (needsMixin(testNode, mixLockable)) {
-                testNode.addMixin(mixLockable);
-            }
+            ensureMixinType(testNode, mixLockable);
             testRootNode.save();
             return testNode;
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SessionScopedLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SessionScopedLockTest.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/SessionScopedLockTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SessionScopedLockTest.java Wed Jul  8 13:57:13 2009
@@ -18,6 +18,14 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.test.NotExecutableException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.Session;
+import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
+import javax.jcr.lock.LockManager;
 
 /** <code>SessionScopedLockTest</code>... */
 public class SessionScopedLockTest extends AbstractLockTest {
@@ -39,4 +47,67 @@
     public void testGetLockToken() {
         assertNull("A session scoped lock may never expose the token.", lock.getLockToken());
     }
+
+    /**
+     * Test locks are released when session logs out
+     */
+    public void testImplicitUnlock() throws RepositoryException,
+            NotExecutableException {
+        Session other = getHelper().getReadWriteSession();
+        try {
+            Node testNode = (Node) other.getItem(testRootNode.getPath());
+            Node lockedNode = testNode.addNode(nodeName1, testNodeType);
+            other.save();
+
+            assertLockable(lockedNode);
+
+            Lock lock = getLockManager(other).lock(lockedNode.getPath(), isDeep(), isSessionScoped(), getTimeoutHint(), getLockOwner());
+            other.logout();
+
+            assertFalse(lock.isLive());
+        } finally {
+            if (other.isLive()) {
+                other.logout();
+            }
+        }
+    }
+
+    /**
+     * Test locks are released when session logs out
+     */
+    public void testImplicitUnlock2() throws RepositoryException,
+            NotExecutableException {
+        Session other = getHelper().getReadWriteSession();
+        try {
+            Node testNode = (Node) other.getItem(testRootNode.getPath());
+            Node lockedNode = testNode.addNode(nodeName1, testNodeType);
+            other.save();
+
+            assertLockable(lockedNode);
+
+            LockManager lMgr = getLockManager(other);
+            Lock lock = lMgr.lock(lockedNode.getPath(), isDeep(), isSessionScoped(), getTimeoutHint(), getLockOwner());
+
+            // access the locked noded added by another session
+            testRootNode.refresh(false);
+            Node n = (Node) superuser.getItem(lockedNode.getPath());
+
+            // remove lock implicit by logout lock-holding session
+            other.logout();
+
+            // check if superuser session is properly informed about the unlock
+            assertFalse(n.isLocked());
+            assertFalse(n.holdsLock());
+            try {
+                n.getLock();
+                fail("Upon logout of the session a session-scoped lock must be gone.");
+            } catch (LockException e) {
+                // ok
+            }
+        } finally {
+            if (other.isLive()) {
+                other.logout();
+            }
+        }
+    }
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SetValueLockExceptionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SetValueLockExceptionTest.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/SetValueLockExceptionTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SetValueLockExceptionTest.java Wed Jul  8 13:57:13 2009
@@ -88,9 +88,7 @@
         else {
             // add a lockable node
             testNode = testRootNode.addNode(nodeName1, testNodeType);
-            if (needsMixin(testNode, mixLockable)) {
-                testNode.addMixin(mixLockable);
-            }
+            ensureMixinType(testNode, mixLockable);
 
             // add properties
             dateValue = Calendar.getInstance();
@@ -146,7 +144,7 @@
         }
 
         // another session
-        Session session = helper.getReadWriteSession();
+        Session session = getHelper().getReadWriteSession();
         try {
             Node node = (Node) session.getItem(testNode.getPath());
             Property prop = null;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanAddChildNodeCallWithNodeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanAddChildNodeCallWithNodeTypeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanAddChildNodeCallWithNodeTypeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanAddChildNodeCallWithNodeTypeTest.java Wed Jul  8 13:57:13 2009
@@ -24,6 +24,7 @@
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.NodeTypeIterator;
 
 /**
  * Tests <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code>
@@ -53,7 +54,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         manager = session.getWorkspace().getNodeTypeManager();
     }
 
@@ -125,6 +126,65 @@
 
     /**
      * Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code>
+     * returns false if <code>nodeTypeName</code> represents a mixin.
+     */
+    public void testCanAddMixinType()
+            throws NotExecutableException, RepositoryException {
+
+        NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, false, false);
+
+        if (nodeDef == null) {
+            throw new NotExecutableException("No testable node type found.");
+        }
+
+        NodeType nodeType = nodeDef.getDeclaringNodeType();
+        String childNodeName = nodeDef.getName();
+        String mixinName;
+        NodeTypeIterator it = manager.getMixinNodeTypes();
+        if (it.hasNext()) {
+            mixinName = it.nextNodeType().getName();
+        } else {
+            throw new NotExecutableException("No mixin type found.");
+        }
+
+        assertFalse("NodeType.canAddChildNode(String childNodeName, String nodeTypeName) " +
+                "must return false if nodeTypeName represents a mixin type.",
+                nodeType.canAddChildNode(childNodeName, mixinName));
+    }
+
+    /**
+     * Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code>
+     * returns false if <code>nodeTypeName</code> represents an abstract node type.
+     */
+    public void testCanAddAbstractType()
+    throws NotExecutableException, RepositoryException {
+
+        NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, false, false);
+
+        if (nodeDef == null) {
+            throw new NotExecutableException("No testable node type found.");
+        }
+
+        NodeType nodeType = nodeDef.getDeclaringNodeType();
+        String childNodeName = nodeDef.getName();
+        String abstractName = null;
+        NodeTypeIterator it = manager.getPrimaryNodeTypes();
+        while (it.hasNext() && abstractName == null) {
+            NodeType nt = it.nextNodeType();
+            if (nt.isAbstract()) {
+                abstractName = nt.getName();
+            }
+        }
+        if (abstractName == null) {
+            throw new NotExecutableException("No abstract type found.");
+        }
+
+        assertFalse("NodeType.canAddChildNode(String childNodeName, String nodeTypeName) " +
+                "must return false if nodeTypeName represents an abstract node type.",
+                nodeType.canAddChildNode(childNodeName, abstractName));
+    }
+    /**
+     * Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code>
      * returns false if <code>childNodeName</code> does not match the <code>NodeDef</code>.
      */
     public void testUndefined()

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanAddChildNodeCallWithoutNodeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanAddChildNodeCallWithoutNodeTypeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanAddChildNodeCallWithoutNodeTypeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanAddChildNodeCallWithoutNodeTypeTest.java Wed Jul  8 13:57:13 2009
@@ -48,7 +48,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanRemoveItemTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanRemoveItemTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanRemoveItemTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanRemoveItemTest.java Wed Jul  8 13:57:13 2009
@@ -49,7 +49,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java Wed Jul  8 13:57:13 2009
@@ -50,7 +50,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java Wed Jul  8 13:57:13 2009
@@ -50,7 +50,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDateTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDateTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDateTest.java Wed Jul  8 13:57:13 2009
@@ -50,7 +50,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDoubleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDoubleTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDoubleTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDoubleTest.java Wed Jul  8 13:57:13 2009
@@ -50,7 +50,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyLongTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyLongTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyLongTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyLongTest.java Wed Jul  8 13:57:13 2009
@@ -50,7 +50,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyMultipleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyMultipleTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyMultipleTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyMultipleTest.java Wed Jul  8 13:57:13 2009
@@ -48,7 +48,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyNameTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyNameTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyNameTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyNameTest.java Wed Jul  8 13:57:13 2009
@@ -50,7 +50,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyPathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyPathTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyPathTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyPathTest.java Wed Jul  8 13:57:13 2009
@@ -50,7 +50,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyStringTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyStringTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyStringTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyStringTest.java Wed Jul  8 13:57:13 2009
@@ -50,7 +50,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyTest.java Wed Jul  8 13:57:13 2009
@@ -48,7 +48,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeDefTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeDefTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeDefTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeDefTest.java Wed Jul  8 13:57:13 2009
@@ -65,7 +65,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         manager = session.getWorkspace().getNodeTypeManager();
         // re-fetch testRootNode with read-only session
         testRootNode = (Node) session.getItem(testRoot);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeManagerTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeManagerTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeManagerTest.java Wed Jul  8 13:57:13 2009
@@ -53,7 +53,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         manager = session.getWorkspace().getNodeTypeManager();
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeTest.java Wed Jul  8 13:57:13 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.test.api.nodetype;
 
+import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
@@ -67,7 +68,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         manager = session.getWorkspace().getNodeTypeManager();
         rootNode = session.getRootNode();
     }
@@ -213,6 +214,9 @@
             assertTrue("all declared supertypes must be supertypes: "
                     + (new HashSet(declaredSupertypeNames).removeAll(supertypeNames)),
                     supertypeNames.containsAll(declaredSupertypeNames));
+            
+            assertEquals("getDeclaredSuperTypes and getDeclaredSuperTypeNames must be consistent",
+                    declaredSupertypeNames, new HashSet(Arrays.asList(type.getDeclaredSupertypeNames())));
         }
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java Wed Jul  8 13:57:13 2009
@@ -67,7 +67,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         manager = session.getWorkspace().getNodeTypeManager();
     }
 
@@ -289,6 +289,9 @@
             String name = supertypes[i].getName();
             if (name.startsWith("nt:") ||
                     name.equals("mix:simpleVersionable") ||
+                    name.equals("mix:created") ||
+                    name.equals("mix:mimeType") ||
+                    name.equals("mix:lastModified") ||
                     (name.equals("mix:referenceable") &&
                         (typeName.equals("mix:versionable") ||
                             typeName.equals("mix:shareable") ||

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/PropertyDefTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/PropertyDefTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/PropertyDefTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/PropertyDefTest.java Wed Jul  8 13:57:13 2009
@@ -87,7 +87,7 @@
         isReadOnly = true;
         super.setUp();
 
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         manager = session.getWorkspace().getNodeTypeManager();
         // re-fetch testRootNode with read-only session
         testRootNode = (Node) session.getItem(testRoot);
@@ -200,6 +200,9 @@
                     case PropertyType.REFERENCE:
                     case PropertyType.BOOLEAN:
                     case PropertyType.UNDEFINED:
+                    case PropertyType.WEAKREFERENCE:
+                    case PropertyType.DECIMAL:
+                    case PropertyType.URI:
                         // success
                         break;
                     default:

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/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/nodetype/TestAll.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/TestAll.java Wed Jul  8 13:57:13 2009
@@ -59,6 +59,10 @@
         suite.addTestSuite(CanAddChildNodeCallWithoutNodeTypeTest.class);
 
         suite.addTestSuite(CanRemoveItemTest.class);
+        
+        // JCR 2.0
+
+        suite.addTestSuite(NodeTypeCreationTest.class);
 
         return suite;
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/AddEventListenerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/AddEventListenerTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/AddEventListenerTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/AddEventListenerTest.java Wed Jul  8 13:57:13 2009
@@ -158,7 +158,7 @@
                 null,
                 new String[]{testNodeType},
                 false);
-        Session s = helper.getSuperuserSession();
+        Session s = getHelper().getSuperuserSession();
         try {
             Node n = (Node) s.getItem(n1.getPath());
             n.addNode(nodeName3, ntBase);
@@ -188,13 +188,10 @@
      * @throws RepositoryException if node creation fails.
      */
     private Node createReferenceable(String nodeName, String nodeType)
-            throws RepositoryException {
+            throws RepositoryException, NotExecutableException {
         Node n = testRootNode.addNode(nodeName, nodeType);
-        if (needsMixin(n, mixReferenceable)) {
-            n.addMixin(mixReferenceable);
-            // some implementations may require a save after addMixin()
-            testRootNode.save();
-        }
+        ensureMixinType(n, mixReferenceable);
+        testRootNode.save();
         return n;
     }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/EventJournalTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/EventJournalTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/EventJournalTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/EventJournalTest.java Wed Jul  8 13:57:13 2009
@@ -23,8 +23,11 @@
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.observation.Event;
 import javax.jcr.observation.EventJournal;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>EventJournalTest</code> performs EventJournal tests.
  */
@@ -39,7 +42,7 @@
 
     public void testSkipToNow() throws RepositoryException {
         // skip everything
-        journal.skipTo(System.currentTimeMillis());
+        skipToNow();
         assertFalse(journal.hasNext());
     }
 
@@ -65,7 +68,7 @@
     }
 
     public void testLiveJournal() throws RepositoryException {
-        journal.skipTo(System.currentTimeMillis());
+        skipToNow();
         assertFalse(journal.hasNext());
 
         testRootNode.addNode(nodeName1);
@@ -75,10 +78,10 @@
     }
 
     public void testWorkspaceSeparation() throws RepositoryException {
-        journal.skipTo(System.currentTimeMillis());
+        skipToNow();
         assertFalse(journal.hasNext());
 
-        Session session = helper.getSuperuserSession(workspaceName);
+        Session session = getHelper().getSuperuserSession(workspaceName);
         try {
             Node rootNode = session.getRootNode();
             if (rootNode.hasNode(nodeName1)) {
@@ -99,24 +102,22 @@
         Node n2 = n1.addNode(nodeName2);
 
         journal = obsMgr.getEventJournal();
-        journal.skipTo(System.currentTimeMillis());
+        skipToNow();
 
         superuser.save();
 
         checkJournal(new String[]{n1.getPath(), n2.getPath()}, new String[0]);
     }
 
-    public void testUUID() throws RepositoryException {
+    public void testUUID() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1);
-        if (!n1.isNodeType(mixReferenceable)) {
-            n1.addMixin(mixReferenceable);
-        }
+        ensureMixinType(n1, mixReferenceable);
         superuser.save();
 
         Node n2 = n1.addNode(nodeName2);
 
         journal = obsMgr.getEventJournal();
-        journal.skipTo(System.currentTimeMillis());
+        skipToNow();
 
         superuser.save();
 
@@ -129,7 +130,7 @@
         obsMgr.setUserData(data);
 
         journal = obsMgr.getEventJournal();
-        journal.skipTo(System.currentTimeMillis());
+        skipToNow();
 
         superuser.save();
 
@@ -137,8 +138,72 @@
         assertEquals("Wrong user data", data, journal.nextEvent().getUserData());
     }
 
+    public void testEventType() throws RepositoryException {
+        Node n1 = testRootNode.addNode(nodeName1);
+
+        journal = getEventJournal(Event.PROPERTY_ADDED, testRoot, true, null, null);
+        skipToNow();
+
+        superuser.save();
+
+        checkJournal(new String[]{n1.getPath() + "/" + jcrPrimaryType},
+                new String[]{n1.getPath()});
+    }
+
+    public void testPath() throws RepositoryException {
+        Node n1 = testRootNode.addNode(nodeName1);
+        Node n2 = n1.addNode(nodeName2);
+
+        journal = getEventJournal(ALL_TYPES, n1.getPath(), true, null, null);
+        skipToNow();
+        superuser.save();
+
+        checkJournal(new String[]{n2.getPath()}, new String[]{n1.getPath()});
+    }
+
+    public void testIsDeepFalse() throws RepositoryException {
+        Node n1 = testRootNode.addNode(nodeName1);
+        Node n2 = n1.addNode(nodeName2);
+
+        journal = getEventJournal(ALL_TYPES, testRoot, false, null, null);
+        skipToNow();
+
+        superuser.save();
+
+        checkJournal(new String[]{n1.getPath()}, new String[]{n2.getPath()});
+    }
+
+    public void testNodeType() throws RepositoryException {
+        Node n1 = testRootNode.addNode(nodeName1, "nt:folder");
+        Node n2 = n1.addNode(nodeName2, "nt:folder");
+
+        journal = getEventJournal(ALL_TYPES, testRoot, true, null,
+                new String[]{"nt:folder"});
+        skipToNow();
+
+        superuser.save();
+
+        checkJournal(new String[]{n2.getPath()}, new String[]{n1.getPath()});
+    }
+    
     //-------------------------------< internal >-------------------------------
 
+    private void skipToNow() {
+        long now = System.currentTimeMillis();
+        journal.skipTo(now);
+        while (now == System.currentTimeMillis()) {
+            try {
+                Thread.sleep(1);
+            } catch (InterruptedException e) {
+                // ignore
+            }
+        }
+    }
+
+    private EventJournal getEventJournal(int eventTypes, String absPath, boolean isDeep, String[] uuid, String[] nodeTypeName) throws RepositoryException {
+        return superuser.getWorkspace().getObservationManager().getEventJournal(eventTypes, absPath, isDeep, uuid, nodeTypeName);
+    }
+
     /**
      * Checks the journal for events.
      *

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/GetIdentifierTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/GetIdentifierTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/GetIdentifierTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/GetIdentifierTest.java Wed Jul  8 13:57:13 2009
@@ -39,7 +39,6 @@
 
     public void testNodeMoved() throws RepositoryException {
         final Node n = testRootNode.addNode(nodeName1, testNodeType);
-        String id = n.getIdentifier();
         testRootNode.save();
         Event[] events = getEvents(new Callable(){
             public void call() throws RepositoryException {
@@ -47,21 +46,21 @@
             }
         }, Event.NODE_MOVED);
         String path = testRootNode.getNode(nodeName2).getPath();
-        assertEquals(id, getEventByPath(events, path).getIdentifier());
+        assertEquals(n.getIdentifier(), getEventByPath(events, path).getIdentifier());
     }
 
     public void testNodeRemoved() throws RepositoryException {
         final Node n = testRootNode.addNode(nodeName1, testNodeType);
         String path = n.getPath();
-        String id = n.getIdentifier();
         testRootNode.save();
+        String identifier = n.getIdentifier();
         Event[] events = getEvents(new Callable(){
             public void call() throws RepositoryException {
                 n.remove();
                 testRootNode.save();
             }
         }, Event.NODE_REMOVED);
-        assertEquals(id, getEventByPath(events, path).getIdentifier());
+        assertEquals(identifier, getEventByPath(events, path).getIdentifier());
     }
 
     public void testPropertyAdded() throws RepositoryException {
@@ -91,7 +90,6 @@
 
     public void testPropertyRemoved() throws RepositoryException {
         Node n = testRootNode.addNode(nodeName1, testNodeType);
-        String id = n.getIdentifier();
         final Property prop = n.setProperty(propertyName1, "test");
         String propPath = prop.getPath();
         testRootNode.save();
@@ -101,6 +99,6 @@
                 testRootNode.save();
             }
         }, Event.PROPERTY_REMOVED);
-        assertEquals(id, getEventByPath(events, propPath).getIdentifier());
+        assertEquals(n.getIdentifier(), getEventByPath(events, propPath).getIdentifier());
     }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/GetUserDataTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/GetUserDataTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/GetUserDataTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/GetUserDataTest.java Wed Jul  8 13:57:13 2009
@@ -56,7 +56,7 @@
         checkSupportedOption(Repository.OPTION_VERSIONING_SUPPORTED);
 
         final Node n1 = testRootNode.addNode(nodeName1);
-        n1.addMixin(mixVersionable);
+        ensureMixinType(n1, mixVersionable);
         testRootNode.save();
 
         runWithUserData(new Callable() {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/LockingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/LockingTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/LockingTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/LockingTest.java Wed Jul  8 13:57:13 2009
@@ -22,6 +22,8 @@
 import java.util.List;
 import java.util.ArrayList;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * Tests if locking a node triggers property added events for jcr:lockOwner
  * and jcr:lockIsDeep.
@@ -44,7 +46,8 @@
      * Tests if locking a node triggers property added events for the properties
      * jcr:lockOwner and jcr:lockIsDeep.
      */
-    public void testAddLockToNode() throws RepositoryException {
+    public void testAddLockToNode() throws RepositoryException,
+            NotExecutableException {
         Node lockable = createLockable(nodeName1, testNodeType);
         testRootNode.save();
         EventResult result = new EventResult(log);
@@ -76,7 +79,8 @@
      * Tests if unlocking a node triggers property removed events for the
      * properties jcr:lockOwner and jcr:lockIsDeep.
      */
-    public void testRemoveLockFromNode() throws RepositoryException {
+    public void testRemoveLockFromNode() throws RepositoryException,
+            NotExecutableException {
         Node lockable = createLockable(nodeName1, testNodeType);
         testRootNode.save();
         // lock the node
@@ -111,11 +115,9 @@
      * @return the lockable node
      */
     private Node createLockable(String nodeName, String nodeType)
-            throws RepositoryException {
+            throws RepositoryException, NotExecutableException {
         Node n = testRootNode.addNode(nodeName, nodeType);
-        if (needsMixin(n, mixLockable)) {
-            n.addMixin(mixLockable);
-        }
+        ensureMixinType(n, mixLockable);
         return n;
     }
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeMovedTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeMovedTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeMovedTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeMovedTest.java Wed Jul  8 13:57:13 2009
@@ -22,9 +22,6 @@
 import javax.jcr.Node;
 import javax.jcr.observation.Event;
 
-import org.apache.jackrabbit.test.api.observation.AbstractObservationTest;
-import org.apache.jackrabbit.test.api.observation.EventResult;
-
 /**
  * Tests if {@link javax.jcr.Session#move} operations trigger the appropriate
  * observation events.

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeReorderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeReorderTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeReorderTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/NodeReorderTest.java Wed Jul  8 13:57:13 2009
@@ -19,8 +19,6 @@
 import java.util.Map;
 
 import org.apache.jackrabbit.test.NotExecutableException;
-import org.apache.jackrabbit.test.api.observation.AbstractObservationTest;
-import org.apache.jackrabbit.test.api.observation.EventResult;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Node;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java Wed Jul  8 13:57:13 2009
@@ -22,11 +22,16 @@
 import javax.jcr.Repository;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.Ordering;
+import javax.jcr.query.qom.DynamicOperand;
+
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.Arrays;
 import java.util.List;
 import java.util.ArrayList;
+import java.math.BigDecimal;
 
 /**
  * Abstract base class for all order by tests. Provides utility methods.
@@ -55,7 +60,24 @@
             Node node = testRootNode.addNode(nodeNames[i], testNodeType);
             node.setProperty(propertyName1, values[i]);
         }
-        testRootNode.save();
+        superuser.save();
+    }
+
+    /**
+     * Populates the workspace with child nodes under <code>testroot</code> with
+     * each node has a value set in property with name
+     * <code>propertyname1</code>. The actual value is created by using the
+     * sessions value factory and the given <code>type</code>.
+     *
+     * @param values the String values.
+     * @param type a JCR property type.
+     */
+    protected void populate(String[] values, int type) throws RepositoryException {
+        for (int i = 0; i < values.length; i++) {
+            Node node = testRootNode.addNode(nodeNames[i], testNodeType);
+            node.setProperty(propertyName1, vf.createValue(values[i], type));
+        }
+        superuser.save();
     }
 
     /**
@@ -69,7 +91,7 @@
             Node node = testRootNode.addNode(nodeNames[i], testNodeType);
             node.setProperty(propertyName1, values[i]);
         }
-        testRootNode.save();
+        superuser.save();
     }
 
     /**
@@ -83,7 +105,7 @@
             Node node = testRootNode.addNode(nodeNames[i], testNodeType);
             node.setProperty(propertyName1, values[i]);
         }
-        testRootNode.save();
+        superuser.save();
     }
 
     /**
@@ -97,7 +119,21 @@
             Node node = testRootNode.addNode(nodeNames[i], testNodeType);
             node.setProperty(propertyName1, values[i]);
         }
-        testRootNode.save();
+        superuser.save();
+    }
+
+    /**
+     * Populates the workspace with child nodes under <code>testroot</code> with
+     * each node has a decimal value set in property with name
+     * <code>propertyname1</code>.
+     * @param values the decimal values.
+     */
+    protected void populate(BigDecimal[] values) throws RepositoryException {
+        for (int i = 0; i < values.length; i++) {
+            Node node = testRootNode.addNode(nodeNames[i], testNodeType);
+            node.setProperty(propertyName1, values[i]);
+        }
+        superuser.save();
     }
 
     /**
@@ -108,31 +144,42 @@
     protected void checkOrder(String[] nodeNames) throws RepositoryException {
         // first check ascending
 
-        String sql = "SELECT " + escapeIdentifierForSQL(propertyName1) + " FROM " + escapeIdentifierForSQL(testNodeType) + " WHERE " +
-                    jcrPath + " LIKE '" + testRoot + "/%' ORDER BY " + escapeIdentifierForSQL(propertyName1);
-        String xpath = "/" + jcrRoot + testRoot + "/*[@jcr:primaryType='" + testNodeType + "'] order by @" + propertyName1;
+        String sql = createSQL();
+        String xpath = createXPath();
         Query q;
         QueryResult result;
-        if (checkSQL) {
+        if (sql != null) {
             q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
             result = q.execute();
             checkResultOrder(result, nodeNames);
         }
 
-        q = superuser.getWorkspace().getQueryManager().createQuery(xpath, Query.XPATH);
+        if (xpath != null) {
+            q = superuser.getWorkspace().getQueryManager().createQuery(xpath, Query.XPATH);
+            result = q.execute();
+            checkResultOrder(result, nodeNames);
+        }
+
+        q = createQOM(true);
         result = q.execute();
         checkResultOrder(result, nodeNames);
 
         // then check descending
         Collections.reverse(Arrays.asList(nodeNames));
 
-        if (checkSQL) {
+        if (sql != null) {
             q = superuser.getWorkspace().getQueryManager().createQuery(sql + " DESC", Query.SQL);
             result = q.execute();
             checkResultOrder(result, nodeNames);
         }
 
-        q = superuser.getWorkspace().getQueryManager().createQuery(xpath + " descending", Query.XPATH);
+        if (xpath != null) {
+            q = superuser.getWorkspace().getQueryManager().createQuery(xpath + " descending", Query.XPATH);
+            result = q.execute();
+            checkResultOrder(result, nodeNames);
+        }
+
+        q = createQOM(false);
         result = q.execute();
         checkResultOrder(result, nodeNames);
     }
@@ -157,4 +204,64 @@
         }
     }
 
+    /**
+     * @return a basic QOM to test order by queries.
+     * @throws RepositoryException if an error occurs.
+     */
+    protected QueryObjectModel createQOM(boolean ascending)
+            throws RepositoryException {
+        DynamicOperand op = createOrderingOperand();
+        Ordering ordering;
+        if (ascending) {
+            ordering = qf.ascending(op);
+        } else {
+            ordering = qf.descending(op);
+        }
+        return qf.createQuery(
+                qf.selector(testNodeType, "s"),
+                qf.descendantNode("s", testRoot),
+                new Ordering[]{ordering},
+                null
+        );
+    }
+
+    /**
+     * @return a dynamic operand that is used in the QOM created by
+     *         {@link #createQOM(boolean)}.
+     * @throws RepositoryException if an error occurs.
+     */
+    protected DynamicOperand createOrderingOperand()
+            throws RepositoryException {
+        return qf.propertyValue("s", propertyName1);
+    }
+
+    /**
+     * @return a basic SQL statement to test order by queries. Returns
+     *         <code>null</code> if SQL is not supported.
+     */
+    protected String createSQL() {
+        if (checkSQL) {
+            return "SELECT " + escapeIdentifierForSQL(propertyName1) +
+                    " FROM "+ escapeIdentifierForSQL(testNodeType) + " WHERE " +
+                    jcrPath + " LIKE '" + testRoot + "/%' ORDER BY " +
+                    escapeIdentifierForSQL(propertyName1);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * @return a basic XPath statement to test order by queries. Returns
+     *         <code>null</code> is XPath is not supported.
+     * @throws RepositoryException if an error occurs.
+     */
+    protected String createXPath() throws RepositoryException {
+        List languages = Arrays.asList(superuser.getWorkspace().getQueryManager().getSupportedQueryLanguages());
+        if (languages.contains(Query.XPATH)) {
+            return xpathRoot + "/*[@jcr:primaryType='" + testNodeType + "'] order by @" + propertyName1;
+        } else {
+            return null;
+        }
+    }
+
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java Wed Jul  8 13:57:13 2009
@@ -18,10 +18,13 @@
 
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.api.util.ISO9075;
 
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.RowIterator;
 import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.qom.QueryObjectModelFactory;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.Node;
@@ -32,6 +35,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Arrays;
 
 /**
  * Abstract base class for query test cases.
@@ -64,6 +68,24 @@
     protected String jcrDeref;
 
     /**
+     * The string /${jcrRoot}${testRoot} with all components of the test path
+     * properly escaped for XPath.
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/JCR-714">JCR-714</a>
+     */
+    protected String xpathRoot;
+
+    /**
+     * The query object model factory for {@link #superuser}.
+     */
+    protected QueryObjectModelFactory qf;
+
+    /**
+     * The query manager for {@link #superuser}
+     */
+    protected QueryManager qm;
+
+    /**
      * Set-up the configuration values used for the test. Per default retrieves
      * a session, configures testRoot, and nodetype and checks if the query
      * language for the current language is available.<br>
@@ -75,6 +97,15 @@
         jcrRoot = superuser.getNamespacePrefix(NS_JCR_URI) + ":root";
         jcrContains = superuser.getNamespacePrefix(NS_JCR_URI) + ":contains";
         jcrDeref = superuser.getNamespacePrefix(NS_JCR_URI) + ":deref";
+        xpathRoot = "/" + jcrRoot + ISO9075.encodePath(testRoot);
+        qm = superuser.getWorkspace().getQueryManager();
+        qf = qm.getQOMFactory();
+    }
+
+    protected void tearDown() throws Exception {
+        qm = null;
+        qf = null;
+        super.tearDown();
     }
 
     /**
@@ -321,4 +352,15 @@
             return '"' + identifier + '"';
         }
     }
+
+    /**
+     * @param language a query language.
+     * @return <code>true</code> if <code>language</code> is supported;
+     *         <code>false</code> otherwise.
+     * @throws RepositoryException if an error occurs.
+     */
+    protected boolean isSupportedLanguage(String language)
+            throws RepositoryException {
+        return Arrays.asList(qm.getSupportedQueryLanguages()).contains(language);
+    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/DerefQueryLevel1Test.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/DerefQueryLevel1Test.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/DerefQueryLevel1Test.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/DerefQueryLevel1Test.java Wed Jul  8 13:57:13 2009
@@ -47,7 +47,7 @@
     protected void setUp() throws Exception {
         isReadOnly = true;
         super.setUp();
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         testRootNode = session.getRootNode().getNode(testPath);
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetLanguageTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetLanguageTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetLanguageTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetLanguageTest.java Wed Jul  8 13:57:13 2009
@@ -17,9 +17,12 @@
 package org.apache.jackrabbit.test.api.query;
 
 import javax.jcr.query.Query;
+import javax.jcr.query.qom.QueryObjectModel;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * Test the method {@link Query#getLanguage()}.
  *
@@ -39,7 +42,7 @@
     protected void setUp() throws Exception {
         isReadOnly = true;
         super.setUp();
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         testRootNode = session.getRootNode().getNode(testPath);
     }
 
@@ -63,4 +66,40 @@
         Query q = session.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
         assertEquals("Query returns wrong language.", Query.XPATH, q.getLanguage());
     }
+
+    /**
+     * Tests if a SQL query returns {@link Query#SQL} when calling
+     * {@link Query#getLanguage()}.
+     */
+    public void testSQL() throws RepositoryException, NotExecutableException {
+        if (isSupportedLanguage(Query.SQL)) {
+            String stmt = "select * from " + testNodeType;
+            Query q = session.getWorkspace().getQueryManager().createQuery(stmt, Query.SQL);
+            assertEquals("Query returns wrong language.", Query.SQL, q.getLanguage());
+        } else {
+            throw new NotExecutableException("SQL not supported");
+        }
+    }
+
+    /**
+     * Tests if a JCR_SQL2 query returns {@link Query#JCR_SQL2} when calling
+     * {@link Query#getLanguage()}.
+     */
+    public void testJCRSQL2() throws RepositoryException {
+        String stmt = "SELECT * FROM [" + testNodeType + "]";
+        Query q = session.getWorkspace().getQueryManager().createQuery(stmt, Query.JCR_SQL2);
+        assertEquals("Query returns wrong language.", Query.JCR_SQL2, q.getLanguage());
+    }
+
+    /**
+     * Tests if a query object model returns {@link Query#JCR_JQOM} when calling
+     * {@link Query#getLanguage()}.
+     */
+    public void testJCRQOM() throws RepositoryException {
+        QueryObjectModel qom = qf.createQuery(
+                qf.selector(testNodeType, "s"),
+                null, null, null
+        );
+        assertEquals("Query returns wrong language.", Query.JCR_JQOM, qom.getLanguage());
+    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetPersistentQueryPathLevel1Test.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetPersistentQueryPathLevel1Test.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetPersistentQueryPathLevel1Test.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetPersistentQueryPathLevel1Test.java Wed Jul  8 13:57:13 2009
@@ -40,7 +40,7 @@
     protected void setUp() throws Exception {
         isReadOnly = true;
         super.setUp();
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         testRootNode = session.getRootNode().getNode(testPath);
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetPropertyNamesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetPropertyNamesTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetPropertyNamesTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetPropertyNamesTest.java Wed Jul  8 13:57:13 2009
@@ -45,7 +45,7 @@
     protected void setUp() throws Exception {
         isReadOnly = true;
         super.setUp();
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         testRootNode = session.getRootNode().getNode(testPath);
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetStatementTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetStatementTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetStatementTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetStatementTest.java Wed Jul  8 13:57:13 2009
@@ -39,7 +39,7 @@
     protected void setUp() throws Exception {
         isReadOnly = true;
         super.setUp();
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         testRootNode = session.getRootNode().getNode(testPath);
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetSupportedQueryLanguagesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetSupportedQueryLanguagesTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetSupportedQueryLanguagesTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetSupportedQueryLanguagesTest.java Wed Jul  8 13:57:13 2009
@@ -43,7 +43,7 @@
     protected void setUp() throws Exception {
         isReadOnly = true;
         super.setUp();
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         testRootNode = session.getRootNode().getNode(testPath);
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/PredicatesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/PredicatesTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/PredicatesTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/PredicatesTest.java Wed Jul  8 13:57:13 2009
@@ -55,7 +55,7 @@
     protected void setUp() throws Exception {
         isReadOnly = true;
         super.setUp();
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         testRootNode = session.getRootNode().getNode(testPath);
 
         nodeTypeName = session.getRootNode().getPrimaryNodeType().getName();
@@ -80,7 +80,8 @@
      * @throws RepositoryException
      */
     public void testEquality() throws RepositoryException {
-        String stmt = "/" + jcrRoot + "/" + testPath+ "/*[@" + jcrPrimaryType + "='" + nodeTypeName + "']";
+        String stmt =
+            xpathRoot + "/*[@" + jcrPrimaryType + "='" + nodeTypeName + "']";
 
         try {
             qm.createQuery(stmt, Query.XPATH);
@@ -95,7 +96,9 @@
      * @throws RepositoryException
      */
     public void testCombinedOr() throws RepositoryException {
-        String stmt = "/" + jcrRoot + "/" + testPath+ "/*[@" + jcrPrimaryType + "='" + nodeTypeName + "' or @" + jcrPrimaryType + "='" + ntBase + "']";
+        String stmt =
+            xpathRoot + "/*[@" + jcrPrimaryType + "='" + nodeTypeName
+            + "' or @" + jcrPrimaryType + "='" + ntBase + "']";
 
         try {
             qm.createQuery(stmt, Query.XPATH);
@@ -110,7 +113,8 @@
      * @throws RepositoryException
      */
     public void testOr() throws RepositoryException {
-        String stmt = "/" + jcrRoot + "/" + testPath+ "/*[@" + jcrPrimaryType + " or @" + jcrMixinTypes + "]";
+        String stmt =
+            xpathRoot + "/*[@" + jcrPrimaryType + " or @" + jcrMixinTypes + "]";
 
         try {
             qm.createQuery(stmt, Query.XPATH);
@@ -125,7 +129,8 @@
      * @throws RepositoryException
      */
     public void testAnd() throws RepositoryException {
-        String stmt = "/" + jcrRoot + "/" + testPath+ "/*[@" + jcrPrimaryType + " and @" + jcrMixinTypes + "]";
+        String stmt =
+            xpathRoot + "/*[@" + jcrPrimaryType + " and @" + jcrMixinTypes + "]";
 
         try {
             qm.createQuery(stmt, Query.XPATH);
@@ -140,7 +145,9 @@
      * @throws RepositoryException
      */
     public void testCombinedAnd() throws RepositoryException {
-        String stmt = "/" + jcrRoot + "/" + testPath+ "/*[@" + jcrPrimaryType + "='" + nodeTypeName + "' and @" + jcrPrimaryType + "='" + ntBase + "']";
+        String stmt =
+            xpathRoot + "/*[@" + jcrPrimaryType + "='" + nodeTypeName
+            + "' and @" + jcrPrimaryType + "='" + ntBase + "']";
 
         try {
             qm.createQuery(stmt, Query.XPATH);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/QueryResultNodeIteratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/QueryResultNodeIteratorTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/QueryResultNodeIteratorTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/QueryResultNodeIteratorTest.java Wed Jul  8 13:57:13 2009
@@ -54,7 +54,7 @@
      *          if getSize() returns -1 (unavailable).
      */
     public void testGetSize() throws RepositoryException, NotExecutableException {
-        NodeIterator it = execute(testPath + "//*", Query.XPATH).getNodes();
+        NodeIterator it = execute(xpathRoot + "//*", Query.XPATH).getNodes();
         long size = testRootNode.getNodes().getSize();
         if (size != -1) {
             long count = 0;
@@ -72,7 +72,7 @@
      * Tests the method <code>NodeIterator.getPosition()</code>.
      */
     public void testGetPosition() throws RepositoryException {
-        QueryResult rs = execute(testPath + "//*", Query.XPATH);
+        QueryResult rs = execute(xpathRoot + "//*", Query.XPATH);
 
         // getPosition initially returns 0
         NodeIterator it = rs.getNodes();
@@ -91,7 +91,7 @@
      * <code>NodeIterator</code>.
      */
     public void testGetPositionEmptyIterator() throws RepositoryException {
-        QueryResult rs = execute(testPath + "/" + nodeName4, Query.XPATH);
+        QueryResult rs = execute(xpathRoot + "/" + nodeName4, Query.XPATH);
 
         NodeIterator it = rs.getNodes();
         assertFalse("NodeIterator must be empty.", it.hasNext());
@@ -105,7 +105,7 @@
      * available.
      */
     public void testNoSuchElementException() throws RepositoryException {
-        NodeIterator it = execute(testPath + "//*", Query.XPATH).getNodes();
+        NodeIterator it = execute(xpathRoot + "//*", Query.XPATH).getNodes();
         while (it.hasNext()) {
             it.nextNode();
         }
@@ -121,7 +121,7 @@
      * Tests if {@link javax.jcr.NodeIterator#skip(long)} works correctly.
      */
     public void testSkip() throws RepositoryException {
-        String query = testPath + "//*";
+        String query = xpathRoot + "//*";
         QueryResult rs = execute(query, Query.XPATH);
         NodeIterator it = rs.getNodes();
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJcrPathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJcrPathTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJcrPathTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJcrPathTest.java Wed Jul  8 13:57:13 2009
@@ -43,7 +43,7 @@
     protected void setUp() throws Exception {
         isReadOnly = true;
         super.setUp();
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         testRootNode = session.getRootNode().getNode(testPath);
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJoinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJoinTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJoinTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJoinTest.java Wed Jul  8 13:57:13 2009
@@ -41,16 +41,15 @@
     /**
      * Test a SQL query with a primary and mixin nodetype join.
      */
-    public void testJoin() throws RepositoryException {
+    public void testJoin() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
         String testMixin = mixReferenceable;
         if (needsMixin(n1, testMixin)) {
-            n1.addMixin(testMixin);
-        }
-        else {
+            ensureMixinType(n1, testMixin);
+        } else {
             testMixin = mixVersionable;
             if (needsMixin(n1, testMixin)) {
-                n1.addMixin(testMixin);
+                ensureMixinType(n1, testMixin);
             }
         }
 
@@ -74,16 +73,16 @@
     /**
      * Test a SQL query with a nt:base primary type and mixin nodetype join.
      */
-    public void testJoinNtBase() throws RepositoryException {
+    public void testJoinNtBase() throws RepositoryException,
+            NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
         String testMixin = mixReferenceable;
         if (needsMixin(n1, testMixin)) {
-            n1.addMixin(testMixin);
-        }
-        else {
+            ensureMixinType(n1, testMixin);
+        } else {
             testMixin = mixVersionable;
             if (needsMixin(n1, testMixin)) {
-                n1.addMixin(testMixin);
+                ensureMixinType(n1, testMixin);
             }
         }
 
@@ -107,15 +106,12 @@
     /**
      * Test a SQL query with a primary type and mixin nodetype join.
      */
-    public void testJoinFilterPrimaryType() throws RepositoryException {
+    public void testJoinFilterPrimaryType()
+            throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixReferenceable)) {
-            n1.addMixin(mixReferenceable);
-        }
+        ensureMixinType(n1, mixReferenceable);
         Node n2 = testRootNode.addNode(nodeName2, ntBase);
-        if (needsMixin(n2, mixReferenceable)) {
-            n2.addMixin(mixReferenceable);
-        }
+        ensureMixinType(n2, mixReferenceable);
         testRootNode.save();
 
         StringBuffer query = new StringBuffer("SELECT * FROM ");
@@ -140,15 +136,13 @@
      */
     public void testJoinSNS() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixReferenceable)) {
-            n1.addMixin(mixReferenceable);
-        }
+        ensureMixinType(n1, mixReferenceable);
         if (!n1.getDefinition().allowsSameNameSiblings()) {
             throw new NotExecutableException("Node at " + testRoot + " does not allow same name siblings with name " + nodeName1);
         }
         testRootNode.addNode(nodeName1, testNodeType);
         Node n2 = testRootNode.addNode(nodeName2, testNodeType);
-        n2.addMixin(mixReferenceable);
+        ensureMixinType(n2, mixReferenceable);
         testRootNode.save();
 
         StringBuffer query = new StringBuffer("SELECT * FROM ");

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLPathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLPathTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLPathTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLPathTest.java Wed Jul  8 13:57:13 2009
@@ -41,7 +41,7 @@
     protected void setUp() throws Exception {
         isReadOnly = true;
         super.setUp();
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         // check precondition for this test
         if (testRootNode.hasNodes()) {
             for (NodeIterator it = testRootNode.getNodes(); it.hasNext();) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SaveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SaveTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SaveTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SaveTest.java Wed Jul  8 13:57:13 2009
@@ -133,13 +133,7 @@
         // create a node that is versionable
         Node versionable = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it versionable if it is not
-        if (!versionable.isNodeType(mixVersionable)) {
-            if (versionable.canAddMixin(mixVersionable)) {
-                versionable.addMixin(mixVersionable);
-            } else {
-                fail("Node " + nodeName1 + " is not versionable and does not allow to add mix:versionable");
-            }
-        }
+        ensureMixinType(versionable, mixVersionable);
         testRootNode.save();
         versionable.checkin();
 
@@ -191,17 +185,11 @@
         // create a node that is lockable
         Node lockable = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it lockable if it is not
-        if (!lockable.isNodeType(mixLockable)) {
-            if (lockable.canAddMixin(mixLockable)) {
-                lockable.addMixin(mixLockable);
-            } else {
-                fail("Node " + nodeName1 + " is not lockable and does not allow to add mix:lockable");
-            }
-        }
+        ensureMixinType(lockable, mixLockable);
         testRootNode.save();
         lockable.lock(false, true);
 
-        Session readWrite = helper.getReadWriteSession();
+        Session readWrite = getHelper().getReadWriteSession();
         try {
             Query query = readWrite.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
             query.storeAsNode(testRoot + "/" + nodeName1 + "/" + nodeName2);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SimpleSelectionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SimpleSelectionTest.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SimpleSelectionTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SimpleSelectionTest.java Wed Jul  8 13:57:13 2009
@@ -45,7 +45,7 @@
     protected void setUp() throws Exception {
         isReadOnly = true;
         super.setUp();
-        session = helper.getReadOnlySession();
+        session = getHelper().getReadOnlySession();
         testRootNode = session.getRootNode().getNode(testPath);
     }
 



Mime
View raw message