@Test
  public void testExpiredScanner() throws Exception {
    Configuration conf = UTIL.getConfiguration();
    conf.setLong(HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, 1000);
    ThriftHBaseServiceHandler handler =
      new ThriftHBaseServiceHandler(conf, UserProvider.instantiate(conf));

    TScan scan = new TScan();
    ByteBuffer table = wrap(tableAname);

    int scannerId = handler.openScanner(table, scan);
    handler.getScannerRows(scannerId, 1);
    Thread.sleep(1000);

    try {
      handler.getScannerRows(scannerId, 1);
      fail("The scanner should be expired and have an TIllegalArgument exception here.");
    } catch (TIllegalArgument e) {
      assertEquals("Invalid scanner Id", e.getMessage());
    } finally {
      conf.setLong(HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD,
        DEFAULT_HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD);
    }
  }
Tests keeping a HBase scanner alive for long periods of time. Each call to getScannerRow()
should reset the ConnectionCache timeout for the scanner's connection.
hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java