@Test public void testFlush() throws IOException { RefCountedBufferingFileStream stream = getStreamToTest(); final byte[] contentToWrite = bytesOf("hello"); stream.write(contentToWrite); Assert.assertEquals(contentToWrite.length, stream.getPositionInBuffer()); Assert.assertEquals(contentToWrite.length, stream.getPos()); stream.flush(); Assert.assertEquals(0, stream.getPositionInBuffer()); Assert.assertEquals(contentToWrite.length, stream.getPos()); final byte[] contentRead = new byte[contentToWrite.length]; new FileInputStream(stream.getInputFile()).read(contentRead, 0, contentRead.length); Assert.assertTrue(Arrays.equals(contentToWrite, contentRead)); stream.release(); }
@Override public void flush() throws IOException { currentTmpFile.write(buffer, 0, positionInBuffer); currentTmpFile.flush(); positionInBuffer = 0; }
RefCountedBufferingFileStream extends RefCountedFSOutputStream { @Override public void flush() throws IOException { currentTmpFile.write(buffer, 0, positionInBuffer); currentTmpFile.flush(); positionInBuffer = 0; } }
RefCountedBufferingFileStream extends RefCountedFSOutputStream { @Override public void flush() throws IOException { currentTmpFile.write(buffer, 0, positionInBuffer); currentTmpFile.flush(); positionInBuffer = 0; } @VisibleForTesting  RefCountedBufferingFileStream(
			final RefCountedFile file,
			final int bufferSize); }
RefCountedBufferingFileStream extends RefCountedFSOutputStream { @Override public void flush() throws IOException { currentTmpFile.write(buffer, 0, positionInBuffer); currentTmpFile.flush(); positionInBuffer = 0; } @VisibleForTesting  RefCountedBufferingFileStream(
			final RefCountedFile file,
			final int bufferSize); @Override File getInputFile(); @Override long getPos(); @Override void write(int b); @Override void write(byte[] b, int off, int len); @Override void flush(); @Override void sync(); @Override boolean isClosed(); @Override void close(); @Override void retain(); @Override boolean release(); @Override String toString(); @VisibleForTesting int getReferenceCounter(); static RefCountedBufferingFileStream openNew(
			final FunctionWithException<File, RefCountedFile, IOException> tmpFileProvider); static RefCountedBufferingFileStream restore(
			final FunctionWithException<File, RefCountedFile, IOException> tmpFileProvider,
			final File initialTmpFile); }
RefCountedBufferingFileStream extends RefCountedFSOutputStream { @Override public void flush() throws IOException { currentTmpFile.write(buffer, 0, positionInBuffer); currentTmpFile.flush(); positionInBuffer = 0; } @VisibleForTesting  RefCountedBufferingFileStream(
			final RefCountedFile file,
			final int bufferSize); @Override File getInputFile(); @Override long getPos(); @Override void write(int b); @Override void write(byte[] b, int off, int len); @Override void flush(); @Override void sync(); @Override boolean isClosed(); @Override void close(); @Override void retain(); @Override boolean release(); @Override String toString(); @VisibleForTesting int getReferenceCounter(); static RefCountedBufferingFileStream openNew(
			final FunctionWithException<File, RefCountedFile, IOException> tmpFileProvider); static RefCountedBufferingFileStream restore(
			final FunctionWithException<File, RefCountedFile, IOException> tmpFileProvider,
			final File initialTmpFile); static final int BUFFER_SIZE; }