@Test public void testAlreadyInCorrectState() throws Exception { WaitingOutOfStateHandler outOfStateHandler = new WaitingOutOfStateHandler(); outOfStateHandler.setCorrectState(ConfiguredComponentState.STARTED); component.changeState(StartedState.getInstance()); outOfStateHandler.handleOutOfState(component); }
@Override public void handleOutOfState(StateManagedComponent component) throws OutOfStateException { long start = new Date().getTime(); while(!component.retrieveComponentState().equals(this.getCorrectState().getComponentState())) { long now = new Date().getTime(); if (now - start > maxWaitTimeMs()) break; else { LifecycleHelper.waitQuietly(intervalToCheckMs()); } } if(!component.retrieveComponentState().equals(this.getCorrectState().getComponentState())) throw new OutOfStateException("Expected state: " + this.getCorrectState().getClass().getSimpleName() + " but got " + component.retrieveComponentState().getClass().getSimpleName()); }
WaitingOutOfStateHandler extends OutOfStateHandlerImp { @Override public void handleOutOfState(StateManagedComponent component) throws OutOfStateException { long start = new Date().getTime(); while(!component.retrieveComponentState().equals(this.getCorrectState().getComponentState())) { long now = new Date().getTime(); if (now - start > maxWaitTimeMs()) break; else { LifecycleHelper.waitQuietly(intervalToCheckMs()); } } if(!component.retrieveComponentState().equals(this.getCorrectState().getComponentState())) throw new OutOfStateException("Expected state: " + this.getCorrectState().getClass().getSimpleName() + " but got " + component.retrieveComponentState().getClass().getSimpleName()); } }
WaitingOutOfStateHandler extends OutOfStateHandlerImp { @Override public void handleOutOfState(StateManagedComponent component) throws OutOfStateException { long start = new Date().getTime(); while(!component.retrieveComponentState().equals(this.getCorrectState().getComponentState())) { long now = new Date().getTime(); if (now - start > maxWaitTimeMs()) break; else { LifecycleHelper.waitQuietly(intervalToCheckMs()); } } if(!component.retrieveComponentState().equals(this.getCorrectState().getComponentState())) throw new OutOfStateException("Expected state: " + this.getCorrectState().getClass().getSimpleName() + " but got " + component.retrieveComponentState().getClass().getSimpleName()); } WaitingOutOfStateHandler(); }
WaitingOutOfStateHandler extends OutOfStateHandlerImp { @Override public void handleOutOfState(StateManagedComponent component) throws OutOfStateException { long start = new Date().getTime(); while(!component.retrieveComponentState().equals(this.getCorrectState().getComponentState())) { long now = new Date().getTime(); if (now - start > maxWaitTimeMs()) break; else { LifecycleHelper.waitQuietly(intervalToCheckMs()); } } if(!component.retrieveComponentState().equals(this.getCorrectState().getComponentState())) throw new OutOfStateException("Expected state: " + this.getCorrectState().getClass().getSimpleName() + " but got " + component.retrieveComponentState().getClass().getSimpleName()); } WaitingOutOfStateHandler(); @Override void handleOutOfState(StateManagedComponent component); TimeInterval getMaximumWaitTime(); void setMaximumWaitTime(TimeInterval max); TimeInterval getIntervalToCheck(); void setIntervalToCheck(TimeInterval interval); }
WaitingOutOfStateHandler extends OutOfStateHandlerImp { @Override public void handleOutOfState(StateManagedComponent component) throws OutOfStateException { long start = new Date().getTime(); while(!component.retrieveComponentState().equals(this.getCorrectState().getComponentState())) { long now = new Date().getTime(); if (now - start > maxWaitTimeMs()) break; else { LifecycleHelper.waitQuietly(intervalToCheckMs()); } } if(!component.retrieveComponentState().equals(this.getCorrectState().getComponentState())) throw new OutOfStateException("Expected state: " + this.getCorrectState().getClass().getSimpleName() + " but got " + component.retrieveComponentState().getClass().getSimpleName()); } WaitingOutOfStateHandler(); @Override void handleOutOfState(StateManagedComponent component); TimeInterval getMaximumWaitTime(); void setMaximumWaitTime(TimeInterval max); TimeInterval getIntervalToCheck(); void setIntervalToCheck(TimeInterval interval);  }