* This test creates some ExampleTasks and runs them.
*/
public void testAsyncDiskService() throws Throwable {
String[] vols = new String[]{"/0", "/1"};
AsyncDiskService service = new AsyncDiskService(vols);
int total = 100;
for (int i = 0; i < total; i++) {
service.execute(vols[i%2], new ExampleTask());
}
Exception e = null;
try {
service.execute("no_such_volume", new ExampleTask());
} catch (RuntimeException ex) {
e = ex;
}
assertNotNull("Executing a task on a non-existing volume should throw an "
+ "Exception.", e);
service.shutdown();
if (!service.awaitTermination(5000)) {
fail("AsyncDiskService didn't shutdown in 5 seconds.");
}
assertEquals(total, count);
}