Search in sources :

Example 1 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class DynamicSyncContextTest method testSyncExternalUserDepth1.

@Test
public void testSyncExternalUserDepth1() throws Exception {
    syncConfig.user().setMembershipNestingDepth(1);
    ExternalUser externalUser = idp.getUser(USER_ID);
    sync(externalUser, SyncResult.Status.ADD);
    Tree tree = r.getTree(userManager.getAuthorizable(USER_ID).getPath());
    PropertyState extPrincipalNames = tree.getProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES);
    assertNotNull(extPrincipalNames);
    Set<String> pNames = Sets.newHashSet(extPrincipalNames.getValue(Type.STRINGS));
    for (ExternalIdentityRef ref : externalUser.getDeclaredGroups()) {
        assertTrue(pNames.remove(idp.getIdentity(ref).getPrincipalName()));
    }
    assertTrue(pNames.isEmpty());
}
Also used : ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 2 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class DynamicSyncContextTest method testSyncExternalUserDepth0.

@Test
public void testSyncExternalUserDepth0() throws Exception {
    syncConfig.user().setMembershipNestingDepth(0);
    ExternalUser externalUser = idp.getUser(USER_ID);
    sync(externalUser, SyncResult.Status.ADD);
    Tree tree = r.getTree(userManager.getAuthorizable(USER_ID).getPath());
    PropertyState extPrincipalNames = tree.getProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES);
    assertNotNull(extPrincipalNames);
    assertEquals(0, extPrincipalNames.count());
}
Also used : ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 3 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class AtomicCounterEditorTest method singleNodeAsync.

@Test
public void singleNodeAsync() throws CommitFailedException, InterruptedException, ExecutionException {
    NodeStore store = new MemoryNodeStore();
    MyExecutor exec1 = new MyExecutor();
    Whiteboard board = new DefaultWhiteboard();
    EditorHook hook1 = new EditorHook(new TestableACEProvider(CLUSTER_1, exec1, store, board));
    NodeBuilder builder, root;
    PropertyState p;
    board.register(CommitHook.class, EmptyHook.INSTANCE, null);
    root = store.getRoot().builder();
    builder = root.child("c");
    builder = setMixin(builder);
    builder = incrementBy(builder, INCREMENT_BY_1);
    store.merge(root, hook1, CommitInfo.EMPTY);
    // as we're providing all the information we expect the counter not to be consolidated for
    // as long as the scheduled process has run
    builder = store.getRoot().builder().getChildNode("c");
    assertTrue(builder.exists());
    p = builder.getProperty(PREFIX_PROP_REVISION + CLUSTER_1.getInstanceId());
    assertNotNull(p);
    assertEquals(1, p.getValue(LONG).longValue());
    p = builder.getProperty(PREFIX_PROP_COUNTER + CLUSTER_1.getInstanceId());
    assertNotNull(p);
    assertEquals(1, p.getValue(LONG).longValue());
    p = builder.getProperty(PROP_COUNTER);
    assertNull(p);
    // executing the consolidation
    exec1.execute();
    // fetching the latest store state to see the changes
    builder = store.getRoot().builder().getChildNode("c");
    assertTrue("the counter node should exists", builder.exists());
    assertCounterNodeState(builder, ImmutableSet.of(PREFIX_PROP_COUNTER + CLUSTER_1.getInstanceId(), PREFIX_PROP_REVISION + CLUSTER_1.getInstanceId()), 1);
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) LongPropertyState(org.apache.jackrabbit.oak.plugins.memory.LongPropertyState) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 4 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class AtomicCounterEditorTest method noHookInWhiteboard.

@Test
public void noHookInWhiteboard() throws CommitFailedException, InterruptedException, ExecutionException {
    NodeStore store = new MemoryNodeStore();
    MyExecutor exec1 = new MyExecutor();
    Whiteboard board = new DefaultWhiteboard();
    EditorHook hook1 = new EditorHook(new TestableACEProvider(CLUSTER_1, exec1, store, board));
    NodeBuilder builder, root;
    PropertyState p;
    root = store.getRoot().builder();
    builder = root.child("c");
    builder = setMixin(builder);
    builder = incrementBy(builder, INCREMENT_BY_1);
    store.merge(root, hook1, CommitInfo.EMPTY);
    // as we're providing all the information we expect the counter not to be consolidated for
    // as long as the scheduled process has run
    builder = store.getRoot().builder().getChildNode("c");
    assertTrue(builder.exists());
    p = builder.getProperty(PREFIX_PROP_REVISION + CLUSTER_1.getInstanceId());
    assertNotNull(p);
    assertEquals(1, p.getValue(LONG).longValue());
    p = builder.getProperty(PREFIX_PROP_COUNTER + CLUSTER_1.getInstanceId());
    assertNotNull(p);
    assertEquals(1, p.getValue(LONG).longValue());
    p = builder.getProperty(PROP_COUNTER);
    assertEquals(1, p.getValue(LONG).longValue());
    assertTrue("without a registered hook it should have fell to sync", exec1.isEmpty());
    // fetching the latest store state to see the changes
    builder = store.getRoot().builder().getChildNode("c");
    assertTrue("the counter node should exists", builder.exists());
    assertCounterNodeState(builder, ImmutableSet.of(PREFIX_PROP_COUNTER + CLUSTER_1.getInstanceId(), PREFIX_PROP_REVISION + CLUSTER_1.getInstanceId()), 1);
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) LongPropertyState(org.apache.jackrabbit.oak.plugins.memory.LongPropertyState) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 5 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class DefaultConflictHandlerTheirsTest method testAddExistingProperties.

@Test
public void testAddExistingProperties() throws CommitFailedException {
    theirRoot.getTree("/").setProperty("p", THEIR_VALUE);
    theirRoot.getTree("/").setProperty("q", THEIR_VALUE);
    ourRoot.getTree("/").setProperty("p", OUR_VALUE);
    ourRoot.getTree("/").setProperty("q", OUR_VALUE);
    theirRoot.commit();
    ourRoot.commit();
    PropertyState p = ourRoot.getTree("/").getProperty("p");
    assertNotNull(p);
    assertEquals(THEIR_VALUE, p.getValue(STRING));
    PropertyState q = ourRoot.getTree("/").getProperty("q");
    assertNotNull(q);
    assertEquals(THEIR_VALUE, p.getValue(STRING));
}
Also used : PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Aggregations

PropertyState (org.apache.jackrabbit.oak.api.PropertyState)404 Test (org.junit.Test)189 Tree (org.apache.jackrabbit.oak.api.Tree)138 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)49 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)45 Nonnull (javax.annotation.Nonnull)31 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)29 RemoteTree (org.apache.jackrabbit.oak.remote.RemoteTree)28 RemoteValue (org.apache.jackrabbit.oak.remote.RemoteValue)28 Blob (org.apache.jackrabbit.oak.api.Blob)21 ArrayList (java.util.ArrayList)20 LongPropertyState (org.apache.jackrabbit.oak.plugins.memory.LongPropertyState)17 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)16 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)14 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)13 CheckForNull (javax.annotation.CheckForNull)12 RepositoryException (javax.jcr.RepositoryException)10 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)10 Map (java.util.Map)9 Value (javax.jcr.Value)9