Search in sources :

Example 96 with NodeBuilder

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));
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Version(javax.jcr.version.Version) Node(javax.jcr.Node) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 97 with NodeBuilder

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));
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Version(javax.jcr.version.Version) Node(javax.jcr.Node) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 98 with NodeBuilder

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);
}
Also used : IndexDefinitionBuilder(org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder) IndexInfo(org.apache.jackrabbit.oak.plugins.index.IndexInfo) AsyncIndexInfo(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) AsyncIndexInfo(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo) Test(org.junit.Test)

Example 99 with NodeBuilder

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) {
    }
}
Also used : IndexUpdateCallback(org.apache.jackrabbit.oak.plugins.index.IndexUpdateCallback) DocumentQueue(org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Editor(org.apache.jackrabbit.oak.spi.commit.Editor) Test(org.junit.Test)

Example 100 with NodeBuilder

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());
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Aggregations

NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1190 Test (org.junit.Test)849 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)338 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)96 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)82 LuceneIndexHelper.newLuceneIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition)80 LuceneIndexHelper.newLucenePropertyIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition)77 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)75 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)73 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)69 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)64 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)61 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)43 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)40 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)38 Blob (org.apache.jackrabbit.oak.api.Blob)36 ArrayList (java.util.ArrayList)29 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)29 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)28 Nonnull (javax.annotation.Nonnull)26