use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.
the class TypeEditorTest method changeNamedPropertyToBadRequiredType.
@Test
public void changeNamedPropertyToBadRequiredType() {
EditorHook hook = new EditorHook(new TypeEditorProvider());
NodeState root = INITIAL_CONTENT;
NodeBuilder builder = root.builder();
NodeBuilder testNode = builder.child("testNode");
testNode.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, Type.NAME);
testNode.setProperty(JCR_MIXINTYPES, ImmutableList.of("mix:title"), Type.NAMES);
testNode.setProperty("jcr:title", "title");
NodeState before = builder.getNodeState();
testNode.setProperty("jcr:title", true);
try {
hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
fail();
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
}
}
use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.
the class TypeEditorTest method changeMandatoryPropertyToBadRequiredType.
@Test
public void changeMandatoryPropertyToBadRequiredType() {
EditorHook hook = new EditorHook(new TypeEditorProvider());
NodeState root = INITIAL_CONTENT;
NodeBuilder builder = root.builder();
NodeBuilder acl = builder.child(AccessControlConstants.REP_POLICY);
acl.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_ACL, Type.NAME);
NodeBuilder ace = acl.child("first");
ace.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_GRANT_ACE, Type.NAME);
ace.setProperty(AccessControlConstants.REP_PRINCIPAL_NAME, EveryonePrincipal.NAME);
ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.NAMES);
NodeState before = builder.getNodeState();
// change to invalid type
ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.STRINGS);
try {
hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
fail();
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
}
}
use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.
the class TypeEditorTest method addMandatoryPropertyWithBadRequiredType.
@Test
public void addMandatoryPropertyWithBadRequiredType() {
EditorHook hook = new EditorHook(new TypeEditorProvider());
NodeState root = INITIAL_CONTENT;
NodeBuilder builder = root.builder();
NodeState before = builder.getNodeState();
NodeBuilder acl = builder.child(AccessControlConstants.REP_POLICY);
acl.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_ACL, Type.NAME);
NodeBuilder ace = acl.child("first");
ace.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_GRANT_ACE, Type.NAME);
ace.setProperty(AccessControlConstants.REP_PRINCIPAL_NAME, EveryonePrincipal.NAME);
ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.STRINGS);
try {
hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
fail();
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(55, e.getCode());
}
}
use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.
the class DocumentQueueTest method setUp.
@Before
public void setUp() throws IOException {
IndexEditorProvider editorProvider = new LuceneIndexEditorProvider(null, null, null, defaultMountInfoProvider());
syncHook = new EditorHook(new IndexUpdateProvider(editorProvider));
asyncHook = new EditorHook(new IndexUpdateProvider(editorProvider, "async", false));
}
use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.
the class LuceneIndexEditorTest method multiplexingWriter.
@Test
public void multiplexingWriter() throws Exception {
newLucenePropertyIndex("lucene", "foo");
MountInfoProvider mip = Mounts.newBuilder().mount("foo", "/libs", "/apps").build();
EditorHook hook = new EditorHook(new IndexUpdateProvider(new LuceneIndexEditorProvider(null, new ExtractedTextCache(0, 0), null, mip)));
NodeState indexed = hook.processCommit(EMPTY_NODE, builder.getNodeState(), CommitInfo.EMPTY);
builder = indexed.builder();
NodeState before = indexed;
builder.child("content").child("en").setProperty("foo", "bar");
builder.child("libs").child("install").setProperty("foo", "bar");
NodeState after = builder.getNodeState();
indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
builder = indexed.builder();
assertEquals(1, numDocs(mip.getMountByName("foo")));
assertEquals(1, numDocs(mip.getDefaultMount()));
}
Aggregations