### Question:
RetriableFileCopyCommand extends RetriableCommand { @VisibleForTesting long copyBytes(FileStatus sourceFileStatus, OutputStream outStream, int bufferSize, Mapper.Context context) throws IOException { Path source = sourceFileStatus.getPath(); byte buf[] = new byte[bufferSize]; ThrottledInputStream inStream = null; long totalBytesRead = 0; try { inStream = getInputStream(source, context.getConfiguration()); int bytesRead = readBytes(inStream, buf); while (bytesRead >= 0) { totalBytesRead += bytesRead; outStream.write(buf, 0, bytesRead); updateContextStatus(totalBytesRead, context, sourceFileStatus); bytesRead = inStream.read(buf); } outStream.close(); outStream = null; } finally { IOUtils.cleanup(LOG, outStream, inStream); } return totalBytesRead; } RetriableFileCopyCommand(String description);  RetriableFileCopyCommand(boolean skipCrc, String description);   }### Answer:
@SuppressWarnings("rawtypes") @Test public void testFailOnCloseError() throws Exception { Mapper.Context context = mock(Mapper.Context.class); doReturn(new Configuration()).when(context).getConfiguration(); Exception expectedEx = new IOException("boom"); OutputStream out = mock(OutputStream.class); doThrow(expectedEx).when(out).close(); File f = File.createTempFile(this.getClass().getSimpleName(), null); f.deleteOnExit(); FileStatus stat = new FileStatus(1L, false, 1, 1024, 0, new Path(f.toURI())); Exception actualEx = null; try { new RetriableFileCopyCommand("testFailOnCloseError") .copyBytes(stat, out, 512, context); } catch (Exception e) { actualEx = e; } assertNotNull("close didn't fail", actualEx); assertEquals(expectedEx, actualEx); }