@Test
  public void testBinaryKeys() throws Exception {
    Set<Cell> set = new TreeSet<>(CellComparatorImpl.COMPARATOR);
    final byte[] fam = Bytes.toBytes("col");
    final byte[] qf = Bytes.toBytes("umn");
    final byte[] nb = new byte[0];
    Cell[] keys = {
      createByteBufferKeyValueFromKeyValue(
        new KeyValue(Bytes.toBytes("aaaaa,\u0000\u0000,2"), fam, qf, 2, nb)),
      createByteBufferKeyValueFromKeyValue(
        new KeyValue(Bytes.toBytes("aaaaa,\u0001,3"), fam, qf, 3, nb)),
      createByteBufferKeyValueFromKeyValue(new KeyValue(Bytes.toBytes("aaaaa,,1"), fam, qf, 1, nb)),
      createByteBufferKeyValueFromKeyValue(
        new KeyValue(Bytes.toBytes("aaaaa,\u1000,5"), fam, qf, 5, nb)),
      createByteBufferKeyValueFromKeyValue(
        new KeyValue(Bytes.toBytes("aaaaa,a,4"), fam, qf, 4, nb)),
      createByteBufferKeyValueFromKeyValue(new KeyValue(Bytes.toBytes("a,a,0"), fam, qf, 0, nb)), };
    // Add to set with bad comparator
    Collections.addAll(set, keys);
    // This will output the keys incorrectly.
    boolean assertion = false;
    int count = 0;
    for (Cell k : set) {
      if (!(count++ == k.getTimestamp())) {
        assertion = true;
      }
    }
    assertTrue(assertion);
    // Make set with good comparator
    set = new TreeSet<>(MetaCellComparator.META_COMPARATOR);
    Collections.addAll(set, keys);
    count = 0;
    for (Cell k : set) {
      assertTrue("count=" + count + ", " + k.toString(), count++ == k.getTimestamp());
    }
  }
More tests using ByteBufferKeyValue copied over from TestKeyValue which uses old KVs only.
hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellComparator.java