use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class CacheValidatorProviderTest method testChangePrimaryType.
@Test
public void testChangePrimaryType() throws RepositoryException {
for (Authorizable a : authorizables) {
try {
NodeUtil node = new NodeUtil(getAuthorizableTree(a));
NodeUtil cache = node.addChild("childNode", JcrConstants.NT_UNSTRUCTURED);
root.commit();
cache.setName(JcrConstants.JCR_PRIMARYTYPE, CacheConstants.NT_REP_CACHE);
cache.setLong(CacheConstants.REP_EXPIRATION, 1);
root.commit();
fail("Changing primary type of residual node below an user/group to rep:Cache must fail.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(34, e.getCode());
} finally {
root.refresh();
}
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class CacheValidatorProviderTest method testNestedCache.
@Test
public void testNestedCache() throws Exception {
NodeUtil cache = new NodeUtil(getCache(getTestUser()));
try {
NodeUtil c = cache.getOrAddChild(CacheConstants.REP_CACHE, CacheConstants.NT_REP_CACHE);
c.setLong(CacheConstants.REP_EXPIRATION, 223);
root.commit(CacheValidatorProvider.asCommitAttributes());
fail("Creating nested cache must fail.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(34, e.getCode());
} finally {
root.refresh();
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class CacheValidatorProviderTest method testCreateCacheByName.
@Test
public void testCreateCacheByName() throws RepositoryException {
for (Authorizable a : authorizables) {
try {
NodeUtil node = new NodeUtil(getAuthorizableTree(a));
node.addChild(CacheConstants.REP_CACHE, JcrConstants.NT_UNSTRUCTURED);
root.commit();
fail("Creating rep:cache node below a user or group must fail.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(34, e.getCode());
} finally {
root.refresh();
}
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class CacheValidatorProviderTest method testModifyCache.
@Test
public void testModifyCache() throws Exception {
List<PropertyState> props = new ArrayList();
props.add(PropertyStates.createProperty(CacheConstants.REP_EXPIRATION, 25));
props.add(PropertyStates.createProperty(CacheConstants.REP_GROUP_PRINCIPAL_NAMES, EveryonePrincipal.NAME));
props.add(PropertyStates.createProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME));
props.add(PropertyStates.createProperty("residualProp", "anyvalue"));
Tree cache = getCache(getTestUser());
for (PropertyState prop : props) {
try {
cache.setProperty(prop);
root.commit(CacheValidatorProvider.asCommitAttributes());
fail("Modifying rep:cache node below a user or group must fail.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(34, e.getCode());
} finally {
root.refresh();
}
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class CacheValidatorProviderTest method testCreateCacheBelowProfile.
@Test
public void testCreateCacheBelowProfile() throws Exception {
try {
NodeUtil node = new NodeUtil(getAuthorizableTree(getTestUser()));
NodeUtil child = node.addChild("profile", NodeTypeConstants.NT_OAK_UNSTRUCTURED);
child.addChild(CacheConstants.REP_CACHE, CacheConstants.NT_REP_CACHE).setLong(CacheConstants.REP_EXPIRATION, 23);
root.commit(CacheValidatorProvider.asCommitAttributes());
fail("Creating rep:cache node below a user or group must fail.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(34, e.getCode());
} finally {
root.refresh();
}
}
Aggregations