final String id = (String)event.getProperty("id");
started.add(id);
}
});
final JobManager jobManager = this.getJobManager();
try {
jobManager.addJob(TOPIC, Collections.singletonMap("id", (Object)"1"));
jobManager.addJob(TOPIC, Collections.singletonMap("id", (Object)"2"));
jobManager.addJob(TOPIC, Collections.singletonMap("id", (Object)"3"));
jobManager.addJob(TOPIC, Collections.singletonMap("id", (Object)"4"));
jobManager.addJob(TOPIC, Collections.singletonMap("id", (Object)"5"));
int count = 0;
final long startTime = System.currentTimeMillis();
do {
count = finished.size() + cancelled.size();
// after 25 seconds we cancel the test
if ( System.currentTimeMillis() - startTime > 25000 ) {
throw new Exception("Timeout during notification test.");
}
} while ( count < 5 || started.size() < 10 );
assertEquals("Finished count", 4, finished.size());
assertEquals("Cancelled count", 1, cancelled.size());
assertEquals("Started count", 10, started.size());
assertEquals("Failed count", 5, failed.size());
} finally {
final Collection<Job> col = jobManager.findJobs(JobManager.QueryType.HISTORY, "sling/test", -1, (Map<String, Object>[])null);
for(final Job j : col) {
jobManager.removeJobById(j.getId());
}
jcReg.unregister();
eh1Reg.unregister();
eh2Reg.unregister();
eh3Reg.unregister();