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 re...@apache.org on 2017/03/15 16:24:10 UTC

svn commit: r1787074 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTestBase.java

Author: reschke
Date: Wed Mar 15 16:24:10 2017
New Revision: 1787074

URL: http://svn.apache.org/viewvc?rev=1787074&view=rev
Log:
OAK-5930: incorrect test assumption in CacheConsistencyTestBase wrt batching

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTestBase.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTestBase.java?rev=1787074&r1=1787073&r2=1787074&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTestBase.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTestBase.java Wed Mar 15 16:24:10 2017
@@ -19,9 +19,11 @@ package org.apache.jackrabbit.oak.plugin
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Set;
 import java.util.UUID;
 
 import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 
 import org.junit.After;
 import org.junit.Before;
@@ -30,6 +32,7 @@ import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 public abstract class CacheConsistencyTestBase {
@@ -173,16 +176,24 @@ public abstract class CacheConsistencyTe
                 fail("should have failed with DocumentStoreException");
             } catch (DocumentStoreException ex) {
                 assertEquals("should fail with enforced exception", ex.getCause().getMessage(), random);
-                // make sure cache was invalidated
-                NodeDocument newdoc = ds.find(Collection.NODES, id1, 1000);
-                assertNotNull(newdoc);
-                assertEquals(random, newdoc.get("_test"));
-                newdoc = ds.find(Collection.NODES, id2, 1000);
-                assertNotNull(newdoc);
-                assertEquals(random, newdoc.get("_test"));
-                newdoc = ds.find(Collection.NODES, id3, 1000);
-                assertNotNull(newdoc);
-                assertEquals(random, newdoc.get("_test"));
+
+                // expected post conditions:
+                // 1) at least one of the documents should be updated
+                // 2) for all documents: reading from cache and uncached
+                // should return the same document
+                Set<String> modifiedDocuments = Sets.newHashSet();
+
+                for (String id : new String[] { id1, id2, id3 }) {
+                    // get cached value
+                    NodeDocument newdoc = ds.find(Collection.NODES, id, 1000);
+                    if (random.equals(newdoc.get("_test"))) {
+                        modifiedDocuments.add(id);
+                    }
+                    // compare with persisted value
+                    assertEquals(newdoc.get("_test"), ds.find(Collection.NODES, id, 0).get("_test"));
+                }
+
+                assertTrue("at least one document should have been updated", !modifiedDocuments.isEmpty());
             }
         } finally {
             setTemporaryUpdateException(null);