use of alma.acsdaemonErrType.ServiceAlreadyRunningEx in project ACS by ACS-Community.
the class ServicesDaemonTest method testStartServiceTwice.
/**
* Test starting service twice. It must return ServiceAlreadyRunning exception (immediately or via callback).
*/
public void testStartServiceTwice() throws Exception {
DaemonCallbackImpl daemonCallbackImpl = new DaemonCallbackImpl(logger);
DaemonCallback dcb = activateDaemonCallback(daemonCallbackImpl);
// start naming service and wait till it's up
daemonCallbackImpl.prepareWaitForDone("naming");
daemon.start_naming_service(dcb, instanceNumber);
assertTrue("Failed to start naming service in 10 s", daemonCallbackImpl.waitForDone(10, TimeUnit.SECONDS));
assertNamingService(true);
try {
// now start it again
daemonCallbackImpl.prepareWaitForDone("naming");
daemon.start_naming_service(dcb, instanceNumber);
assertTrue("Failed to get reply about starting of second naming service within 10 s", daemonCallbackImpl.waitForDone(10, TimeUnit.SECONDS));
// error via callback?
if (daemonCallbackImpl.getLastDoneCompletion().type != alma.ACSErr.acsdaemonErrType.value || daemonCallbackImpl.getLastDoneCompletion().code != alma.acsdaemonErrType.ServiceAlreadyRunning.value)
fail("Expected ServiceAlreadyRunningEx when starting naming service twice.");
} catch (ServiceAlreadyRunningEx ex) {
// good
logger.info("Got expected ServiceAlreadyRunningEx from attempting to start naming service twice.");
assertEquals("Naming", AcsJServiceAlreadyRunningEx.fromServiceAlreadyRunningEx(ex).getService());
} finally {
daemonCallbackImpl.prepareWaitForDone("naming");
daemon.stop_naming_service(dcb, instanceNumber);
assertTrue("Failed to stop naming service in 5 s", daemonCallbackImpl.waitForDone(5, TimeUnit.SECONDS));
}
}
Aggregations