protected final void testRenameFamily(Configuration conf) throws Exception {
    TableName sourceTable = TableName.valueOf(name.getMethodName() + "-source");
    TableName targetTable = TableName.valueOf(name.getMethodName() + "-target");

    TableDescriptor desc1 = TableDescriptorBuilder.newBuilder(sourceTable)
      .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY_A))
      .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY_B)).build();
    TableDescriptor desc2 = TableDescriptorBuilder.newBuilder(targetTable)
      .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY_A))
      .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY_B)).build();

    try (Table t = createSourceTable(desc1); Table t2 = createTargetTable(desc2)) {
      Put p = new Put(ROW1);
      p.addColumn(FAMILY_A, QUALIFIER, Bytes.toBytes("Data11"));
      p.addColumn(FAMILY_B, QUALIFIER, Bytes.toBytes("Data12"));
      p.addColumn(FAMILY_A, QUALIFIER, Bytes.toBytes("Data13"));
      t.put(p);
      p = new Put(ROW2);
      p.addColumn(FAMILY_B, QUALIFIER, Bytes.toBytes("Dat21"));
      p.addColumn(FAMILY_A, QUALIFIER, Bytes.toBytes("Data22"));
      p.addColumn(FAMILY_B, QUALIFIER, Bytes.toBytes("Data23"));
      t.put(p);

      long currentTime = EnvironmentEdgeManager.currentTime();
      String[] args = ArrayUtils.addAll(getPeerClusterOptions(), "--new.name=" + targetTable,
        "--families=a:b", "--all.cells", "--starttime=" + (currentTime - 100000),
        "--endtime=" + (currentTime + 100000), "--versions=1", sourceTable.getNameAsString());
      assertNull(t2.get(new Get(ROW1)).getRow());

      assertTrue(runCopy(conf, args));

      assertNotNull(t2.get(new Get(ROW1)).getRow());
      Result res = t2.get(new Get(ROW1));
      byte[] b1 = res.getValue(FAMILY_B, QUALIFIER);
      assertEquals("Data13", Bytes.toString(b1));
      assertNotNull(t2.get(new Get(ROW2)).getRow());
      res = t2.get(new Get(ROW2));
      b1 = res.getValue(FAMILY_A, QUALIFIER);
      // Data from the family of B is not copied
      assertNull(b1);
    } finally {
      dropSourceTable(sourceTable);
      dropTargetTable(targetTable);
    }
  }
Base class for testing CopyTable MR tool.
hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/CopyTableTestBase.java