Search in sources :

Example 1 with Type

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

the class ValidatorNoProtectionTest method testRepExternalIdType.

@Override
@Test
public void testRepExternalIdType() throws Exception {
    Root systemRoot = getSystemRoot();
    Tree userTree = systemRoot.getTree(testUserPath);
    Map<Type, Object> valMap = ImmutableMap.<Type, Object>of(Type.BOOLEAN, Boolean.TRUE, Type.LONG, new Long(1234), Type.NAME, "id");
    for (Type t : valMap.keySet()) {
        Object val = valMap.get(t);
        try {
            userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_ID, val, t);
            systemRoot.commit();
        } finally {
            systemRoot.refresh();
        }
    }
}
Also used : Type(org.apache.jackrabbit.oak.api.Type) Root(org.apache.jackrabbit.oak.api.Root) Tree(org.apache.jackrabbit.oak.api.Tree) Test(org.junit.Test)

Example 2 with Type

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

the class ExternalIdentityValidatorTest method testRepExternalIdType.

@Test
public void testRepExternalIdType() throws Exception {
    Root systemRoot = getSystemRoot();
    Tree userTree = systemRoot.getTree(testUserPath);
    java.util.Map<Type, Object> valMap = ImmutableMap.<Type, Object>of(Type.BOOLEAN, Boolean.TRUE, Type.LONG, new Long(1234), Type.NAME, "id");
    for (Type t : valMap.keySet()) {
        Object val = valMap.get(t);
        try {
            userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_ID, val, t);
            systemRoot.commit();
            fail("Creating rep:externalId with type " + t + " must be detected.");
        } catch (CommitFailedException e) {
            // success
            assertEquals(75, e.getCode());
        } finally {
            systemRoot.refresh();
        }
    }
}
Also used : Type(org.apache.jackrabbit.oak.api.Type) Root(org.apache.jackrabbit.oak.api.Root) Tree(org.apache.jackrabbit.oak.api.Tree) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException) Test(org.junit.Test)

Example 3 with Type

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

the class ExternalIdentityValidatorTest method testExternalPrincipalNamesType.

@Test
public void testExternalPrincipalNamesType() throws Exception {
    Root systemRoot = getSystemRoot();
    Tree userTree = systemRoot.getTree(testUserPath);
    java.util.Map<Type, Object> valMap = ImmutableMap.<Type, Object>of(Type.BOOLEANS, ImmutableSet.of(Boolean.TRUE), Type.LONGS, ImmutableSet.of(new Long(1234)), Type.NAMES, ImmutableSet.of("id", "id2"));
    for (Type t : valMap.keySet()) {
        Object val = valMap.get(t);
        try {
            userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, val, t);
            systemRoot.commit();
            fail("Creating rep:externalPrincipalNames with type " + t + " must be detected.");
        } catch (CommitFailedException e) {
            // success
            assertEquals(71, e.getCode());
        } finally {
            systemRoot.refresh();
        }
    }
}
Also used : Type(org.apache.jackrabbit.oak.api.Type) Root(org.apache.jackrabbit.oak.api.Root) Tree(org.apache.jackrabbit.oak.api.Tree) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException) Test(org.junit.Test)

Aggregations

Root (org.apache.jackrabbit.oak.api.Root)3 Tree (org.apache.jackrabbit.oak.api.Tree)3 Type (org.apache.jackrabbit.oak.api.Type)3 Test (org.junit.Test)3 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)2