use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class HiddenNodeTest method hiddenChildOrderProperty.
@Test
public void hiddenChildOrderProperty() throws Exception {
Node test = session.getRootNode().addNode("test", "nt:unstructured");
Node child = test.addNode("child");
child.addNode("a");
child.addNode("b");
child.addNode("c");
test.addMixin("mix:versionable");
session.save();
NodeBuilder testBuilder = store.getRoot().builder().getChildNode("test").getChildNode("child");
assertTrue(testBuilder.hasProperty(TreeConstants.OAK_CHILD_ORDER));
session.refresh(false);
Version v1 = vMgr.checkpoint("/test");
Version v2 = vMgr.checkpoint("/test");
NodeState state = store.getRoot();
for (String name : PathUtils.elements(v2.getPath())) {
state = state.getChildNode(name);
}
state = state.getChildNode(VersionConstants.JCR_FROZENNODE).getChildNode("child");
assertTrue(state.exists());
assertTrue(state.hasProperty(TreeConstants.OAK_CHILD_ORDER));
vMgr.restore(v1, true);
state = store.getRoot().getChildNode("test").getChildNode("child");
assertTrue(state.hasProperty(TreeConstants.OAK_CHILD_ORDER));
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class HiddenNodeTest method hiddenOrderProperty.
@Test
public void hiddenOrderProperty() throws Exception {
Node test = session.getRootNode().addNode("test", "nt:unstructured");
test.addNode("a");
test.addNode("b");
test.addNode("c");
test.addMixin("mix:versionable");
session.save();
NodeBuilder testBuilder = store.getRoot().builder().getChildNode("test");
assertTrue(testBuilder.hasProperty(TreeConstants.OAK_CHILD_ORDER));
session.refresh(false);
Version v1 = vMgr.checkpoint("/test");
Version v2 = vMgr.checkpoint("/test");
NodeState state = store.getRoot();
for (String name : PathUtils.elements(v2.getPath())) {
state = state.getChildNode(name);
}
state = state.getChildNode(VersionConstants.JCR_FROZENNODE);
assertTrue(state.exists());
assertTrue(state.hasProperty(TreeConstants.OAK_CHILD_ORDER));
vMgr.restore(v1, true);
state = store.getRoot().getChildNode("test");
assertTrue(state.hasProperty(TreeConstants.OAK_CHILD_ORDER));
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class LuceneIndexInfoProviderTest method info.
@Test
public void info() throws Exception {
IndexDefinitionBuilder defnBuilder = new IndexDefinitionBuilder();
NodeBuilder builder = store.getRoot().builder();
builder.child("oak:index").setChildNode("fooIndex", defnBuilder.build());
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
when(asyncService.getInfo("async")).thenReturn(new AsyncIndexInfo("async", 0, 0, false, null));
IndexInfo info = provider.getInfo("/oak:index/fooIndex");
assertNotNull(info);
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class LuceneIndexEditorProviderTest method readOnlyBuilderUsedForSync.
@Test
public void readOnlyBuilderUsedForSync() throws Exception {
LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider(null, null, null, null, Mounts.defaultMountInfoProvider());
editorProvider.setIndexingQueue(mock(DocumentQueue.class));
IndexUpdateCallback callback = new TestCallback("/oak:index/fooIndex", newCommitInfo(), false, false);
NodeBuilder defnBuilder = createIndexDefinition("fooIndex").builder();
Editor editor = editorProvider.getIndexEditor(TYPE_LUCENE, defnBuilder, root, callback);
LuceneIndexEditor luceneEditor = (LuceneIndexEditor) editor;
NodeBuilder builderFromContext = (NodeBuilder) FieldUtils.readField(luceneEditor.getContext(), "definitionBuilder", true);
try {
builderFromContext.setProperty("foo", "bar");
fail("Should have been read only builder");
} catch (UnsupportedOperationException ignore) {
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class LuceneIndexEditorTest method noOfDocsIndexedNonFullText.
@Test
public void noOfDocsIndexedNonFullText() throws Exception {
NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
NodeBuilder nb = newLuceneIndexDefinitionV2(index, "lucene", of(TYPENAME_STRING));
nb.setProperty(LuceneIndexConstants.FULL_TEXT_ENABLED, false);
nb.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("foo"), STRINGS));
NodeState before = builder.getNodeState();
builder.child("test").setProperty("foo", "fox is jumping");
builder.child("test2").setProperty("bar", "kite is flying");
builder.child("test3").setProperty("foo", "wind is blowing");
NodeState after = builder.getNodeState();
NodeState indexed = HOOK.processCommit(before, after, CommitInfo.EMPTY);
tracker.update(indexed);
assertEquals(2, getSearcher().getIndexReader().numDocs());
}
Aggregations