public static void testCancel() throws Exception {
final ProtocolDataSource ds = new ProtocolDataSource(url);
ds.setConnectionPoolSize(1);
Connection conn = ds.getConnection(NoCredentials.INSTANCE);
final Command c = conn.createCommand(query);
final Command c2 = conn.createCommand(query);
final CountDownLatch done = new CountDownLatch(2);
new Thread(new Runnable() {
public void run() {
exec(c);
done.countDown();
}
}).start();
new Thread(new Runnable() {
public void run() {
exec(c2);
done.countDown();
}
}).start();
Thread.sleep(5000);
log("canceling query 1");
c.cancel();
c2.cancel();
done.await();
log("query 1 thread done");
final CountDownLatch query = new CountDownLatch(1);
final CountDownLatch cancel = new CountDownLatch(1);