Search in sources :

Example 31 with MountInfoProvider

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);
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) DefaultNodeStateDiff(org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 32 with MountInfoProvider

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));
}
Also used : MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) Mounts.defaultMountInfoProvider(org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider) Test(org.junit.Test)

Example 33 with MountInfoProvider

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());
}
Also used : Mount(org.apache.jackrabbit.oak.spi.mount.Mount) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) Mounts.defaultMountInfoProvider(org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider) Test(org.junit.Test)

Example 34 with MountInfoProvider

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());
}
Also used : Mount(org.apache.jackrabbit.oak.spi.mount.Mount) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) SimpleMountInfoProvider(org.apache.jackrabbit.oak.spi.mount.SimpleMountInfoProvider) Test(org.junit.Test)

Example 35 with MountInfoProvider

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());
}
Also used : SimpleMountInfoProvider(org.apache.jackrabbit.oak.spi.mount.SimpleMountInfoProvider) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) SimpleMountInfoProvider(org.apache.jackrabbit.oak.spi.mount.SimpleMountInfoProvider) Test(org.junit.Test)

Aggregations

MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)47 Test (org.junit.Test)38 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)14 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)9 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)7 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)7 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)6 Mount (org.apache.jackrabbit.oak.spi.mount.Mount)6 IndexUpdateProvider (org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider)5 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)5 Mounts.defaultMountInfoProvider (org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider)5 SimpleMountInfoProvider (org.apache.jackrabbit.oak.spi.mount.SimpleMountInfoProvider)5 IOException (java.io.IOException)4 IndexCopier (org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier)3 IndexTracker (org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker)3 LuceneIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider)3 LuceneIndexProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider)3 DefaultIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory)3 LuceneIndexReaderFactory (org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory)3 DefaultNodeStateDiff (org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff)3