@Test
  public void testCancelOperation() 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);

    serviceClient.executeStatement(sessHandle,
        "create temporary function sleepMsUDF as '" + TestHiveServer2Acid.SleepMsUDF.class.getName() + "'",
        confOverlay);
    OperationHandle opHandle = serviceClient
        .executeStatementAsync(sessHandle, "select sleepMsUDF(id, 1000), id from " + tableName, confOverlay);
    serviceClient.cancelOperation(opHandle);
    
    assertOperationWasCancelled(serviceClient, opHandle);
    Assert.assertEquals(0, TestTxnDbUtil.countQueryAgent(
        miniHS2.getHiveConf(), 
        "select count(*) from HIVE_LOCKS"));
    Assert.assertEquals(1, TestTxnDbUtil.countQueryAgent(
        miniHS2.getHiveConf(), 
        "select 1 from TXNS where TXN_ID = (select max(TXN_ID) from TXNS) and TXN_STATE='a'"));
    serviceClient.closeSession(sessHandle);
  }
End to end test with MiniHS2 with ACID enabled.
itests/hive-unit/src/test/java/org/apache/hive/jdbc/miniHS2/TestHiveServer2Acid.java