@Test (expected = SystemManagementException.class) public void testChangeStateExceptions_5() { CMSState state = new CMSState(); state.setState(CMSState.State.shutdown); state.setState(CMSState.State.normal); }
public synchronized void setState(final State to) { CheckConditions.checkNotNull(to); if (to == state) { return; } if (stateMap.get(state).contains(to)) { final State oldState = state; state = to; logger.info("state changed from {} to {}", oldState, to); for (final IEventListener e : listeners) { executor.execute(new EventNotifier(e, oldState, to)); } if (to == State.shutdown) { executor.shutdown(); } } else { logger.error("Can not switch state from " + state + " to " + to); throw new SystemManagementException("Can not switch state from " + state + " to " + to); } }
CMSState { public synchronized void setState(final State to) { CheckConditions.checkNotNull(to); if (to == state) { return; } if (stateMap.get(state).contains(to)) { final State oldState = state; state = to; logger.info("state changed from {} to {}", oldState, to); for (final IEventListener e : listeners) { executor.execute(new EventNotifier(e, oldState, to)); } if (to == State.shutdown) { executor.shutdown(); } } else { logger.error("Can not switch state from " + state + " to " + to); throw new SystemManagementException("Can not switch state from " + state + " to " + to); } } }
CMSState { public synchronized void setState(final State to) { CheckConditions.checkNotNull(to); if (to == state) { return; } if (stateMap.get(state).contains(to)) { final State oldState = state; state = to; logger.info("state changed from {} to {}", oldState, to); for (final IEventListener e : listeners) { executor.execute(new EventNotifier(e, oldState, to)); } if (to == State.shutdown) { executor.shutdown(); } } else { logger.error("Can not switch state from " + state + " to " + to); throw new SystemManagementException("Can not switch state from " + state + " to " + to); } } CMSState(); }
CMSState { public synchronized void setState(final State to) { CheckConditions.checkNotNull(to); if (to == state) { return; } if (stateMap.get(state).contains(to)) { final State oldState = state; state = to; logger.info("state changed from {} to {}", oldState, to); for (final IEventListener e : listeners) { executor.execute(new EventNotifier(e, oldState, to)); } if (to == State.shutdown) { executor.shutdown(); } } else { logger.error("Can not switch state from " + state + " to " + to); throw new SystemManagementException("Can not switch state from " + state + " to " + to); } } CMSState(); void registerEvent(IEventListener listener); boolean removeEvent(IEventListener listener); synchronized State getState(); synchronized boolean checkAndSetState(final State from, final State to); synchronized void setState(final State to); }
CMSState { public synchronized void setState(final State to) { CheckConditions.checkNotNull(to); if (to == state) { return; } if (stateMap.get(state).contains(to)) { final State oldState = state; state = to; logger.info("state changed from {} to {}", oldState, to); for (final IEventListener e : listeners) { executor.execute(new EventNotifier(e, oldState, to)); } if (to == State.shutdown) { executor.shutdown(); } } else { logger.error("Can not switch state from " + state + " to " + to); throw new SystemManagementException("Can not switch state from " + state + " to " + to); } } CMSState(); void registerEvent(IEventListener listener); boolean removeEvent(IEventListener listener); synchronized State getState(); synchronized boolean checkAndSetState(final State from, final State to); synchronized void setState(final State to);  }