use of org.apache.jackrabbit.oak.spi.mount.MountInfoProvider in project jackrabbit-oak by apache.
the class CompositeCompareTest method nodesOutsideTheMountsAreIgnored.
@Test
public void nodesOutsideTheMountsAreIgnored() 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.child("global-child-1");
builder.child("global-child-2");
globalStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
NodeBuilder libsBuilder = libsStore.getRoot().builder();
libsBuilder.child("libs");
libsBuilder.child("libs-child-1");
libsBuilder.child("libs-child-2");
libsStore.merge(libsBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
NodeState modified = compositeNodeStore.getRoot();
final Set<String> addedChildren = newHashSet();
modified.compareAgainstBaseState(empty, new DefaultNodeStateDiff() {
@Override
public boolean childNodeAdded(String name, NodeState after) {
addedChildren.add(name);
return true;
}
});
assertEquals(ImmutableSet.of("global-child-1", "global-child-2", "libs"), addedChildren);
}
use of org.apache.jackrabbit.oak.spi.mount.MountInfoProvider in project jackrabbit-oak by apache.
the class MountInfoProviderServiceTest method defaultSetup.
@Test
public void defaultSetup() throws Exception {
MockOsgi.activate(service, context.bundleContext(), Collections.<String, Object>emptyMap());
MountInfoProvider provider = context.getService(MountInfoProvider.class);
assertNotNull(provider);
assertEquals(defaultMountInfoProvider(), provider);
MockOsgi.deactivate(service, context.bundleContext());
assertNull(context.getService(MountInfoProvider.class));
}
use of org.apache.jackrabbit.oak.spi.mount.MountInfoProvider in project jackrabbit-oak by apache.
the class MountInfoProviderServiceTest method mountWithConfig_Name.
@Test
public void mountWithConfig_Name() throws Exception {
MockOsgi.activate(service, context.bundleContext(), ImmutableMap.<String, Object>of("mountedPaths", new String[] { "/a", "/b" }, "mountName", "foo", "readOnlyMount", true));
MountInfoProvider provider = context.getService(MountInfoProvider.class);
assertEquals(1, provider.getNonDefaultMounts().size());
Mount m = provider.getMountByName(MountInfoProviderService.PROP_MOUNT_NAME_DEFAULT);
assertNull(m);
Mount defMount = provider.getDefaultMount();
assertNotNull(defMount);
m = provider.getMountByName("foo");
assertEquals(m, provider.getMountByPath("/a"));
assertEquals(defMount, provider.getMountByPath("/x"));
assertTrue(m.isReadOnly());
}
use of org.apache.jackrabbit.oak.spi.mount.MountInfoProvider in project jackrabbit-oak by apache.
the class SimpleMountInfoProviderTest method mountsPlacedUnder.
@Test
public void mountsPlacedUnder() {
MountInfoProvider mip = Mounts.newBuilder().mount("first", "/b").mount("second", "/d", "/b/a").mount("third", "/h", "/b/c").build();
Collection<Mount> mountsContainedBetweenPaths = mip.getMountsPlacedUnder("/b");
assertEquals(2, mountsContainedBetweenPaths.size());
}
use of org.apache.jackrabbit.oak.spi.mount.MountInfoProvider in project jackrabbit-oak by apache.
the class SimpleMountInfoProviderTest method defaultMount.
@Test
public void defaultMount() throws Exception {
MountInfoProvider mip = new SimpleMountInfoProvider(Collections.<Mount>emptyList());
assertNotNull(mip.getMountByPath("/a"));
assertTrue(mip.getMountByPath("/a").isDefault());
assertFalse(mip.hasNonDefaultMounts());
}
Aggregations