use of com.orientechnologies.orient.core.hook.ORecordHookAbstract in project orientdb by orientechnologies.
the class HookTxTest method testHookCannotBeginTx.
@Test(dependsOnMethods = "testHookCallsDelete")
public void testHookCannotBeginTx() throws IOException {
final AtomicBoolean exc = new AtomicBoolean(false);
database.activateOnCurrentThread();
database.registerHook(new ORecordHookAbstract() {
@Override
public RESULT onRecordBeforeCreate(ORecord iRecord) {
try {
database.activateOnCurrentThread();
database.begin();
} catch (IllegalStateException e) {
exc.set(true);
}
return null;
}
@Override
public DISTRIBUTED_EXECUTION_MODE getDistributedExecutionMode() {
return DISTRIBUTED_EXECUTION_MODE.BOTH;
}
});
Assert.assertFalse(exc.get());
new ODocument().field("test-hook", true).save();
Assert.assertTrue(exc.get());
database.activateOnCurrentThread();
database.close();
}
Aggregations