@Test(timeout = 60000)
public void testDFSAdminUnreachableDatanode() throws Exception {

  redirectStream();
  final DFSAdmin dfsAdmin = new DFSAdmin(conf);
  for (String command : new String[]{"-getDatanodeInfo",
      "-evictWriters", "-getBalancerBandwidth"}) {
    // Connecting to Xfer port instead of IPC port will get
    // Datanode unreachable. java.io.EOFException
    final String dnDataAddr = datanode.getXferAddress().getHostString() + ":"
        + datanode.getXferPort();
    resetStream();
    final List<String> outs = Lists.newArrayList();
    final int ret = ToolRunner.run(dfsAdmin,
        new String[]{command, dnDataAddr});
    assertEquals(-1, ret);
    scanIntoList(out, outs);
    assertTrue("Unexpected " + command + " stdout: " + out, outs.isEmpty());
    assertTrue("Unexpected " + command + " stderr: " + err,
        err.toString().contains("Exception"));
  }
}