use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class DocumentBundlingTest method memory.
@Test
public void memory() throws Exception {
NodeBuilder builder = store.getRoot().builder();
NodeBuilder bundledFileNode = newNode("nt:file");
bundledFileNode.child("jcr:content").setProperty("jcr:data", "foo");
builder.child("test").setChildNode("book.jpg", bundledFileNode.getNodeState());
//Create a non bundled NodeState structure nt:File vs nt:file
NodeBuilder nonBundledFileNode = newNode("nt:File");
nonBundledFileNode.child("jcr:content").setProperty("jcr:data", "foo");
builder.child("test").setChildNode("book2.jpg", nonBundledFileNode.getNodeState());
merge(builder);
NodeState root = store.getRoot();
DocumentNodeState bundledFile = asDocumentState(getNode(root, "/test/book.jpg"));
DocumentNodeState nonBundledFile = asDocumentState(getNode(root, "/test/book2.jpg"));
DocumentNodeState nonBundledContent = asDocumentState(getNode(root, "/test/book2.jpg/jcr:content"));
int nonBundledMem = nonBundledFile.getMemory() + nonBundledContent.getMemory();
int bundledMem = bundledFile.getMemory();
assertEquals(1386, bundledMem);
assertThat(bundledMem, is(greaterThan(nonBundledMem)));
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class DocumentBundlingTest method bundledNodeAndNodeChildrenCache.
@Test
public void bundledNodeAndNodeChildrenCache() throws Exception {
NodeBuilder builder = store.getRoot().builder();
NodeBuilder appNB = newNode("app:Asset");
createChild(appNB, "jcr:content", //not bundled
"jcr:content/comments", "jcr:content/metadata", //not bundled
"jcr:content/metadata/xmp", //includes all
"jcr:content/renditions", "jcr:content/renditions/original", "jcr:content/renditions/original/jcr:content");
builder.child("test").setChildNode("book.jpg", appNB.getNodeState());
merge(builder);
Set<PathRev> cachedPaths = store.getNodeChildrenCache().asMap().keySet();
for (PathRev pr : cachedPaths) {
assertFalse(pr.getPath().contains("jcr:content/renditions"));
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class DocumentBundlingTest method journalDiffAndBundling.
@Test
public void journalDiffAndBundling() throws Exception {
NodeBuilder builder = store.getRoot().builder();
NodeBuilder fileNode = newNode("nt:file");
fileNode.child("jcr:content").setProperty("jcr:data", "foo");
builder.child("test").setChildNode("book.jpg", fileNode.getNodeState());
NodeState r1 = merge(builder);
builder = store.getRoot().builder();
childBuilder(builder, "/test/book.jpg/jcr:content").setProperty("fooContent", "bar");
childBuilder(builder, "/test/book.jpg").setProperty("fooBook", "bar");
NodeState r2 = merge(builder);
final List<String> addedPropertyNames = Lists.newArrayList();
r2.compareAgainstBaseState(r1, new DefaultNodeStateDiff() {
@Override
public boolean propertyAdded(PropertyState after) {
addedPropertyNames.add(after.getName());
return super.propertyAdded(after);
}
@Override
public boolean childNodeChanged(String name, NodeState before, NodeState after) {
return after.compareAgainstBaseState(before, this);
}
});
assertTrue("No change reported for /test/book.jpg", addedPropertyNames.contains("fooBook"));
assertTrue("No change reported for /test/book.jpg/jcr:content", addedPropertyNames.contains("fooContent"));
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class DocumentBundlingTest method addBundledNodePostInitialCreation.
@Test
public void addBundledNodePostInitialCreation() throws Exception {
NodeBuilder builder = store.getRoot().builder();
NodeBuilder appNB = newNode("app:Asset");
createChild(appNB, "jcr:content", //not bundled
"jcr:content/comments", "jcr:content/metadata", //not bundled
"jcr:content/metadata/xmp", //includes all
"jcr:content/renditions", "jcr:content/renditions/original", "jcr:content/renditions/original/jcr:content");
builder.child("test").setChildNode("book.jpg", appNB.getNodeState());
merge(builder);
builder = store.getRoot().builder();
NodeBuilder renditions = childBuilder(builder, "/test/book.jpg/jcr:content/renditions");
renditions.child("small").child("jcr:content");
NodeState appNode_v2 = childBuilder(builder, "/test/book.jpg").getNodeState();
merge(builder);
assertThat(childNames(getLatestNode("/test/book.jpg"), "jcr:content/renditions"), hasItems("original", "small"));
assertTrue(AssertingDiff.assertEquals(getLatestNode("/test/book.jpg"), appNode_v2));
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class DocumentBundlingTest method hasChildren_BundledNode_NoChild.
@Test
public void hasChildren_BundledNode_NoChild() throws Exception {
createTestNode("/test/book.jpg", createChild(newNode("app:Asset"), "jcr:content").getNodeState());
ds.reset();
assertEquals(0, Iterables.size(getLatestNode("test/book.jpg/jcr:content").getChildNodeNames()));
assertEquals(0, ds.queryPaths.size());
NodeBuilder builder = store.getRoot().builder();
childBuilder(builder, "/test/book.jpg/jcr:content/metadata");
merge(builder);
ds.reset();
assertEquals(1, Iterables.size(getLatestNode("test/book.jpg/jcr:content").getChildNodeNames()));
assertEquals(0, ds.queryPaths.size());
}
Aggregations