public static void testCommandSerialization(Command cmd) {
    String serializedCmd = null;
    try {
      serializedCmd = ReplicationUtils.serializeCommand(cmd);
    } catch (IOException e) {
      LOG.error("Serialization error",e);
      assertNull(e); // error out.
    }

    Command cmd2 = null;
    try {
      cmd2 = ReplicationUtils.deserializeCommand(serializedCmd);
    } catch (IOException e) {
      LOG.error("Serialization error",e);
      assertNull(e); // error out.
    }

    assertEquals(cmd.getClass(),cmd2.getClass());
    assertEquals(cmd.getEventId(), cmd2.getEventId());
    assertEquals(cmd.get(), cmd2.get());
    assertEquals(cmd.isUndoable(),cmd2.isUndoable());
    if (cmd.isUndoable()){
      assertEquals(cmd.getUndo(),cmd2.getUndo());
    }
    assertEquals(cmd.isRetriable(),cmd2.isRetriable());
  }
Class which provides several useful methods to test commands, but is itself not a test.
hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/repl/CommandTestUtils.java