use of org.bboxdb.commons.ServiceState in project bboxdb by jnidzwetzki.
the class TestServiceState method testDispatchToStarting2.
/**
* Dispath to starting
*/
@Test(expected = IllegalStateException.class)
public void testDispatchToStarting2() {
final ServiceState state = new ServiceState();
state.dipatchToStarting();
state.dipatchToStarting();
}
use of org.bboxdb.commons.ServiceState in project bboxdb by jnidzwetzki.
the class TestServiceState method testTransition1.
/**
* Normal dispatching
* @throws InterruptedException
*/
@Test(timeout = 1000)
public void testTransition1() throws InterruptedException {
final ServiceState state = new ServiceState();
Assert.assertFalse(state.isInFinishedState());
state.dipatchToStarting();
state.awaitStarting();
Assert.assertTrue(state.isInStartingState());
Assert.assertFalse(state.isInRunningState());
Assert.assertFalse(state.isInStoppingState());
Assert.assertFalse(state.isInFailedState());
state.dispatchToRunning();
Assert.assertTrue(state.isInRunningState());
state.awaitRunning();
Assert.assertFalse(state.isInShutdownState());
state.dispatchToStopping();
Assert.assertTrue(state.isInShutdownState());
state.awaitStopping();
state.dispatchToTerminated();
state.awaitTerminatedOrFailed();
Assert.assertTrue(state.isInFinishedState());
}
use of org.bboxdb.commons.ServiceState in project bboxdb by jnidzwetzki.
the class TestServiceState method testTransition2.
/**
* Error dispatching
* @throws InterruptedException
*/
@Test(timeout = 1000, expected = IllegalStateException.class)
public void testTransition2() throws InterruptedException {
final ServiceState state = new ServiceState();
Assert.assertFalse(state.isInShutdownState());
state.dispatchToTerminated();
Assert.assertTrue(state.isInShutdownState());
state.awaitTerminatedOrFailed();
}
use of org.bboxdb.commons.ServiceState in project bboxdb by jnidzwetzki.
the class TestServiceState method testToString.
/**
* Test the to string method
*/
@Test(timeout = 60000)
public void testToString() {
final ServiceState state = new ServiceState();
final int length = state.toString().length();
final IllegalArgumentException exception = new IllegalArgumentException();
state.dispatchToFailed(exception);
final int lengthWithException = state.toString().length();
// Assume at least 100 chars for stacktrace
Assert.assertTrue(length + 100 < lengthWithException);
}
use of org.bboxdb.commons.ServiceState in project bboxdb by jnidzwetzki.
the class TestServiceState method testTransition3.
/**
* Error dispatching
* @throws InterruptedException
*/
@Test(timeout = 1000)
public void testTransition3() throws InterruptedException {
final ServiceState state = new ServiceState();
final IllegalArgumentException exception = new IllegalArgumentException();
state.dispatchToFailed(exception);
state.awaitTerminatedOrFailed();
Assert.assertTrue(state.isInFinishedState());
Assert.assertFalse(state.isInRunningState());
}