use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class IndexUpdateTest method testReindexAsync.
/**
* Async Reindex Test (OAK-2174)
* <ul>
* <li>Add some content</li>
* <li>Add an index definition with the reindex flag and the reindex-async flag set</li>
* <li>Run the background async job manually</li>
* <li>Search & verify</li>
* </ul>
*/
@Test
public void testReindexAsync() throws Exception {
IndexEditorProvider provider = new PropertyIndexEditorProvider();
EditorHook hook = new EditorHook(new IndexUpdateProvider(provider));
NodeStore store = new MemoryNodeStore();
NodeBuilder builder = store.getRoot().builder();
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null).setProperty(REINDEX_ASYNC_PROPERTY_NAME, true);
builder.child("testRoot").setProperty("foo", "abc");
// merge it back in
store.merge(builder, hook, CommitInfo.EMPTY);
// first check that the async flag exist
NodeState ns1 = checkPathExists(store.getRoot(), INDEX_DEFINITIONS_NAME, "rootIndex");
assertTrue(ns1.getProperty(REINDEX_PROPERTY_NAME).getValue(Type.BOOLEAN));
assertTrue(ns1.getProperty(REINDEX_ASYNC_PROPERTY_NAME).getValue(Type.BOOLEAN));
assertEquals(ASYNC_REINDEX_VALUE, ns1.getString(ASYNC_PROPERTY_NAME));
AsyncIndexUpdate async = new AsyncIndexUpdate(ASYNC_REINDEX_VALUE, store, provider, true);
int max = 5;
// same behaviour as PropertyIndexAsyncReindex mbean
boolean done = false;
int count = 0;
while (!done || count >= max) {
async.run();
done = async.isFinished();
count++;
}
// first check that the index content nodes exist
NodeState ns = checkPathExists(store.getRoot(), INDEX_DEFINITIONS_NAME, "rootIndex");
checkPathExists(ns, INDEX_CONTENT_NODE_NAME);
assertFalse(ns.getProperty(REINDEX_PROPERTY_NAME).getValue(Type.BOOLEAN));
assertNull(ns.getProperty(ASYNC_PROPERTY_NAME));
// next, lookup
PropertyIndexLookup lookup = new PropertyIndexLookup(store.getRoot());
assertEquals(ImmutableSet.of("testRoot"), find(lookup, "foo", "abc"));
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class NodeStateCopierTest method shouldIgnoreNonMatchingMergePaths.
@Test
public void shouldIgnoreNonMatchingMergePaths() throws CommitFailedException, IOException {
final NodeStore source = createNodeStoreWithContent("/content/foo");
final NodeStore target = createNodeStoreWithContent("/content/bar");
final NodeState before = target.getRoot();
builder().merge("/con").copy(source, target);
final NodeState after = target.getRoot();
expectDifference().strict().childNodeAdded("/content/foo").childNodeChanged("/content").childNodeDeleted("/content/bar").verify(before, after);
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class NodeStateCopierTest method shouldIncludeMultiplePaths.
@Test
public void shouldIncludeMultiplePaths() throws CommitFailedException, IOException {
final NodeStore source = createPrefilledNodeStore();
final NodeStore target = createNodeStoreWithContent();
builder().include("/a/b/c/d", "/a/b/c/e").copy(source, target);
expectDifference().propertyDeleted("/a/b/c/f/jcr:primaryType").childNodeChanged("/a", "/a/b", "/a/b/c").childNodeDeleted("/excluded", "/a/b/excluded", "/a/b/c/f").strict().verify(source.getRoot(), target.getRoot());
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class FilteringNodeStateTest method setup.
@Before
public void setup() throws RepositoryException, CommitFailedException, IOException {
final NodeStore nodeStore = createNodeStoreWithContent("/content/foo/de", "/content/foo/en", "/content/football/en", "/apps/foo/install", "/libs/foo/install");
final PropertyState childOrder = createProperty(OAK_CHILD_ORDER, asList("foo", "football"), Type.NAMES);
final NodeBuilder builder = nodeStore.getRoot().builder();
create(builder, "/content", childOrder);
commit(nodeStore, builder);
rootNodeState = nodeStore.getRoot();
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class NodeStateCopierTest method shouldDeleteExistingPropertyIfMissingInSource.
@Test
public void shouldDeleteExistingPropertyIfMissingInSource() throws CommitFailedException, IOException {
final NodeStore source = createNodeStoreWithContent("/a");
final NodeStore target = createNodeStoreWithContent();
final NodeBuilder builder = target.getRoot().builder();
create(builder, "/a", primaryType);
commit(target, builder);
final NodeState before = target.getRoot();
builder().copy(source, target);
final NodeState after = target.getRoot();
expectDifference().strict().propertyDeleted("/a/jcr:primaryType").childNodeChanged("/a").verify(before, after);
}
Aggregations