use of org.apache.sling.event.jobs.consumer.JobExecutionContext in project sling by apache.
the class JobHandlingTest method testSimpleJobExecutionUsingJobExecutor.
/**
* Test simple job execution.
* The job is executed once and finished successfully.
*/
@Test(timeout = DEFAULT_TEST_TIMEOUT)
public void testSimpleJobExecutionUsingJobExecutor() throws Exception {
final Barrier cb = new Barrier(2);
this.registerJobExecutor(TOPIC, new JobExecutor() {
@Override
public JobExecutionResult process(final Job job, final JobExecutionContext context) {
cb.block();
return context.result().succeeded();
}
});
this.getJobManager().addJob(TOPIC, null);
assertTrue("No event received in the given time.", cb.block(5));
cb.reset();
assertFalse("Unexpected event received in the given time.", cb.block(5));
}
Aggregations