@Test
public void luceneWithFSDirectory() throws Exception{
//Issue is not reproducible with MemoryNodeBuilder and
//MemoryNodeState as they cannot determine change in childNode without
//entering
NodeStore nodeStore = new SegmentNodeStore();
final IndexTracker tracker = new IndexTracker();
((Observable)nodeStore).addObserver(new Observer() {
@Override
public void contentChanged(@Nonnull NodeState root, @Nullable CommitInfo info) {
tracker.update(root);
}
});
builder = nodeStore.getRoot().builder();
NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
NodeBuilder idxb = newLuceneIndexDefinition(index, "lucene",
ImmutableSet.of(TYPENAME_STRING));
idxb.setProperty(PERSISTENCE_NAME, PERSISTENCE_FILE);
idxb.setProperty(PERSISTENCE_PATH, getIndexDir());
nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
builder = nodeStore.getRoot().builder();
builder.setProperty("foo", "bar");
NodeState indexed = nodeStore.merge(builder, HOOK, CommitInfo.EMPTY);
assertQuery(tracker, indexed, "foo", "bar");
builder = nodeStore.getRoot().builder();
builder.setProperty("foo2", "bar2");
indexed = nodeStore.merge(builder, HOOK, CommitInfo.EMPTY);
assertQuery(tracker, indexed, "foo2", "bar2");
}