UnsyncFilterOutputStream extends OutputStream { @Override public void flush() throws IOException { outputStream.flush(); } UnsyncFilterOutputStream(OutputStream outputStream); @Override void close(); @Override void flush(); @Override void write(byte[] bytes); @Override void write(byte[] bytes, int offset, int length); @Override void write(int b);  }
@Test public void testFlush() throws IOException { AtomicBoolean flushCalled = new AtomicBoolean(); UnsyncFilterOutputStream unsyncFilterOutputStream = new UnsyncFilterOutputStream( new TestOutputStream() { @Override public void flush() { flushCalled.set(true); } }); unsyncFilterOutputStream.flush(); Assert.assertTrue(flushCalled.get()); }