LifecycleController { public static boolean waitForOneOf(LifecycleAware delegate, LifecycleState[] states) throws InterruptedException { return waitForOneOf(delegate, states, 0); }  static boolean waitForState(LifecycleAware delegate,
      LifecycleState state); static boolean waitForState(LifecycleAware delegate,
      LifecycleState state, long timeout); static boolean waitForOneOf(LifecycleAware delegate,
      LifecycleState[] states); static boolean waitForOneOf(LifecycleAware delegate,
      LifecycleState[] states, long timeout); static void stopAll(List<LifecycleAware> services);  }
@Test public void testWaitForOneOf() throws LifecycleException, InterruptedException { LifecycleAware delegate = new SleeperLifecycleDelegate(); Assert.assertEquals(LifecycleState.IDLE, delegate.getLifecycleState()); delegate.start(); boolean reached = LifecycleController.waitForOneOf(delegate, new LifecycleState[] { LifecycleState.STOP, LifecycleState.START }, 2000); Assert.assertTrue("Matched a state change", reached); Assert.assertEquals(LifecycleState.START, delegate.getLifecycleState()); }