jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r390402 - /jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/DerefTest.java
Date Fri, 31 Mar 2006 12:15:22 GMT
Author: mreutegg
Date: Fri Mar 31 04:15:17 2006
New Revision: 390402

URL: http://svn.apache.org/viewcvs?rev=390402&view=rev
Log:
Add jcr:deref test case that checks dereferencing into version storage

Modified:
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/DerefTest.java

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/DerefTest.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/DerefTest.java?rev=390402&r1=390401&r2=390402&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/DerefTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/DerefTest.java
Fri Mar 31 04:15:17 2006
@@ -17,6 +17,11 @@
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.NodeIterator;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+import javax.jcr.version.Version;
 
 /**
  * Tests the jcr:deref() function.
@@ -108,5 +113,32 @@
 
         executeXPathQuery(testPath + "/people/*/jcr:deref(@worksfor, '*')[jcr:contains(.,'ballmer')]",
                 new Node[]{microsoft});
+    }
+
+    /**
+     * Checks if jcr:deref works when dereferencing into the version storage.
+     */
+    public void testDerefToVersionNode() throws RepositoryException {
+        Node referenced = testRootNode.addNode(nodeName1);
+        referenced.addMixin(mixVersionable);
+        testRootNode.save();
+
+        Version version = referenced.checkin();
+        Node referencedVersionNode = version.getNode(jcrFrozenNode);
+        Node referencer = testRootNode.addNode(nodeName2);
+        referencer.setProperty(propertyName1, referencedVersionNode);
+        testRootNode.save();
+
+        String query = "/" + testRoot + "/*[@" + propertyName1 +
+                "]/jcr:deref(@" + propertyName1 + ",'*')";
+        QueryManager qm = superuser.getWorkspace().getQueryManager();
+        Query q = qm.createQuery(query, Query.XPATH);
+        QueryResult qr = q.execute();
+        NodeIterator ni = qr.getNodes();
+        assertEquals("Must find one result in query", 1, ni.getSize());
+        while (ni.hasNext()) {
+            Node node = (Node) ni.next();
+            assertTrue(node.getProperty("jcr:frozenUuid").getString().equals(referenced.getUUID()));
+        }
     }
 }



Mime
View raw message