@Test
public void testComputePacketChunkSize()
    throws Exception {

  DistributedFileSystem fs = cluster.getFileSystem();
  FSDataOutputStream os = fs.create(new Path("/test"));
  DFSOutputStream dos = (DFSOutputStream) Whitebox.getInternalState(os,
      "wrappedStream");
  final int packetSize = 64*1024;
  final int bytesPerChecksum = 512;
  Method method = dos.getClass().getDeclaredMethod("computePacketChunkSize",
      int.class, int.class);
  method.setAccessible(true);
  method.invoke(dos, packetSize, bytesPerChecksum);
  Field field = dos.getClass().getDeclaredField("packetSize");
  field.setAccessible(true);
  Assert.assertTrue((Integer) field.get(dos) + 33 < packetSize);
  // If PKT_MAX_HEADER_LEN is 257, actual packet size come to over 64KB
  // without a fix on HDFS-7308.
  Assert.assertTrue((Integer) field.get(dos) + 257 < packetSize);
}