Search in sources :

Example 1 with MountedNodeStore

use of org.apache.jackrabbit.oak.composite.MountedNodeStore in project jackrabbit-oak by apache.

the class UniqueIndexNodeStoreCheckerTest method noConflict.

@Test
public void noConflict() throws Exception {
    MemoryNodeStore globalStore = new MemoryNodeStore();
    MemoryNodeStore mountedStore = new MemoryNodeStore();
    populateStore(globalStore, b -> b.child("first").setProperty("foo", "baz"));
    populateStore(mountedStore, b -> b.child("libs").child("first").setProperty("foo", "bar"));
    UniqueIndexNodeStoreChecker checker = new UniqueIndexNodeStoreChecker();
    Context ctx = checker.createContext(globalStore, mip);
    ErrorHolder error = new ErrorHolder();
    checker.check(new MountedNodeStore(mip.getMountByName("libs"), mountedStore), TreeFactory.createReadOnlyTree(mountedStore.getRoot()), error, ctx);
    error.end();
}
Also used : Context(org.apache.jackrabbit.oak.composite.checks.UniqueIndexNodeStoreChecker.Context) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MountedNodeStore(org.apache.jackrabbit.oak.composite.MountedNodeStore) Test(org.junit.Test)

Example 2 with MountedNodeStore

use of org.apache.jackrabbit.oak.composite.MountedNodeStore in project jackrabbit-oak by apache.

the class UniqueIndexNodeStoreCheckerTest method noConflict_globalMountHasDuplicateOutsideOfPath.

/**
 * Tests that if a mount has an index clash but the path does not belog to the global mount no error is reported
 */
@Test
public void noConflict_globalMountHasDuplicateOutsideOfPath() throws Exception {
    MemoryNodeStore globalStore = new MemoryNodeStore();
    MemoryNodeStore mountedStore = new MemoryNodeStore();
    populateStore(globalStore, b -> b.child("libs").child("first").setProperty("foo", "bar"));
    populateStore(mountedStore, b -> b.child("libs").child("second").setProperty("foo", "bar"));
    UniqueIndexNodeStoreChecker checker = new UniqueIndexNodeStoreChecker();
    Context ctx = checker.createContext(globalStore, mip);
    ErrorHolder error = new ErrorHolder();
    checker.check(new MountedNodeStore(mip.getMountByName("libs"), mountedStore), TreeFactory.createReadOnlyTree(mountedStore.getRoot()), error, ctx);
    error.end();
}
Also used : Context(org.apache.jackrabbit.oak.composite.checks.UniqueIndexNodeStoreChecker.Context) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MountedNodeStore(org.apache.jackrabbit.oak.composite.MountedNodeStore) Test(org.junit.Test)

Example 3 with MountedNodeStore

use of org.apache.jackrabbit.oak.composite.MountedNodeStore in project jackrabbit-oak by apache.

the class UniqueIndexNodeStoreCheckerTest method noConflict_mountHasDuplicateOutsideOfPath.

/**
 * Tests that if a mount has an index clash but the path does not belong to the mount no error is reported
 */
@Test
public void noConflict_mountHasDuplicateOutsideOfPath() throws Exception {
    MemoryNodeStore globalStore = new MemoryNodeStore();
    MemoryNodeStore mountedStore = new MemoryNodeStore();
    populateStore(globalStore, b -> b.child("first").setProperty("foo", "bar"));
    populateStore(mountedStore, b -> b.child("second").setProperty("foo", "bar"));
    UniqueIndexNodeStoreChecker checker = new UniqueIndexNodeStoreChecker();
    Context ctx = checker.createContext(globalStore, mip);
    ErrorHolder error = new ErrorHolder();
    checker.check(new MountedNodeStore(mip.getMountByName("libs"), mountedStore), TreeFactory.createReadOnlyTree(mountedStore.getRoot()), error, ctx);
    error.end();
}
Also used : Context(org.apache.jackrabbit.oak.composite.checks.UniqueIndexNodeStoreChecker.Context) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MountedNodeStore(org.apache.jackrabbit.oak.composite.MountedNodeStore) Test(org.junit.Test)

Example 4 with MountedNodeStore

use of org.apache.jackrabbit.oak.composite.MountedNodeStore in project jackrabbit-oak by apache.

the class UniqueIndexNodeStoreCheckerTest method uuidConflict_twoStores.

@Test
public void uuidConflict_twoStores() throws Exception {
    MemoryNodeStore globalStore = new MemoryNodeStore();
    MemoryNodeStore mountedStore = new MemoryNodeStore();
    populateStore(globalStore, b -> b.child("first").setProperty("foo", "bar"));
    populateStore(mountedStore, b -> b.child("libs").child("first").setProperty("foo", "bar"));
    UniqueIndexNodeStoreChecker checker = new UniqueIndexNodeStoreChecker();
    Context ctx = checker.createContext(globalStore, mip);
    exception.expect(IllegalRepositoryStateException.class);
    exception.expectMessage("1 errors were found");
    exception.expectMessage("clash for value bar: 'duplicate unique index entry'");
    ErrorHolder error = new ErrorHolder();
    checker.check(new MountedNodeStore(mip.getMountByName("libs"), mountedStore), TreeFactory.createReadOnlyTree(mountedStore.getRoot()), error, ctx);
    error.end();
}
Also used : Context(org.apache.jackrabbit.oak.composite.checks.UniqueIndexNodeStoreChecker.Context) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MountedNodeStore(org.apache.jackrabbit.oak.composite.MountedNodeStore) Test(org.junit.Test)

Example 5 with MountedNodeStore

use of org.apache.jackrabbit.oak.composite.MountedNodeStore in project jackrabbit-oak by apache.

the class NamespacePrefixNodestoreCheckerTest method check.

private void check(String path) {
    Tree tree = TreeUtil.getTree(TreeFactory.createReadOnlyTree(mount.getRoot()), path);
    ErrorHolder errorHolder = new ErrorHolder();
    checker.check(new MountedNodeStore(mip.getMountByName("first"), mount), tree, errorHolder, context);
    errorHolder.end();
}
Also used : MountedNodeStore(org.apache.jackrabbit.oak.composite.MountedNodeStore) Tree(org.apache.jackrabbit.oak.api.Tree)

Aggregations

MountedNodeStore (org.apache.jackrabbit.oak.composite.MountedNodeStore)12 Test (org.junit.Test)10 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)7 Context (org.apache.jackrabbit.oak.composite.checks.UniqueIndexNodeStoreChecker.Context)5 Context (org.apache.jackrabbit.oak.composite.checks.NodeTypeMountedNodeStoreChecker.Context)2 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 Tree (org.apache.jackrabbit.oak.api.Tree)1 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1