protected final void testStartStopRow(Configuration conf) throws Exception {
    final TableName tableName1 = TableName.valueOf(name.getMethodName() + "1");
    final TableName tableName2 = TableName.valueOf(name.getMethodName() + "2");
    final byte[] family = Bytes.toBytes("family");
    final byte[] column = Bytes.toBytes("c1");
    final byte[] row0 = Bytes.toBytesBinary("\\x01row0");
    final byte[] row1 = Bytes.toBytesBinary("\\x01row1");
    final byte[] row2 = Bytes.toBytesBinary("\\x01row2");
    TableDescriptor desc1 = TableDescriptorBuilder.newBuilder(tableName1)
      .setColumnFamily(ColumnFamilyDescriptorBuilder.of(family)).build();
    TableDescriptor desc2 = TableDescriptorBuilder.newBuilder(tableName2)
      .setColumnFamily(ColumnFamilyDescriptorBuilder.of(family)).build();
    try (Table t1 = createSourceTable(desc1); Table t2 = createTargetTable(desc2)) {
      // put rows into the first table
      Put p = new Put(row0);
      p.addColumn(family, column, column);
      t1.put(p);
      p = new Put(row1);
      p.addColumn(family, column, column);
      t1.put(p);
      p = new Put(row2);
      p.addColumn(family, column, column);
      t1.put(p);

      String[] peerClusterOptions = getPeerClusterOptions();
      assertTrue(runCopy(conf, ArrayUtils.addAll(peerClusterOptions, "--new.name=" + tableName2,
        "--startrow=\\x01row1", "--stoprow=\\x01row2", tableName1.getNameAsString())));

      // verify the data was copied into table 2
      // row1 exist, row0, row2 do not exist
      Get g = new Get(row1);
      Result r = t2.get(g);
      assertEquals(1, r.size());
      assertTrue(CellUtil.matchingQualifier(r.rawCells()[0], column));

      g = new Get(row0);
      r = t2.get(g);
      assertEquals(0, r.size());

      g = new Get(row2);
      r = t2.get(g);
      assertEquals(0, r.size());
    } finally {
      dropSourceTable(tableName1);
      dropTargetTable(tableName2);
    }
  }
Base class for testing CopyTable MR tool.
hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/CopyTableTestBase.java