/**
* Test maximum cache
*/
public void testCompleteTimeout() throws Exception
{
BasicThreadPool pool = new BasicThreadPool();
pool.setMaximumQueueSize(1);
pool.setMaximumPoolSize(1);
try
{
/* Test that a task with a timeout that completes within its timeout
works as expected
*/
TestTask task = new TestTask(HOLD_START, "test1", 0, 10*1000, Task.WAIT_NONE);
pool.runTask(task);
started.wait(1);
started.release("test1");
completed.wait(1);
/* Test a task with a timeout that does not complete within its timeout
is stopped
*/
task = new TestTask(HOLD_START, "test2", 0, 10*1000, Task.WAIT_NONE);
task.setRunSleepTime(12*1000);
pool.runTask(task);
started.wait(1);
started.release("test2");
stopped.wait(1);
completed.wait(1);
// Test that another valid task completes as expected
task = new TestTask(HOLD_START, "test3", 0, 0, Task.WAIT_NONE);
pool.runTask(task);
started.wait(1);
started.release("test3");
completed.wait(1);
/* Test a task with a timeout that does not complete within its timeout
is stopped
*/
task = new TestTask(HOLD_START, "test4", 0, 10*1000, Task.WAIT_NONE);
task.setRunSleepTime(12*1000);
pool.runTask(task);
started.wait(1);
started.release("test4");
stopped.wait(1);
completed.wait(1);
}
finally
{
pool.stop(true);
}
}