private static final int JOB_COUNT = 2;
public void testBasic() throws Exception
{
WorkerMonitor monitor = new WorkerMonitorImpl(1, 2, 1, 1);
List jobs = new ArrayList(JOB_COUNT);
for (int ix = 0; ix < JOB_COUNT; ix++)
{
PortletWindow window = new PortletWindowImpl("w" + String.valueOf(ix));
jobs.add(new MockRenderJob("Job-" + (ix + 1), 4000, window));
}
assertNotNull("monitor is null", monitor);
monitor.start();
for (int ix = 0; ix < JOB_COUNT; ix++)
monitor.process((RenderingJob)jobs.get(ix));
Thread.sleep(2000);
assertTrue("available jobs expect 0", monitor.getAvailableJobsCount() == 0);
assertTrue("running jobs expect 2", monitor.getRunningJobsCount() == 2);
assertTrue("queued jobs expect 0", monitor.getQueuedJobsCount() == 0);
monitor.stop();
}