use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class PrivilegeValidatorTest method testUnknownAggregate.
@Test
public void testUnknownAggregate() {
try {
NodeState newDef = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE).setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_PRIVILEGE).setProperty(REP_BITS, 8).setProperty(REP_AGGREGATES, ImmutableList.of("unknown", JCR_READ), Type.NAMES).getNodeState();
PrivilegeValidator validator = new PrivilegeValidator(root, root);
validator.childNodeAdded("test", newDef);
fail("unknown aggregate must be detected.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(51, e.getCode());
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class PrivilegeValidatorTest method testCircularAggregate2.
@Test
public void testCircularAggregate2() {
try {
createPrivilegeTree("test2", "test");
NodeState newDef = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE).setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_PRIVILEGE).setProperty(REP_BITS, 8).setProperty(REP_AGGREGATES, ImmutableList.of("test2", JCR_READ), Type.NAMES).getNodeState();
PrivilegeValidator validator = new PrivilegeValidator(root, root);
validator.childNodeAdded("test", newDef);
fail("unknown aggregate must be detected.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(52, e.getCode());
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class BackgroundObserverTest method contentChanged.
private static void contentChanged(Observer observer, long value) {
NodeState node = EMPTY_NODE.builder().setProperty("p", value).getNodeState();
observer.contentChanged(node, COMMIT_INFO);
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class PrefilteringBackgroundObserverTest method testFlipping.
@Test
public void testFlipping() throws Exception {
final int queueLength = 2000;
init(queueLength);
// initialize observer with an initial contentChanged
// (see ChangeDispatcher#addObserver)
{
compositeObserver.contentChanged(p(-1), CommitInfo.EMPTY_EXTERNAL);
}
// Part 1 : first run with filtersEvaluatedMapWithEmptyObservers - empty or null shouldn't matter, it's excluded in both cases
for (int k = 0; k < 1000; k++) {
CommitInfo info;
if (k % 2 == 1) {
info = includingCommitInfo;
} else {
info = excludingCommitInfo;
}
final NodeState p = p(k);
compositeObserver.contentChanged(p, info);
if (k % 10 == 0) {
executeRunnables(runnableQ, 10);
}
}
executeRunnables(runnableQ, 10);
// changed from 501 with OAK-5121
assertEquals(500, received.size());
// changed from 500 with OAK-5121
assertEquals(499, resetCallCnt);
// Part 2 : run with filtersEvaluatedMapWithNullObservers - empty or null shouldn't matter, it's excluded in both cases
received.clear();
resetCallCnt = 0;
for (int k = 0; k < 1000; k++) {
CommitInfo info;
if (k % 2 == 1) {
info = includingCommitInfo;
} else {
info = excludingCommitInfo;
}
final NodeState p = p(k);
compositeObserver.contentChanged(p, info);
if (k % 10 == 0) {
executeRunnables(runnableQ, 10);
}
}
executeRunnables(runnableQ, 10);
assertEquals(500, received.size());
assertEquals(500, resetCallCnt);
// Part 3 : unlike the method name suggests, this variant tests with the filter disabled, so should receive all events normally
received.clear();
resetCallCnt = 0;
for (int k = 0; k < 1000; k++) {
CommitInfo info;
if (k % 2 == 1) {
info = includingCommitInfo;
} else {
info = includingCommitInfo;
}
final NodeState p = p(k);
compositeObserver.contentChanged(p, info);
if (k % 10 == 0) {
executeRunnables(runnableQ, 10);
}
}
executeRunnables(runnableQ, 10);
assertEquals(1000, received.size());
assertEquals(0, resetCallCnt);
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class EffectiveType method getTypeNames.
@Nonnull
Set<String> getTypeNames() {
Set<String> names = newHashSet();
for (NodeState type : types) {
names.add(type.getName(JCR_NODETYPENAME));
addAll(names, type.getNames(REP_SUPERTYPES));
}
return names;
}
Aggregations