use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class ExternalIdentityValidatorTest method testRemoveRepExternalIdWithoutPrincipalNames.
@Test
public void testRemoveRepExternalIdWithoutPrincipalNames() throws Exception {
Root systemRoot = getSystemRoot();
systemRoot.getTree(testUserPath).setProperty(ExternalIdentityConstants.REP_EXTERNAL_ID, "id");
systemRoot.commit();
root.refresh();
try {
root.getTree(testUserPath).removeProperty(ExternalIdentityConstants.REP_EXTERNAL_ID);
root.commit();
fail("Removal of rep:externalId must be detected in the default setup.");
} catch (CommitFailedException e) {
// success: verify nature of the exception
assertTrue(e.isConstraintViolation());
assertEquals(74, e.getCode());
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class ExternalIdentityValidatorTest method testExternalPrincipalNamesSingle.
@Test
public void testExternalPrincipalNamesSingle() throws Exception {
Root systemRoot = getSystemRoot();
try {
NodeUtil n = new NodeUtil(systemRoot.getTree(testUserPath));
n.setString(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, "id");
systemRoot.commit();
fail("Creating rep:externalPrincipalNames as single STRING property must be detected.");
} catch (CommitFailedException e) {
// success
assertEquals(71, e.getCode());
} finally {
systemRoot.refresh();
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException 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();
}
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class ExternalIdentityValidatorTest method testModifyExternalPrincipalNames.
@Test
public void testModifyExternalPrincipalNames() throws Exception {
Tree userTree = root.getTree(externalUserPath);
try {
userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, Lists.newArrayList("principalNames"), Type.STRINGS);
root.commit();
fail("Changing rep:externalPrincipalNames must be detected.");
} catch (CommitFailedException e) {
// success
assertEquals(70, e.getCode());
} finally {
root.refresh();
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class ExternalIdentityValidatorTest method testRemoveRepExternalIdAsSystem.
@Test
public void testRemoveRepExternalIdAsSystem() throws Exception {
Root systemRoot = getSystemRoot();
try {
NodeUtil n = new NodeUtil(systemRoot.getTree(externalUserPath));
n.removeProperty(ExternalIdentityConstants.REP_EXTERNAL_ID);
systemRoot.commit();
fail("Removing rep:externalId is not allowed if rep:externalPrincipalNames is present.");
} catch (CommitFailedException e) {
// success
assertEquals(73, e.getCode());
} finally {
systemRoot.refresh();
}
}
Aggregations