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));
}
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);
}
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"));
}
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));
}
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());
}
Aggregations