impl.setStackVersion(null);
}
Assert.assertEquals(startState,
impl.getState());
ServiceComponentHostEvent startEvent = createEvent(impl, ++timestamp,
startEventType);
long startTime = timestamp;
impl.handleEvent(startEvent);
Assert.assertEquals(startTime, impl.getLastOpStartTime());
Assert.assertEquals(-1, impl.getLastOpLastUpdateTime());
Assert.assertEquals(-1, impl.getLastOpEndTime());
Assert.assertEquals(inProgressState,
impl.getState());
if (checkStack) {
Assert.assertNotNull(impl.getStackVersion());
Assert.assertEquals(impl.getDesiredStackVersion().getStackId(),
impl.getStackVersion().getStackId());
}
ServiceComponentHostEvent installEvent2 = createEvent(impl, ++timestamp,
startEventType);
boolean exceptionThrown = false;
LOG.info("Transitioning from " + impl.getState() + " " + installEvent2.getType());
try {
impl.handleEvent(installEvent2);
} catch (Exception e) {
exceptionThrown = true;
}
if (impl.getState() == State.INSTALLING || impl.getState() == State.STARTING
|| impl.getState() == State.UNINSTALLING
|| impl.getState() == State.WIPING_OUT
|| impl.getState() == State.STARTED
) {
startTime = timestamp;
// Exception is not expected on valid event
Assert.assertTrue("Exception not thrown on invalid event", !exceptionThrown);
}
else {
Assert.assertTrue("Exception not thrown on invalid event", exceptionThrown);
}
Assert.assertEquals(startTime, impl.getLastOpStartTime());
Assert.assertEquals(-1, impl.getLastOpLastUpdateTime());
Assert.assertEquals(-1, impl.getLastOpEndTime());
Assert.assertEquals(inProgressState,
impl.getState());
ServiceComponentHostOpInProgressEvent inProgressEvent1 = new
ServiceComponentHostOpInProgressEvent(impl.getServiceComponentName(),
impl.getHostName(), ++timestamp);
impl.handleEvent(inProgressEvent1);
Assert.assertEquals(startTime, impl.getLastOpStartTime());
Assert.assertEquals(timestamp, impl.getLastOpLastUpdateTime());
Assert.assertEquals(-1, impl.getLastOpEndTime());
Assert.assertEquals(inProgressState,
impl.getState());
ServiceComponentHostOpInProgressEvent inProgressEvent2 = new
ServiceComponentHostOpInProgressEvent(impl.getServiceComponentName(),
impl.getHostName(), ++timestamp);
impl.handleEvent(inProgressEvent2);
Assert.assertEquals(startTime, impl.getLastOpStartTime());
Assert.assertEquals(timestamp, impl.getLastOpLastUpdateTime());
Assert.assertEquals(-1, impl.getLastOpEndTime());
Assert.assertEquals(inProgressState,
impl.getState());
ServiceComponentHostOpFailedEvent failEvent = new
ServiceComponentHostOpFailedEvent(impl.getServiceComponentName(),
impl.getHostName(), ++timestamp);
long endTime = timestamp;
impl.handleEvent(failEvent);
Assert.assertEquals(startTime, impl.getLastOpStartTime());
Assert.assertEquals(timestamp, impl.getLastOpLastUpdateTime());
Assert.assertEquals(endTime, impl.getLastOpEndTime());
Assert.assertEquals(failedState,
impl.getState());
ServiceComponentHostOpRestartedEvent restartEvent = new
ServiceComponentHostOpRestartedEvent(impl.getServiceComponentName(),
impl.getHostName(), ++timestamp);
startTime = timestamp;
impl.handleEvent(restartEvent);
Assert.assertEquals(startTime, impl.getLastOpStartTime());
Assert.assertEquals(-1, impl.getLastOpLastUpdateTime());
Assert.assertEquals(-1, impl.getLastOpEndTime());
Assert.assertEquals(inProgressState,
impl.getState());
ServiceComponentHostOpInProgressEvent inProgressEvent3 = new
ServiceComponentHostOpInProgressEvent(impl.getServiceComponentName(),
impl.getHostName(), ++timestamp);
impl.handleEvent(inProgressEvent3);
Assert.assertEquals(startTime, impl.getLastOpStartTime());
Assert.assertEquals(timestamp, impl.getLastOpLastUpdateTime());
Assert.assertEquals(-1, impl.getLastOpEndTime());
Assert.assertEquals(inProgressState,
impl.getState());
ServiceComponentHostOpFailedEvent failEvent2 = new
ServiceComponentHostOpFailedEvent(impl.getServiceComponentName(),
impl.getHostName(), ++timestamp);
endTime = timestamp;
impl.handleEvent(failEvent2);
Assert.assertEquals(startTime, impl.getLastOpStartTime());
Assert.assertEquals(timestamp, impl.getLastOpLastUpdateTime());
Assert.assertEquals(endTime, impl.getLastOpEndTime());
Assert.assertEquals(failedState,
impl.getState());
ServiceComponentHostEvent startEvent2 = createEvent(impl, ++timestamp,
startEventType);
startTime = timestamp;
impl.handleEvent(startEvent2);
Assert.assertEquals(-1, impl.getLastOpLastUpdateTime());
Assert.assertEquals(-1, impl.getLastOpEndTime());
Assert.assertEquals(inProgressState,
impl.getState());
ServiceComponentHostOpInProgressEvent inProgressEvent4 = new
ServiceComponentHostOpInProgressEvent(impl.getServiceComponentName(),
impl.getHostName(), ++timestamp);
impl.handleEvent(inProgressEvent4);
Assert.assertEquals(startTime, impl.getLastOpStartTime());
Assert.assertEquals(timestamp, impl.getLastOpLastUpdateTime());
Assert.assertEquals(-1, impl.getLastOpEndTime());
Assert.assertEquals(inProgressState,
impl.getState());
ServiceComponentHostEvent succeededEvent;
if (startEventType == ServiceComponentHostEventType.HOST_SVCCOMP_START) {
succeededEvent = new ServiceComponentHostStartedEvent(impl.getServiceComponentName(),
impl.getHostName(), ++timestamp);
} else if (startEventType == ServiceComponentHostEventType.HOST_SVCCOMP_STOP) {
succeededEvent = new ServiceComponentHostStoppedEvent(impl.getServiceComponentName(),