@Test
 public void jobsOnStoppingShouldBeExecuted() throws Exception {
   ApplicationStopTestJob.results.clear();
   jobManager.start();
   jobManager.stop();
   stopped = true;
   assertThat(ApplicationStopTestJob.results, hasSize(1));
 }
 @Test
 public void jobsWithEveryAnnotationShouldBeExecuted() throws Exception {
   EveryTestJob.results.clear();
   jobManager.start();
   Thread.sleep(5000);
   assertThat(EveryTestJob.results, hasSize(greaterThan(5)));
 }
 @Test
 public void jobsOnStartupShouldBeExecuted() throws Exception {
   ApplicationStartTestJob.results.clear();
   jobManager.start();
   Thread.sleep(1000);
   assertThat(ApplicationStartTestJob.results, hasSize(1));
 }
 @After
 public void tearDown() throws Exception {
   if (!stopped) {
     jobManager.stop();
   }
   jobManager = null;
 }
 @Test
 public void jobsWithEveryAnnotationAndNoValueShouldBeExternallyConfigured() throws Exception {
   givenConfigurationFor("everyTestJobDefaultConfiguration", "1s");
   EveryTestJobDefaultConfiguration.results.clear();
   jobManager.start();
   Thread.sleep(5000);
   assertThat(EveryTestJobDefaultConfiguration.results, hasSize(greaterThan(5)));
 }
 @Test
 public void jobsWithEveryAnnotationAndDelayStartShouldWaitToBeExecuted() throws Exception {
   EveryTestJobWithDelay.results.clear();
   jobManager.start();
   Thread.sleep(2500);
   assertThat(EveryTestJobWithDelay.results, hasSize(0));
   Thread.sleep(2500);
   assertThat(EveryTestJobWithDelay.results, hasSize(lessThan(4)));
 }
 private void givenConfigurationFor(String key, String value) {
   TestConfig config = new TestConfig();
   config.getJobs().put(key, value);
   jobManager.configure(config);
 }