@Test
  public void testAsyncConcurrent() throws Exception {
    String tableName = "TestHiveServer2TestConnection";
    CLIServiceClient serviceClient = miniHS2.getServiceClient();
    SessionHandle sessHandle = serviceClient.openSession("foo", "bar");
    serviceClient.executeStatement(sessHandle, "DROP TABLE IF EXISTS " + tableName, confOverlay);
    serviceClient.executeStatement(sessHandle, "CREATE TABLE " + tableName + " (id INT) STORED AS ORC", confOverlay);
    serviceClient.executeStatement(sessHandle, "insert into " + tableName + " values(5)", confOverlay);
    OperationHandle opHandle =
        serviceClient.executeStatementAsync(sessHandle, "select * from " + tableName, confOverlay);
    assertOperationFinished(serviceClient, opHandle);
    RowSet rowSet = serviceClient.fetchResults(opHandle);
    serviceClient.executeStatement(sessHandle,
        "create temporary function sleepMsUDF as '" + TestHiveServer2Acid.SleepMsUDF.class.getName() + "'",
        confOverlay);
    // Start a second "slow" query
    OperationHandle opHandle2 = serviceClient
        .executeStatementAsync(sessHandle, "select sleepMsUDF(id, 1000), id from " + tableName, confOverlay);
    // Close the first operation (this will destroy the Driver and TxnManager)
    serviceClient.closeOperation(opHandle);
    assertEquals(1, rowSet.numRows());
    assertOperationFinished(serviceClient, opHandle2);
    rowSet = serviceClient.fetchResults(opHandle2);
    assertEquals(1, rowSet.numRows());
    serviceClient.closeSession(sessHandle);
  }
Test overlapping async queries in one session.
Since TxnManager is shared in the session this can cause all kind of trouble.
@throws Exception ex
itests/hive-unit/src/test/java/org/apache/hive/jdbc/miniHS2/TestHiveServer2Acid.java