@Test
public void testFailToFlush() throws IOException {

  // Create a file at destination
  FileOutputStream fos = new FileOutputStream(DST_FILE);
  fos.write(TEST_STRING_2.getBytes());
  fos.close();
  
  OutputStream failingStream = createFailingStream();
  failingStream.write(TEST_STRING.getBytes());
  try {
    failingStream.close();
    fail("Close didn't throw exception");
  } catch (IOException ioe) {
    // expected
  }
  
  // Should not have touched original file
  assertEquals(TEST_STRING_2, DFSTestUtil.readFile(DST_FILE));
  
  assertEquals("Temporary file should have been cleaned up",
      DST_FILE.getName(), Joiner.on(",").join(TEST_DIR.list()));
}