@Test
public void testDoGetShouldCloseTheDFSInputStreamIfResponseGetOutPutStreamThrowsAnyException()
    throws Exception {

  MiniDFSCluster cluster = new MiniDFSCluster(CONF, 1, true, null);
  try {
    Path testFile = createFile();
    setUpForDoGetTest(cluster, testFile);
    Mockito.doThrow(new IOException()).when(mockHttpServletResponse)
        .getOutputStream();
    DFSInputStream fsMock = Mockito.mock(DFSInputStream.class);
    Mockito.doReturn(fsMock).when(clientMock).open(testFile.toString());
    Mockito.doReturn(Long.valueOf(4)).when(fsMock).getFileLength();
    try {
      sfile.doGet(mockHttpServletRequest, mockHttpServletResponse);
      fail("Not throwing the IOException");
    } catch (IOException e) {
      Mockito.verify(clientMock, Mockito.atLeastOnce()).close();
    }
  } finally {
    cluster.shutdown();
  }
}