use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class PropertyIndexTest method traversalWarning.
@Test
public void traversalWarning() throws Exception {
ListAppender appender = createAndRegisterAppender();
int testDataSize = ContentMirrorStoreStrategy.TRAVERSING_WARN;
NodeState indexed = createTestData(testDataSize);
assertEquals(testDataSize, getResultSize(indexed, "foo", "bar"));
assertFalse(appender.list.isEmpty());
appender.list.clear();
testDataSize = 100;
indexed = createTestData(100);
assertEquals(testDataSize, getResultSize(indexed, "foo", "bar"));
assertTrue("Warning should not be logged for traversing " + testDataSize, appender.list.isEmpty());
deregisterAppender(appender);
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class PropertyIndexTest method createTestData.
private NodeState createTestData(int entryCount) throws CommitFailedException {
NodeState root = INITIAL_CONTENT;
// Add index definition
NodeBuilder builder = root.builder();
NodeBuilder index = createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "foo", true, false, ImmutableSet.of("foo"), null);
// disable the estimation
index.setProperty("entryCount", -1);
NodeState before = builder.getNodeState();
// Add some content and process it through the property index hook
int depth = ContentMirrorStoreStrategy.TRAVERSING_WARN / entryCount + 10;
for (int i = 0; i < entryCount; i++) {
NodeBuilder parentNode = builder.child("n" + i);
for (int j = 0; j < depth; j++) {
parentNode = parentNode.child("c" + j);
}
parentNode.setProperty("foo", "bar");
}
NodeState after = builder.getNodeState();
return HOOK.processCommit(before, after, CommitInfo.EMPTY);
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class PropertyIndexTest method mountAndUniqueIndexes.
@Test(expected = CommitFailedException.class)
public void mountAndUniqueIndexes() throws Exception {
NodeState root = INITIAL_CONTENT;
// Add index definition
NodeBuilder builder = root.builder();
NodeBuilder index = createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "foo", true, true, ImmutableSet.of("foo"), null);
index.setProperty("entryCount", -1);
NodeState before = builder.getNodeState();
MountInfoProvider mip = Mounts.newBuilder().mount("foo", "/a").build();
builder.child("a").setProperty("foo", "abc");
builder.child("b").setProperty("foo", Arrays.asList("abc", "def"), Type.STRINGS);
NodeState after = builder.getNodeState();
EditorHook hook = new EditorHook(new IndexUpdateProvider(new PropertyIndexEditorProvider().with(mip)));
// should throw
hook.processCommit(before, after, CommitInfo.EMPTY);
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class PropertyIndexStatsTest method prepareStore.
private void prepareStore() throws CommitFailedException {
activateMBean();
NodeState root = store.getRoot();
NodeBuilder builder = root.builder();
new InitialContent().initialize(builder);
store.merge(builder, HOOK, CommitInfo.EMPTY);
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class ReferenceIndexTest method removeReferencedNode.
@Test
public void removeReferencedNode() throws Exception {
NodeState root = INITIAL_CONTENT;
NodeBuilder builder = root.builder();
NodeState before = builder.getNodeState();
builder.child("a").setProperty(createProperty(JCR_UUID, "u1", Type.STRING));
builder.child("b").setProperty(createProperty("foo", "u1", Type.REFERENCE));
NodeState after = builder.getNodeState();
EditorHook hook = new EditorHook(new IndexUpdateProvider(new ReferenceEditorProvider()));
NodeState indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
builder = indexed.builder();
builder.getChildNode("a").remove();
thrown.expect(CommitFailedException.class);
thrown.expectMessage("OakIntegrity0001: Unable to delete referenced node");
hook.processCommit(indexed, builder.getNodeState(), CommitInfo.EMPTY);
}
Aggregations