* Parallel execution.
* @throws Exception if failed
*/
@Test(timeout = 5000)
public void parallel() throws Exception {
JobScheduler instance = create(
"parallel.default", "1",
"parallel.para", "2");
final CyclicBarrier barrier = new CyclicBarrier(3);
List<Mock> jobs = new ArrayList<Mock>();
jobs.add(new Mock("a0") {
@Override
protected void hook() throws InterruptedException, IOException {
try {
barrier.await();
} catch (BrokenBarrierException e) {
throw new IOException(e);
}
}
}.resource("para"));
jobs.add(new Mock("a2") {
@Override
protected void hook() throws InterruptedException, IOException {
try {
barrier.await();
} catch (BrokenBarrierException e) {
throw new IOException(e);
}
}
}.resource("para"));
jobs.add(new Mock("a3") {
@Override
protected void hook() throws InterruptedException, IOException {
try {
barrier.await();
} catch (BrokenBarrierException e) {
throw new IOException(e);
}
}
}.resource("otherwise"));
instance.execute(PhaseMonitor.NULL, CONTEXT, jobs, JobScheduler.STRICT);
Set<String> rest = collectRest(jobs);
assertThat(rest.size(), is(0));
}