Search in sources :

Example 1 with Context

use of org.apache.jackrabbit.oak.composite.checks.UniqueIndexNodeStoreChecker.Context 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 Context

use of org.apache.jackrabbit.oak.composite.checks.UniqueIndexNodeStoreChecker.Context 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 Context

use of org.apache.jackrabbit.oak.composite.checks.UniqueIndexNodeStoreChecker.Context 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 Context

use of org.apache.jackrabbit.oak.composite.checks.UniqueIndexNodeStoreChecker.Context 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 Context

use of org.apache.jackrabbit.oak.composite.checks.UniqueIndexNodeStoreChecker.Context in project jackrabbit-oak by apache.

the class UniqueIndexNodeStoreCheckerTest method uuidConflict_threeStores.

@Test
public void uuidConflict_threeStores() throws Exception {
    MemoryNodeStore globalStore = new MemoryNodeStore();
    MemoryNodeStore mountedStore = new MemoryNodeStore();
    MemoryNodeStore mountedStore2 = new MemoryNodeStore();
    populateStore(globalStore, b -> b.child("first").setProperty("foo", "bar"));
    populateStore(globalStore, b -> b.child("second").setProperty("foo", "baz"));
    populateStore(mountedStore, b -> b.child("libs").child("first").setProperty("foo", "bar"));
    populateStore(mountedStore2, b -> b.child("apps").child("first").setProperty("foo", "baz"));
    UniqueIndexNodeStoreChecker checker = new UniqueIndexNodeStoreChecker();
    Context ctx = checker.createContext(globalStore, mip);
    exception.expect(IllegalRepositoryStateException.class);
    exception.expectMessage("2 errors were found");
    exception.expectMessage("clash for value bar: 'duplicate unique index entry'");
    exception.expectMessage("clash for value baz: 'duplicate unique index entry'");
    ErrorHolder error = new ErrorHolder();
    checker.check(new MountedNodeStore(mip.getMountByName("libs"), mountedStore), TreeFactory.createReadOnlyTree(mountedStore.getRoot()), error, ctx);
    checker.check(new MountedNodeStore(mip.getMountByName("apps"), mountedStore2), 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)

Aggregations

MountedNodeStore (org.apache.jackrabbit.oak.composite.MountedNodeStore)5 Context (org.apache.jackrabbit.oak.composite.checks.UniqueIndexNodeStoreChecker.Context)5 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)5 Test (org.junit.Test)5