Search in sources :

Example 1 with State

use of org.bboxdb.commons.ServiceState.State in project bboxdb by jnidzwetzki.

the class TestServiceState method testCallbackListenerRegisterAndUnregister.

/**
 * Test the register and unregister method
 */
@Test(timeout = 60000)
public void testCallbackListenerRegisterAndUnregister() {
    final ServiceState state = new ServiceState();
    final Consumer<? super ServiceState> consumer = (s) -> {
    };
    // Callback is unkown
    Assert.assertFalse(state.removeCallback(consumer));
    state.registerCallback(consumer);
    // Callback is known
    Assert.assertTrue(state.removeCallback(consumer));
    // Callback is unkown
    Assert.assertFalse(state.removeCallback(consumer));
}
Also used : Consumer(java.util.function.Consumer) ServiceState(org.bboxdb.commons.ServiceState) Semaphore(java.util.concurrent.Semaphore) State(org.bboxdb.commons.ServiceState.State) Test(org.junit.Test) Assert(org.junit.Assert) ServiceState(org.bboxdb.commons.ServiceState) Test(org.junit.Test)

Aggregations

Semaphore (java.util.concurrent.Semaphore)1 Consumer (java.util.function.Consumer)1 ServiceState (org.bboxdb.commons.ServiceState)1 State (org.bboxdb.commons.ServiceState.State)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1