@Test @Ignore public void testPutJob() { final TaskGraph tg = new TaskGraph(); tg.addTask(this.A); tg.addTask(this.B); tg.addTask(this.C, this.A); tg.addTask(this.D, this.A); final TaskGraph tg2 = new TaskGraph(); tg2.addTask(this.A); tg2.addTask(this.B); tg2.addTask(this.C, this.A); tg2.addTask(this.D, this.A); final TaskGraph tg3 = new TaskGraph(); tg3.addTask(this.A); tg3.addTask(this.B); tg3.addTask(this.C, this.A); tg3.addTask(this.D, this.A); @SuppressWarnings("unchecked") final List<String> mockList = mock(List.class); JobEngine.getEngine().addJobCompletionListener(new JobCompletionListener() { @Override public void completed(Job job) { mockList.add(job.getName()); } }); Runnable job1Runnable = new Runnable() { @Override public void run() { JobQueuer.getInstance().putJob(new JobRequest("Job-parallel-nested1", tg, false)); } }; Runnable job2Runnable = new Runnable() { @Override public void run() { JobQueuer.getInstance().putJob(new JobRequest("Job-parallel-nested2", tg2, false)); } }; Runnable job3Runnable = new Runnable() { @Override public void run() { JobQueuer.getInstance().putJob(new JobRequest("Job-parallel-nested3", tg3, false)); } }; new Thread(job1Runnable).start(); try { Thread.sleep(1000); } catch (InterruptedException e1) { e1.printStackTrace(); } new Thread(job2Runnable).start(); new Thread(job3Runnable).start(); InOrder inOrder = inOrder(mockList); verify(mockList, new Timeout(5000, new InOrderWrapper(new Times(1), (InOrderImpl) inOrder))).add( "Job-parallel-nested1"); verify(mockList, new Timeout(5000, new InOrderWrapper(new Times(1), (InOrderImpl) inOrder))).add( "Job-parallel-nested2"); verify(mockList, new Timeout(5000, new InOrderWrapper(new Times(1), (InOrderImpl) inOrder))).add( "Job-parallel-nested3"); verifyNoMoreInteractions(mockList); }
public synchronized void putJob(JobRequest job) { try { log.info(String.format("Job %s put into queue", job.getName())); jobQueue.put(job); } catch (InterruptedException e) { log.warn("Putting job in queue was interrupted.", e); } }
JobQueuer { public synchronized void putJob(JobRequest job) { try { log.info(String.format("Job %s put into queue", job.getName())); jobQueue.put(job); } catch (InterruptedException e) { log.warn("Putting job in queue was interrupted.", e); } } }
JobQueuer { public synchronized void putJob(JobRequest job) { try { log.info(String.format("Job %s put into queue", job.getName())); jobQueue.put(job); } catch (InterruptedException e) { log.warn("Putting job in queue was interrupted.", e); } } private  JobQueuer(); }
JobQueuer { public synchronized void putJob(JobRequest job) { try { log.info(String.format("Job %s put into queue", job.getName())); jobQueue.put(job); } catch (InterruptedException e) { log.warn("Putting job in queue was interrupted.", e); } } private  JobQueuer(); static synchronized JobQueuer getInstance(); synchronized void putJob(JobRequest job); }
JobQueuer { public synchronized void putJob(JobRequest job) { try { log.info(String.format("Job %s put into queue", job.getName())); jobQueue.put(job); } catch (InterruptedException e) { log.warn("Putting job in queue was interrupted.", e); } } private  JobQueuer(); static synchronized JobQueuer getInstance(); synchronized void putJob(JobRequest job);  }