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 17:55:05 UTC
svn commit: r1787086 - in /jackrabbit/oak/branches/1.6: ./
oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTestBase.java
Author: reschke
Date: Wed Mar 15 17:55:05 2017
New Revision: 1787086
URL: http://svn.apache.org/viewvc?rev=1787086&view=rev
Log:
OAK-5930: incorrect test assumption in CacheConsistencyTestBase wrt batching (ported to 1.6)
Modified:
jackrabbit/oak/branches/1.6/ (props changed)
jackrabbit/oak/branches/1.6/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTestBase.java
Propchange: jackrabbit/oak/branches/1.6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 15 17:55:05 2017
@@ -1,3 +1,3 @@
/jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1781068,1781075,1781248,1781386,1781846,1781907,1782000,1782029,1782196,1782447,1782476,1782770,1782945,1782973,1782990,1783061,1783066,1783089,1783104-1783105,1783619,1783731,1783733,1783742,1783855,1783891,1784023,1784130,1784162,1784251,1784401,1784551,1784574,1785095,1785108,1785283,1785838,1785919
+/jackrabbit/oak/trunk:1781068,1781075,1781248,1781386,1781846,1781907,1782000,1782029,1782196,1782447,1782476,1782770,1782945,1782973,1782990,1783061,1783066,1783089,1783104-1783105,1783619,1783731,1783733,1783742,1783855,1783891,1784023,1784130,1784162,1784251,1784401,1784551,1784574,1785095,1785108,1785283,1785838,1785919,1787074
/jackrabbit/trunk:1345480
Modified: jackrabbit/oak/branches/1.6/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTestBase.java?rev=1787086&r1=1787085&r2=1787086&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.6/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTestBase.java (original)
+++ jackrabbit/oak/branches/1.6/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CacheConsistencyTestBase.java Wed Mar 15 17:55:05 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);