@Test
  public void test() throws ServiceException, IOException {
    Scan scan = new Scan();
    ScanRequest req = RequestConverter.buildScanRequest(HRI.getRegionName(), scan, 1, false);
    ScanResponse resp = scan(req);
    assertTrue(resp.hasScannerId());
    long scannerId = resp.getScannerId();
    int nextCallSeq = 0;
    // test next
    for (int i = 0; i < COUNT / 2; i++) {
      req = RequestConverter.buildScanRequest(scannerId, 1, false, nextCallSeq++, false, false, -1);
      resp = scan(req);
      assertTrue(resp.hasScannerId());
      assertEquals(scannerId, resp.getScannerId());
    }
    // test renew
    req = RequestConverter.buildScanRequest(scannerId, 0, false, nextCallSeq++, false, true, -1);
    resp = scan(req);
    assertTrue(resp.hasScannerId());
    assertEquals(scannerId, resp.getScannerId());
    // test close
    req = RequestConverter.buildScanRequest(scannerId, 0, true, false);
    resp = scan(req);
    assertTrue(resp.hasScannerId());
    assertEquals(scannerId, resp.getScannerId());
  }
Testcase to make sure that we always set scanner id in ScanResponse. See HBASE-18000.
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAlwaysSetScannerId.java