@Test
public void testCancel() throws SQLException {

  HiveConnection hiveConnection = createNiceMock(HiveConnection.class);
  HiveStatement hiveStatement = createNiceMock(HiveStatement.class);
  HiveQueryResultSet resultSet = createNiceMock(HiveQueryResultSet.class);
  expect(hiveConnection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)).andReturn(hiveStatement);
  String query = "select * from test";
  expect(hiveStatement.execute(query)).andReturn(true);
  expect(hiveStatement.getResultSet()).andReturn(resultSet);
  hiveStatement.cancel();
  resultSet.close();
  replay(hiveConnection, hiveStatement, resultSet);
  HiveJdbcConnectionDelegate hiveJdbcConnectionDelegate = new HiveJdbcConnectionDelegate();
  hiveJdbcConnectionDelegate.execute(hiveConnection, query);
  hiveJdbcConnectionDelegate.cancel();
  hiveJdbcConnectionDelegate.closeResultSet();
  hiveJdbcConnectionDelegate.closeStatement();
  verify(hiveConnection, hiveStatement, resultSet);
}