Exemplo n.º 1
0
 @Test
 public void jobsOnStoppingShouldBeExecuted() throws Exception {
   ApplicationStopTestJob.results.clear();
   jobManager.start();
   jobManager.stop();
   stopped = true;
   assertThat(ApplicationStopTestJob.results, hasSize(1));
 }
Exemplo n.º 2
0
 @Test
 public void jobsWithEveryAnnotationShouldBeExecuted() throws Exception {
   EveryTestJob.results.clear();
   jobManager.start();
   Thread.sleep(5000);
   assertThat(EveryTestJob.results, hasSize(greaterThan(5)));
 }
Exemplo n.º 3
0
 @Test
 public void jobsOnStartupShouldBeExecuted() throws Exception {
   ApplicationStartTestJob.results.clear();
   jobManager.start();
   Thread.sleep(1000);
   assertThat(ApplicationStartTestJob.results, hasSize(1));
 }
Exemplo n.º 4
0
 @After
 public void tearDown() throws Exception {
   if (!stopped) {
     jobManager.stop();
   }
   jobManager = null;
 }
Exemplo n.º 5
0
 @Test
 public void jobsWithEveryAnnotationAndNoValueShouldBeExternallyConfigured() throws Exception {
   givenConfigurationFor("everyTestJobDefaultConfiguration", "1s");
   EveryTestJobDefaultConfiguration.results.clear();
   jobManager.start();
   Thread.sleep(5000);
   assertThat(EveryTestJobDefaultConfiguration.results, hasSize(greaterThan(5)));
 }
Exemplo n.º 6
0
 @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)));
 }
Exemplo n.º 7
0
 private void givenConfigurationFor(String key, String value) {
   TestConfig config = new TestConfig();
   config.getJobs().put(key, value);
   jobManager.configure(config);
 }