CachedAlertFlushService extends AbstractScheduledService { @Override protected void startUp() throws Exception { boolean enabled = m_configuration.isAlertCacheEnabled(); if (!enabled) { stopAsync(); } }    }
@Test public void testServiceIsDisabled() throws Exception { Configuration configuration = m_injector.getInstance(Configuration.class); EasyMock.expect(configuration.isAlertCacheEnabled()).andReturn(Boolean.FALSE).atLeastOnce(); CachedAlertFlushService service = PowerMockito.spy(new CachedAlertFlushService()); PowerMockito.doReturn(null).when(service).stopAsync(); replayAll(); m_injector.injectMembers(service); service.startUp(); PowerMockito.verifyPrivate(service).invoke("stopAsync"); verifyAll(); }