@@ -0,0 +1,1280 @@
+package com.datastax.driver.core;%0A%0Aimport java.util.Collection;%0Aimport java.util.concurrent.TimeUnit;%0A%0Aimport com.google.common.collect.Lists;%0Aimport org.testng.annotations.Test;%0A%0Aimport static org.testng.Assert.assertEquals;%0Aimport static org.testng.Assert.assertTrue;%0A%0Apublic class AsyncQueryTest extends CCMBridge.PerClassSingleNodeCluster %7B%0A%0A    @Override%0A    protected Collection%3CString%3E getTableDefinitions() %7B%0A        return Lists.newArrayList();%0A    %7D%0A%0A    /**%0A     * Checks that a cancelled query releases the connection (JAVA-407).%0A     */%0A    @Test(groups = %22short%22)%0A    public void cancelQueryTest() throws InterruptedException %7B%0A        ResultSetFuture future = session.executeAsync(%22select release_version from system.local%22);%0A        future.cancel(true);%0A        assertTrue(future.isCancelled());%0A%0A        TimeUnit.MILLISECONDS.sleep(100);%0A%0A        HostConnectionPool pool = getPool(session);%0A        for (Connection connection : pool.connections) %7B%0A            assertEquals(connection.inFlight.get(), 0);%0A        %7D%0A    %7D%0A%0A    private static HostConnectionPool getPool(Session session) %7B%0A        Collection%3CHostConnectionPool%3E pools = ((SessionManager) session).pools.values();%0A        assertEquals(pools.size(), 1);%0A        return pools.iterator().next();%0A    %7D%0A%7D%0A

Test connection release on ResultSetFuture#cancel (JAVA-407).