@Test
  public void testAggregation() throws Throwable {
    Table table = util.getConnection().getTable(TEST_TABLE);
    Map<byte[], SumResponse> results =
      sum(table, TEST_FAMILY, TEST_QUALIFIER, ROWS[0], ROWS[ROWS.length - 1]);
    long sumResult = 0;
    long expectedResult = 0;
    for (Map.Entry<byte[], SumResponse> e : results.entrySet()) {
      LOG.info(
        "Got value " + e.getValue().getSum() + " for region " + Bytes.toStringBinary(e.getKey()));
      sumResult += e.getValue().getSum();
    }
    for (long i = 0; i < ROWSIZE; i++) {
      expectedResult += i;
    }
    assertEquals("Invalid result", expectedResult, sumResult);

    // scan: for region 2 and region 3
    results = sum(table, TEST_FAMILY, TEST_QUALIFIER, ROWS[rowSeperator1], ROWS[ROWS.length - 1]);
    sumResult = 0;
    expectedResult = 0;
    for (Map.Entry<byte[], SumResponse> e : results.entrySet()) {
      LOG.info(
        "Got value " + e.getValue().getSum() + " for region " + Bytes.toStringBinary(e.getKey()));
      sumResult += e.getValue().getSum();
    }
    for (long i = rowSeperator1; i < ROWSIZE; i++) {
      expectedResult += i;
    }
    assertEquals("Invalid result", expectedResult, sumResult);
    table.close();
  }
TestEndpoint: test cases to verify the batch execution of coprocessor Endpoint
hbase-endpoint/src/test/java/org/apache/hadoop/hbase/coprocessor/TestBatchCoprocessorEndpoint.java