Search in sources :

Example 56 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class IndexUpdateTest method testReindexSyncMissingProvider.

/**
     * OAK-2203 Test reindex behavior on a sync index when the index provider is missing
     * for a given type
     */
@Test
public void testReindexSyncMissingProvider() throws Exception {
    EditorHook hook = new EditorHook(new IndexUpdateProvider(emptyProvider()));
    NodeState before = builder.getNodeState();
    createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null);
    builder.child(INDEX_DEFINITIONS_NAME).child("azerty");
    builder.child("testRoot").setProperty("foo", "abc");
    NodeState after = builder.getNodeState();
    NodeState indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
    NodeState rootIndex = checkPathExists(indexed, INDEX_DEFINITIONS_NAME, "rootIndex");
    PropertyState ps = rootIndex.getProperty(REINDEX_PROPERTY_NAME);
    assertNotNull(ps);
    assertTrue(ps.getValue(Type.BOOLEAN));
    NodeState azerty = checkPathExists(indexed, INDEX_DEFINITIONS_NAME, "azerty");
    assertNull("Node should be ignored by reindexer", azerty.getProperty(REINDEX_PROPERTY_NAME));
}
Also used : EmptyNodeState(org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 57 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class IndexUpdateTest method testReindexHidden.

@Test
public void testReindexHidden() throws Exception {
    NodeState before = EmptyNodeState.EMPTY_NODE;
    NodeBuilder builder = before.builder();
    builder.child(":testRoot").setProperty("foo", "abc");
    createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", false, false, ImmutableSet.of("foo"), null);
    NodeState after = builder.getNodeState();
    NodeState indexed = HOOK.processCommit(before, after, CommitInfo.EMPTY);
    // first check that the index content nodes exist
    NodeState ns = checkPathExists(indexed, INDEX_DEFINITIONS_NAME, "rootIndex");
    NodeState index = checkPathExists(ns, INDEX_CONTENT_NODE_NAME);
    PropertyState ps = ns.getProperty(REINDEX_PROPERTY_NAME);
    assertNotNull(ps);
    assertFalse(ps.getValue(Type.BOOLEAN));
    assertFalse(index.getChildNodeCount(1) > 0);
    before = indexed;
    builder = before.builder();
    builder.child(INDEX_DEFINITIONS_NAME).child("rootIndex").setProperty("reindex", true);
    after = builder.getNodeState();
    indexed = HOOK.processCommit(before, after, CommitInfo.EMPTY);
    index = checkPathExists(ns, INDEX_CONTENT_NODE_NAME);
    ps = ns.getProperty(REINDEX_PROPERTY_NAME);
    assertNotNull(ps);
    assertFalse(ps.getValue(Type.BOOLEAN));
    assertFalse(index.getChildNodeCount(1) > 0);
}
Also used : EmptyNodeState(org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 58 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class IndexUpdateTest method testReindexAuto.

/**
     * Auto Reindex Test
     * <ul>
     * <li>Add some content</li>
     * <li>Add an index definition without a reindex flag (see OAK-1874)</li>
     * <li>Search & verify</li>
     * </ul>
     */
@Test
public void testReindexAuto() throws Exception {
    builder.child("testRoot").setProperty("foo", "abc");
    NodeState before = builder.getNodeState();
    createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", false, false, ImmutableSet.of("foo"), null);
    NodeState after = builder.getNodeState();
    NodeState indexed = HOOK.processCommit(before, after, CommitInfo.EMPTY);
    // first check that the index content nodes exist
    NodeState ns = checkPathExists(indexed, INDEX_DEFINITIONS_NAME, "rootIndex");
    checkPathExists(ns, INDEX_CONTENT_NODE_NAME);
    PropertyState ps = ns.getProperty(REINDEX_PROPERTY_NAME);
    assertNotNull(ps);
    assertFalse(ps.getValue(Type.BOOLEAN));
    // next, lookup
    PropertyIndexLookup lookup = new PropertyIndexLookup(indexed);
    assertEquals(ImmutableSet.of("testRoot"), find(lookup, "foo", "abc"));
}
Also used : EmptyNodeState(org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) PropertyIndexLookup(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexLookup) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 59 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class TreeTest method testGetPropertyStatus.

@Test
public void testGetPropertyStatus() throws Exception {
    setupPermission("/a", testPrincipal, false, PrivilegeConstants.REP_READ_NODES);
    testRoot.refresh();
    Tree a = testRoot.getTree("/a");
    assertFalse(a.exists());
    PropertyState p = a.getProperty(JcrConstants.JCR_PRIMARYTYPE);
    assertNotNull(p);
    assertEquals(Tree.Status.UNCHANGED, a.getPropertyStatus(JcrConstants.JCR_PRIMARYTYPE));
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 60 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class HiddenPropertyTest method testGetProperties.

@Test
public void testGetProperties() {
    Set<String> propertyNames = Sets.newHashSet(JcrConstants.JCR_PRIMARYTYPE, "aProp");
    Tree a = root.getTree("/a");
    for (PropertyState prop : a.getProperties()) {
        assertTrue(propertyNames.remove(prop.getName()));
    }
    assertTrue(propertyNames.isEmpty());
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Aggregations

PropertyState (org.apache.jackrabbit.oak.api.PropertyState)404 Test (org.junit.Test)189 Tree (org.apache.jackrabbit.oak.api.Tree)138 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)49 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)45 Nonnull (javax.annotation.Nonnull)31 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)29 RemoteTree (org.apache.jackrabbit.oak.remote.RemoteTree)28 RemoteValue (org.apache.jackrabbit.oak.remote.RemoteValue)28 Blob (org.apache.jackrabbit.oak.api.Blob)21 ArrayList (java.util.ArrayList)20 LongPropertyState (org.apache.jackrabbit.oak.plugins.memory.LongPropertyState)17 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)16 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)14 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)13 CheckForNull (javax.annotation.CheckForNull)12 RepositoryException (javax.jcr.RepositoryException)10 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)10 Map (java.util.Map)9 Value (javax.jcr.Value)9