WrappingHttpOutputMessage implements HttpOutputMessage, AutoCloseable { @Override public void close() throws IOException { if (stream != null) { stream.close(); } }  @Nonnull @Override OutputStream getBody(); @Nonnull @Override HttpHeaders getHeaders(); @Override void close();  }
@Test void shouldNotCloseStreamIfNeverAccessed() throws IOException { final OutputStream wrappedStream = mock(OutputStream.class); when(wrapper.apply(any())).thenReturn(wrappedStream); unit.close(); verifyNoInteractions(wrappedStream); }