use of org.apache.jackrabbit.oak.spi.filter.PathFilter in project jackrabbit-oak by apache.
the class NodeCacheTest method cachePredicateSync.
@Test
public void cachePredicateSync() throws Exception {
PathFilter pf = new PathFilter(asList("/a"), emptyList());
Predicate<String> p = path -> pf.filter(path) == PathFilter.Result.INCLUDE;
initializeNodeStore(false, b -> b.setNodeCachePredicate(p));
NodeBuilder builder = ns.getRoot().builder();
builder.child("a").child("c1");
builder.child("b").child("c2");
ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
// Do a read again
ns.getRoot().getChildNode("a").getChildNode("c1");
ns.getRoot().getChildNode("b").getChildNode("c2");
assertNotContains(nodeCache, "/b");
assertNotContains(nodeCache, "/b/c2");
assertContains(nodeCache, "/a");
assertContains(nodeCache, "/a/c1");
}
use of org.apache.jackrabbit.oak.spi.filter.PathFilter in project jackrabbit-oak by apache.
the class SecondaryStoreObserverTest method childNodeDeleted.
@Test
public void childNodeDeleted() throws Exception {
PathFilter pathFilter = new PathFilter(of("/a"), empty);
SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver();
primary.addObserver(observer);
NodeBuilder nb = primary.getRoot().builder();
create(nb, "/a/b", "/a/c", "/x/y/z");
primary.merge(nb, EmptyHook.INSTANCE, CommitInfo.EMPTY);
nb = primary.getRoot().builder();
nb.child("a").child("c").remove();
primary.merge(nb, EmptyHook.INSTANCE, CommitInfo.EMPTY);
assertFalse(NodeStateUtils.getNode(secondaryRoot(), "/a/c").exists());
}
use of org.apache.jackrabbit.oak.spi.filter.PathFilter in project jackrabbit-oak by apache.
the class SecondaryStoreObserverTest method childNodeAdded.
@Test
public void childNodeAdded() throws Exception {
PathFilter pathFilter = new PathFilter(of("/a"), empty);
SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver();
primary.addObserver(observer);
NodeBuilder nb = primary.getRoot().builder();
create(nb, "/a/b", "/a/c", "/x/y/z");
primary.merge(nb, EmptyHook.INSTANCE, CommitInfo.EMPTY);
nb = primary.getRoot().builder();
create(nb, "/a/d");
primary.merge(nb, EmptyHook.INSTANCE, CommitInfo.EMPTY);
assertMetaState(primary.getRoot(), secondaryRoot(), "/a/d");
assertMetaState(primary.getRoot(), secondaryRoot(), "/a");
}
use of org.apache.jackrabbit.oak.spi.filter.PathFilter in project jackrabbit-oak by apache.
the class SecondaryStoreObserverTest method childNodeChangedAndExclude.
@Test
public void childNodeChangedAndExclude() throws Exception {
PathFilter pathFilter = new PathFilter(of("/a"), of("a/b"));
SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver();
primary.addObserver(observer);
NodeBuilder nb = primary.getRoot().builder();
create(nb, "/a/b", "/a/c", "/x/y/z");
primary.merge(nb, EmptyHook.INSTANCE, CommitInfo.EMPTY);
nb = primary.getRoot().builder();
create(nb, "/a/d", "/a/b/e");
primary.merge(nb, EmptyHook.INSTANCE, CommitInfo.EMPTY);
assertMetaState(primary.getRoot(), secondaryRoot(), "/a/d");
}
use of org.apache.jackrabbit.oak.spi.filter.PathFilter in project jackrabbit-oak by apache.
the class SecondaryStoreCacheTest method bundledNodes.
@Test
public void bundledNodes() throws Exception {
SecondaryStoreCache cache = createCache(new PathFilter(of("/"), empty));
primary.setNodeStateCache(cache);
NodeBuilder builder = primary.getRoot().builder();
new InitialContent().initialize(builder);
BundlingConfigInitializer.INSTANCE.initialize(builder);
merge(builder);
BundledTypesRegistry registry = BundledTypesRegistry.from(NodeStateUtils.getNode(primary.getRoot(), BundlingConfigHandler.CONFIG_PATH));
assertNotNull("DocumentBundling not found to be enabled for nt:file", registry.getBundlor(newNode("nt:file").getNodeState()));
// 1. Create a file node
builder = primary.getRoot().builder();
NodeBuilder fileNode = newNode("nt:file");
fileNode.child("jcr:content").setProperty("jcr:data", "foo");
builder.child("test").setChildNode("book.jpg", fileNode.getNodeState());
merge(builder);
// 2. Assert that bundling is working
assertNull(getNodeDocument("/test/book.jpg/jcr:content"));
// 3. Now update the file node
builder = primary.getRoot().builder();
builder.getChildNode("test").getChildNode("book.jpg").getChildNode("jcr:content").setProperty("foo", "bar");
merge(builder);
}
Aggregations