You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by st...@apache.org on 2012/05/25 17:14:52 UTC

svn commit: r1342679 - /jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java

Author: stefan
Date: Fri May 25 15:14:51 2012
New Revision: 1342679

URL: http://svn.apache.org/viewvc?rev=1342679&view=rev
Log:
OAK-75: specify format and semantics of 'filter' parameter in MicroKernel API:

 test case for :hash semantics

Modified:
    jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java

Modified: jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java?rev=1342679&r1=1342678&r2=1342679&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java (original)
+++ jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java Fri May 25 15:14:51 2012
@@ -37,6 +37,7 @@ import java.util.Set;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -409,6 +410,46 @@ public class MicroKernelIT extends Abstr
     }
 
     @Test
+    public void getNodesHash() {
+        // :hash must be explicitly specified in the filter
+        JSONObject obj = parseJSONObject(mk.getNodes("/", null, 1, 0, -1, null));
+        assertPropertyNotExists(obj, ":hash");
+        obj = parseJSONObject(mk.getNodes("/", null, 1, 0, -1, "{properties:[\"*\"]}"));
+        assertPropertyNotExists(obj, ":hash");
+
+        // verify initial content with :hash property
+        obj = parseJSONObject(mk.getNodes("/", null, 1, 0, -1, "{properties:[\"*\",\":hash\"]}"));
+        assertPropertyValue(obj, "test/booleanProp", true);
+
+        assertPropertyExists(obj, ":hash", String.class);
+        assertPropertyExists(obj, "test/:hash", String.class);
+        String hash0 = (String) resolveValue(obj, ":hash");
+
+        // modify a property and verify that the hash of the root node changed
+        mk.commit("/test", "^\"booleanProp\":false", null, null);
+        obj = parseJSONObject(mk.getNodes("/", null, 1, 0, -1, "{properties:[\"*\",\":hash\"]}"));
+        assertPropertyValue(obj, "test/booleanProp", false);
+
+        assertPropertyExists(obj, ":hash", String.class);
+        assertPropertyExists(obj, "test/:hash", String.class);
+        String hash1 = (String) resolveValue(obj, ":hash");
+
+        assertFalse(hash0.equals(hash1));
+
+        // undo property modification and verify that the hash of the root node changed
+        mk.commit("/test", "^\"booleanProp\":true", null, null);
+        obj = parseJSONObject(mk.getNodes("/", null, 1, 0, -1, "{properties:[\"*\",\":hash\"]}"));
+        assertPropertyValue(obj, "test/booleanProp", true);
+
+        assertPropertyExists(obj, ":hash", String.class);
+        assertPropertyExists(obj, "test/:hash", String.class);
+        String hash2 = (String) resolveValue(obj, ":hash");
+
+        assertFalse(hash1.equals(hash2));
+        assertTrue(hash0.equals(hash2));
+    }
+
+    @Test
     public void getNodesFiltered() {
         String head = mk.getHeadRevision();