use of org.neo4j.graphdb.event.KernelEventHandler in project neo4j by neo4j.
the class TestKernelEvents method testRegisterUnregisterHandlers.
@Test
public void testRegisterUnregisterHandlers() {
GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
KernelEventHandler handler1 = new DummyKernelEventHandler(RESOURCE1) {
@Override
public ExecutionOrder orderComparedTo(KernelEventHandler other) {
return ExecutionOrder.DOESNT_MATTER;
}
};
KernelEventHandler handler2 = new DummyKernelEventHandler(RESOURCE2) {
@Override
public ExecutionOrder orderComparedTo(KernelEventHandler other) {
return ExecutionOrder.DOESNT_MATTER;
}
};
try {
graphDb.unregisterKernelEventHandler(handler1);
fail("Shouldn't be able to do unregister on a " + "unregistered handler");
} catch (IllegalStateException e) {
/* Good */
}
assertTrue(handler1 == graphDb.registerKernelEventHandler(handler1));
assertTrue(handler1 == graphDb.registerKernelEventHandler(handler1));
assertTrue(handler1 == graphDb.unregisterKernelEventHandler(handler1));
try {
graphDb.unregisterKernelEventHandler(handler1);
fail("Shouldn't be able to do unregister on a " + "unregistered handler");
} catch (IllegalStateException e) {
/* Good */
}
assertTrue(handler1 == graphDb.registerKernelEventHandler(handler1));
assertTrue(handler2 == graphDb.registerKernelEventHandler(handler2));
assertTrue(handler1 == graphDb.unregisterKernelEventHandler(handler1));
assertTrue(handler2 == graphDb.unregisterKernelEventHandler(handler2));
graphDb.shutdown();
}
Aggregations