@Test
  public void testTotalOrderCustomComparator() throws Exception {
    TezTotalOrderPartitioner partitioner = new TezTotalOrderPartitioner();
    Configuration conf = new Configuration();
    HiveKey[] revSplitStrings = Arrays.copyOf(splitStrings, splitStrings.length);
    Arrays.sort(revSplitStrings, new ReverseHiveKeyComparator());
    Path p = TestTezTotalOrderPartitioner.<HiveKey> writePartitionFile("totalordercustomcomparator",
        conf, revSplitStrings);
    conf.setBoolean(TotalOrderPartitioner.NATURAL_ORDER, false);
    conf.setClass(MRJobConfig.KEY_COMPARATOR, ReverseHiveKeyComparator.class, RawComparator.class);
    ArrayList<Check<HiveKey>> revCheck = new ArrayList<Check<HiveKey>>();
    revCheck.add(new Check<HiveKey>(new HiveKey("aaaaa".getBytes()), 9));
    revCheck.add(new Check<HiveKey>(new HiveKey("aaabb".getBytes()), 9));
    revCheck.add(new Check<HiveKey>(new HiveKey("aabbb".getBytes()), 9));
    revCheck.add(new Check<HiveKey>(new HiveKey("aaaaa".getBytes()), 9));
    revCheck.add(new Check<HiveKey>(new HiveKey("babbb".getBytes()), 8));
    revCheck.add(new Check<HiveKey>(new HiveKey("baabb".getBytes()), 8));
    revCheck.add(new Check<HiveKey>(new HiveKey("yai".getBytes()), 1));
    revCheck.add(new Check<HiveKey>(new HiveKey("yak".getBytes()), 1));
    revCheck.add(new Check<HiveKey>(new HiveKey("z".getBytes()), 0));
    revCheck.add(new Check<HiveKey>(new HiveKey("ddngo".getBytes()), 4));
    revCheck.add(new Check<HiveKey>(new HiveKey("hi".getBytes()), 3));
    try {
      partitioner.configure(new JobConf(conf));
      NullWritable nw = NullWritable.get();
      for (Check<HiveKey> chk : revCheck) {
        assertEquals(chk.data.toString(), chk.part,
            partitioner.getPartition(chk.data, nw, splitStrings.length + 1));
      }
    } finally {
      p.getFileSystem(conf).delete(p, true);
    }
  }
Compare the buffers in serialized form.
ql/src/test/org/apache/hadoop/hive/ql/exec/tez/TestTezTotalOrderPartitioner.java