IOTools { public void close(@Nullable final Closeable closeable) { if (closeable == null) { return; } try { closeable.close(); } catch (final IOException e) { LOG.log(Level.WARNING, "Close failed", e); } }  void flush(@Nullable final Flushable flushable); void close(@Nullable final Closeable closeable); void createFolder(final String folder);  }
@Test public void closeShouldHandleNull() { ioTools.close(null); }
@Test public void closeShouldClose() throws IOException { final Closeable closeable = mock(Closeable.class); ioTools.close(closeable); verify(closeable).close(); }
@Test public void closeShouldIgnoreExceptions() throws IOException { final Closeable closeable = mock(Closeable.class); doThrow(new IOException("Throw on close")).when(closeable).close(); ioTools.close(closeable); verify(closeable).close(); }