Author: mreutegg
Date: Tue Jun 21 09:18:42 2016
New Revision: 1749475
URL: http://svn.apache.org/viewvc?rev=1749475&view=rev
Log:
OAK-4489: Improve test coverage on DocumentStore for concurrent query and
invalidate
Add test for invalidateCache(Collection, String)
Modified:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndInvalidateIT.java
Modified:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndInvalidateIT.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndInvalidateIT.java?rev=1749475&r1=1749474&r2=1749475&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndInvalidateIT.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ConcurrentQueryAndInvalidateIT.java
Tue Jun 21 09:18:42 2016
@@ -43,16 +43,38 @@ public class ConcurrentQueryAndInvalidat
private volatile long counter;
@Test
- public void cacheUpdate() throws Exception {
- cacheUpdate(false);
+ public void cacheUpdateInvalidateWithIDs() throws Exception {
+ cacheUpdate(new Invalidate() {
+ @Override
+ public void perform(DocumentStore store, Iterable<String> ids) {
+ store.invalidateCache(ids);
+ }
+ });
}
@Test
public void cacheUpdateInvalidateAll() throws Exception {
- cacheUpdate(true);
+ cacheUpdate(new Invalidate() {
+ @Override
+ public void perform(DocumentStore store, Iterable<String> ids) {
+ store.invalidateCache();
+ }
+ });
}
- private void cacheUpdate(final boolean invalidateAll) throws Exception {
+ @Test
+ public void cacheUpdateInvalidateIndividual() throws Exception {
+ cacheUpdate(new Invalidate() {
+ @Override
+ public void perform(DocumentStore store, Iterable<String> ids) {
+ for (String id : ids) {
+ store.invalidateCache(NODES, id);
+ }
+ }
+ });
+ }
+
+ private void cacheUpdate(final Invalidate inv) throws Exception {
Revision r = newRevision();
List<UpdateOp> ops = Lists.newArrayList();
List<String> ids = Lists.newArrayList();
@@ -82,11 +104,7 @@ public class ConcurrentQueryAndInvalidat
// update docs on ds2
Iterable<String> ids = updateDocuments();
// invalidate docs on ds1
- if (invalidateAll) {
- ds1.invalidateCache();
- } else {
- ds1.invalidateCache(ids);
- }
+ inv.perform(ds1, ids);
}
});
q.start();
@@ -120,4 +138,8 @@ public class ConcurrentQueryAndInvalidat
ds2.update(NODES, ids, op);
return ids;
}
+
+ private interface Invalidate {
+ void perform(DocumentStore store, Iterable<String> ids);
+ }
}