StartedState extends ComponentStateImp { public static StartedState getInstance() { if (instance == null) { instance = new StartedState(); } return instance; } private  StartedState(); @Override void requestStop(StateManagedComponent comp); @Override void requestClose(StateManagedComponent comp); @Override void requestInit(StateManagedComponent comp); static StartedState getInstance();  }
@Test public void testInstance() throws Exception { StartedState one = StartedState.getInstance(); assertTrue(one == StartedState.getInstance()); assertEquals(StartedState.getInstance(), one); assertEquals(StartedState.class.getSimpleName(), one.toString()); }
@Test public void testStarted_To_Started() throws Exception { MockConnection component = new MockConnection(); component.requestStart(); StartedState state = StartedState.getInstance(); state.requestStart(component); assertEquals(StartedState.getInstance(), component.retrieveComponentState()); assertEquals(1, component.getInitCount()); assertEquals(1, component.getStartCount()); assertEquals(0, component.getStopCount()); assertEquals(0, component.getCloseCount()); }
@Test public void testRestart() throws Exception { MockConnection component = new MockConnection(); component.requestStart(); StartedState state = StartedState.getInstance(); state.requestRestart(component); assertEquals(StartedState.getInstance(), component.retrieveComponentState()); assertEquals(2, component.getInitCount()); assertEquals(2, component.getStartCount()); assertEquals(1, component.getStopCount()); assertEquals(1, component.getCloseCount()); }