use of org.apache.jackrabbit.oak.spi.mount.MountInfoProvider in project jackrabbit-oak by apache.
the class LuceneIndexEditorTest method multiplexingWriter.
@Test
public void multiplexingWriter() throws Exception {
newLucenePropertyIndex("lucene", "foo");
MountInfoProvider mip = Mounts.newBuilder().mount("foo", "/libs", "/apps").build();
EditorHook hook = new EditorHook(new IndexUpdateProvider(new LuceneIndexEditorProvider(null, new ExtractedTextCache(0, 0), null, mip)));
NodeState indexed = hook.processCommit(EMPTY_NODE, builder.getNodeState(), CommitInfo.EMPTY);
builder = indexed.builder();
NodeState before = indexed;
builder.child("content").child("en").setProperty("foo", "bar");
builder.child("libs").child("install").setProperty("foo", "bar");
NodeState after = builder.getNodeState();
indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
builder = indexed.builder();
assertEquals(1, numDocs(mip.getMountByName("foo")));
assertEquals(1, numDocs(mip.getDefaultMount()));
}
use of org.apache.jackrabbit.oak.spi.mount.MountInfoProvider in project jackrabbit-oak by apache.
the class CompositeChildrenCountTest method multipleContributingStores.
@Test
public void multipleContributingStores() {
MountInfoProvider mip = Mounts.newBuilder().mount("libs", "/libs", "/libs1", "/libs2", "/libs3", "/libs4").build();
NodeStore globalStore = new MemoryNodeStore();
NodeStore libsStore = new MemoryNodeStore();
List<MountedNodeStore> mounts = Lists.newArrayList();
mounts.add(new MountedNodeStore(mip.getMountByName("libs"), libsStore));
CompositeNodeStore compositeNodeStore = new CompositeNodeStore(mip, globalStore, mounts);
CompositeNodeStoreBuilder b = new CompositeNodeStoreBuilder(compositeNodeStore.ctx);
TestingNodeState globalTestingNS = b.configureMount("/", 5);
TestingNodeState libsTestingNS = b.configureMount("/libs", "libs", "libs1", "libs2");
CompositeNodeState mns = b.getNodeState();
assertEquals(8, mns.getChildNodeCount(9));
assertEquals(5, globalTestingNS.fetchedChildren);
assertEquals(3, libsTestingNS.fetchedChildren);
globalTestingNS.fetchedChildren = 0;
libsTestingNS.fetchedChildren = 0;
assertEquals(MAX_VALUE, mns.getChildNodeCount(8));
assertEquals(5, globalTestingNS.fetchedChildren);
assertEquals(3, libsTestingNS.fetchedChildren);
globalTestingNS.fetchedChildren = 0;
libsTestingNS.fetchedChildren = 0;
assertEquals(MAX_VALUE, mns.getChildNodeCount(7));
assertEquals(5, globalTestingNS.fetchedChildren);
assertEquals(2, libsTestingNS.fetchedChildren);
globalTestingNS.fetchedChildren = 0;
libsTestingNS.fetchedChildren = 0;
assertEquals(8, mns.builder().getChildNodeCount(9));
assertEquals(5, globalTestingNS.fetchedChildren);
assertEquals(3, libsTestingNS.fetchedChildren);
globalTestingNS.fetchedChildren = 0;
libsTestingNS.fetchedChildren = 0;
assertEquals(MAX_VALUE, mns.builder().getChildNodeCount(8));
assertEquals(5, globalTestingNS.fetchedChildren);
assertEquals(3, libsTestingNS.fetchedChildren);
globalTestingNS.fetchedChildren = 0;
libsTestingNS.fetchedChildren = 0;
assertEquals(MAX_VALUE, mns.builder().getChildNodeCount(7));
assertEquals(5, globalTestingNS.fetchedChildren);
assertEquals(2, libsTestingNS.fetchedChildren);
}
use of org.apache.jackrabbit.oak.spi.mount.MountInfoProvider in project jackrabbit-oak by apache.
the class CompositeCompareTest method reportedNodesAreWrapped.
@Test
public void reportedNodesAreWrapped() {
Mounts.Builder mipBuilder = Mounts.newBuilder();
mipBuilder.readOnlyMount("libs", "/libs");
MountInfoProvider mip = mipBuilder.build();
NodeStore globalStore = new MemoryNodeStore();
CompositeNodeStore.Builder nsBuilder = new CompositeNodeStore.Builder(mip, globalStore);
nsBuilder.addMount("libs", new MemoryNodeStore());
CompositeNodeStore compositeNodeStore = nsBuilder.build();
NodeBuilder builder = compositeNodeStore.getRoot().builder();
builder.child("changed");
builder.child("deleted");
NodeState base = builder.getNodeState();
builder.getChildNode("changed").setProperty("newProp", "xyz", Type.STRING);
builder.getChildNode("deleted").remove();
builder.child("added");
final NodeState modified = builder.getNodeState();
final Set<String> modifiedNodes = newHashSet();
modified.compareAgainstBaseState(base, new DefaultNodeStateDiff() {
@Override
public boolean childNodeAdded(String name, NodeState after) {
assertTrue(after instanceof CompositeNodeState);
assertEquals(name, "added");
modifiedNodes.add(name);
return true;
}
@Override
public boolean childNodeChanged(String name, NodeState before, NodeState after) {
assertTrue(before instanceof CompositeNodeState);
assertTrue(after instanceof CompositeNodeState);
assertEquals(name, "changed");
modifiedNodes.add(name);
return true;
}
@Override
public boolean childNodeDeleted(String name, NodeState before) {
assertTrue(before instanceof CompositeNodeState);
assertEquals(name, "deleted");
modifiedNodes.add(name);
return true;
}
});
assertEquals(ImmutableSet.of("added", "changed", "deleted"), modifiedNodes);
}
use of org.apache.jackrabbit.oak.spi.mount.MountInfoProvider in project jackrabbit-oak by apache.
the class CrossMountReferenceValidatorTest method initializeHook.
@Before
public void initializeHook() {
MountInfoProvider mip = Mounts.newBuilder().mount("foo", "/a").build();
hook = new EditorHook(new CompositeEditorProvider(new IndexUpdateProvider(new CompositeIndexEditorProvider(new PropertyIndexEditorProvider().with(mip), new ReferenceEditorProvider().with(mip))), new CrossMountReferenceValidatorProvider().with(mip).withFailOnDetection(true)));
}
use of org.apache.jackrabbit.oak.spi.mount.MountInfoProvider in project jackrabbit-oak by apache.
the class CompositeCompareTest method onlyPropertiesOnMainNodesAreCompared.
@Test
public void onlyPropertiesOnMainNodesAreCompared() throws CommitFailedException {
MountInfoProvider mip = Mounts.newBuilder().mount("libs", "/libs").build();
NodeStore globalStore = new MemoryNodeStore();
NodeStore libsStore = new MemoryNodeStore();
List<MountedNodeStore> mounts = Lists.newArrayList();
mounts.add(new MountedNodeStore(mip.getMountByName("libs"), libsStore));
CompositeNodeStore compositeNodeStore = new CompositeNodeStore(mip, globalStore, mounts);
NodeState empty = compositeNodeStore.getRoot();
NodeBuilder builder = globalStore.getRoot().builder();
builder.setProperty("global-prop-1", "val");
builder.setProperty("global-prop-2", "val");
globalStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
NodeBuilder libsBuilder = libsStore.getRoot().builder();
libsBuilder.setProperty("libs-prop-1", "val");
libsBuilder.setProperty("libs-prop-2", "val");
libsStore.merge(libsBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
NodeState modified = compositeNodeStore.getRoot();
final Set<String> addedProperties = newHashSet();
modified.compareAgainstBaseState(empty, new DefaultNodeStateDiff() {
@Override
public boolean propertyAdded(PropertyState after) {
addedProperties.add(after.getName());
return true;
}
});
assertEquals(ImmutableSet.of("global-prop-1", "global-prop-2"), addedProperties);
}
Aggregations