Search in sources :

Example 1 with ErrorState

use of org.neo4j.graphdb.event.ErrorState in project graphdb by neo4j-attic.

the class TestShutdownSequence method canInvokeShutdownFromShutdownHandler.

@Test
public void canInvokeShutdownFromShutdownHandler() {
    graphDb.registerKernelEventHandler(new KernelEventHandler() {

        public void beforeShutdown() {
            graphDb.shutdown();
        }

        public Object getResource() {
            return null;
        }

        public void kernelPanic(ErrorState error) {
        // do nothing
        }

        public ExecutionOrder orderComparedTo(KernelEventHandler other) {
            return ExecutionOrder.DOESNT_MATTER;
        }
    });
    graphDb.shutdown();
}
Also used : KernelEventHandler(org.neo4j.graphdb.event.KernelEventHandler) ErrorState(org.neo4j.graphdb.event.ErrorState) Test(org.junit.Test)

Example 2 with ErrorState

use of org.neo4j.graphdb.event.ErrorState in project neo4j by neo4j.

the class TestShutdownSequence method canInvokeShutdownFromShutdownHandler.

@Test
public void canInvokeShutdownFromShutdownHandler() {
    graphDb.registerKernelEventHandler(new KernelEventHandler() {

        @Override
        public void beforeShutdown() {
            graphDb.shutdown();
        }

        @Override
        public Object getResource() {
            return null;
        }

        @Override
        public void kernelPanic(ErrorState error) {
        // do nothing
        }

        @Override
        public ExecutionOrder orderComparedTo(KernelEventHandler other) {
            return ExecutionOrder.DOESNT_MATTER;
        }
    });
    graphDb.shutdown();
}
Also used : KernelEventHandler(org.neo4j.graphdb.event.KernelEventHandler) ErrorState(org.neo4j.graphdb.event.ErrorState) Test(org.junit.Test)

Example 3 with ErrorState

use of org.neo4j.graphdb.event.ErrorState in project neo4j by neo4j.

the class TestShutdownSequence method eventHandlersAreOnlyInvokedOnceDuringShutdown.

@Test
public void eventHandlersAreOnlyInvokedOnceDuringShutdown() {
    final AtomicInteger counter = new AtomicInteger();
    graphDb.registerKernelEventHandler(new KernelEventHandler() {

        @Override
        public void beforeShutdown() {
            counter.incrementAndGet();
        }

        @Override
        public Object getResource() {
            return null;
        }

        @Override
        public void kernelPanic(ErrorState error) {
        // do nothing
        }

        @Override
        public ExecutionOrder orderComparedTo(KernelEventHandler other) {
            return ExecutionOrder.DOESNT_MATTER;
        }
    });
    graphDb.shutdown();
    graphDb.shutdown();
    assertEquals(1, counter.get());
}
Also used : KernelEventHandler(org.neo4j.graphdb.event.KernelEventHandler) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ErrorState(org.neo4j.graphdb.event.ErrorState) Test(org.junit.Test)

Example 4 with ErrorState

use of org.neo4j.graphdb.event.ErrorState in project graphdb by neo4j-attic.

the class TestShutdownSequence method eventHandlersAreOnlyInvokedOnceDuringShutdown.

@Test
public void eventHandlersAreOnlyInvokedOnceDuringShutdown() {
    final AtomicInteger counter = new AtomicInteger();
    graphDb.registerKernelEventHandler(new KernelEventHandler() {

        public void beforeShutdown() {
            counter.incrementAndGet();
        }

        public Object getResource() {
            return null;
        }

        public void kernelPanic(ErrorState error) {
        // do nothing
        }

        public ExecutionOrder orderComparedTo(KernelEventHandler other) {
            return ExecutionOrder.DOESNT_MATTER;
        }
    });
    graphDb.shutdown();
    graphDb.shutdown();
    assertEquals(1, counter.get());
}
Also used : KernelEventHandler(org.neo4j.graphdb.event.KernelEventHandler) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ErrorState(org.neo4j.graphdb.event.ErrorState) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 ErrorState (org.neo4j.graphdb.event.ErrorState)4 KernelEventHandler (org.neo4j.graphdb.event.KernelEventHandler)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2