IOUtils { public static void close(@Nullable Closeable stream) { try { if (stream != null) stream.close(); } catch (Exception e) { } } private  IOUtils(); static void close(@Nullable Closeable stream);  }
@Test public void testHandlesNull() throws Exception { IOUtils.close(null); }
@Test public void testClosesStream() throws Exception { InputStream is = Mockito.mock(InputStream.class); IOUtils.close(is); Mockito.verify(is, Mockito.times(1)).close(); }
@Test public void testClosesThrowsError() throws Exception { InputStream is = Mockito.mock(InputStream.class); Mockito.doThrow(new IOException("throwing for test")).when(is).close(); IOUtils.close(is); Mockito.verify(is, Mockito.times(1)).close(); }