jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1342679 - /jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
Date Fri, 25 May 2012 15:14:52 GMT
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();
 



Mime
View raw message