@Override public void close() throws IOException { inner.close(); }
@Override public void close() throws IOException { delegate.close(); } }
@Override public void close() throws IOException { delegateChannel.close(); }
private void releaseChannel() throws IOException { storeLockFileChannel.close(); storeLockFileChannel = null; }
private long readAndValidateHeader() throws IOException { try { return readAndValidate( fileChannel, file ); } catch ( InvalidIdGeneratorException e ) { fileChannel.close(); throw e; } }
@Override public void close() throws IOException { channel.close(); } }
private void closeChannel() throws IOException { fileChannel.force( false ); fileChannel.close(); fileChannel = null; closed = true; }
@Override public void close() throws IOException { delegate.close(); }
@Override public void close() throws IOException { adversary.injectFailure( IOException.class ); delegate.close(); }
private boolean isFailed( File failureFile ) throws IOException { try ( StoreChannel channel = fs.open( failureFile, OpenMode.READ ) ) { byte[] data = new byte[(int) channel.size()]; channel.readAll( ByteBuffer.wrap( data ) ); channel.close(); return !allZero( data ); } }
private void writeIntegerIntoFile( File targetFile ) throws IOException { StoreChannel storeChannel = fsa.create( targetFile ); ByteBuffer byteBuffer = ByteBuffer.allocate( Integer.SIZE ).putInt( 7 ); byteBuffer.flip(); storeChannel.writeAll( byteBuffer ); storeChannel.close(); } }
private void ensureExists( File file ) throws IOException { fsa.mkdirs( file.getParentFile() ); fsa.create( file ).close(); }
private File existingFile( String fileName ) throws IOException { File file = new File( path, fileName ); fsa.mkdirs( path ); fsa.create( file ).close(); return file; }
@Test void close() throws Exception { channel.close(); verify( actual ).close(); } }
@Test public void fs_openClose() throws IOException { chan( true ).close(); }
@Before public void createWorkingDirectoryAndTestFile() throws IOException { Thread.interrupted(); fs.mkdirs( testdir.directory() ); file = testdir.file( "a" ); fs.create( file ).close(); channel = null; channelShouldBeClosed = false; Thread.currentThread().interrupt(); }
private File createMetaDataFile() throws IOException { File file = testDirectory.databaseLayout().metadataStore(); fs.create( file ).close(); return file; }
private File emptyFile( FileSystemAbstraction fs ) throws IOException { File shortFile = directory.file( "empty" ); fs.deleteFile( shortFile ); fs.create( shortFile ).close(); return shortFile; }
@Test void lastPageIdOfFileWithOneByteIsZero() throws IOException { StoreChannel channel = fs.create( file( "a" ) ); channel.write( ByteBuffer.wrap( new byte[]{1} ) ); channel.close(); configureStandardPageCache(); try ( PagedFile pagedFile = map( file( "a" ), filePageSize ) ) { assertThat( pagedFile.getLastPageId(), is( 0L ) ); } }
@Test void deleteRecursivelyMustDeleteGivenFile() throws Exception { fsa.mkdirs( path ); File file = new File( path, "file" ); fsa.create( file ).close(); fsa.deleteRecursively( file ); assertFalse( fsa.fileExists( file ) ); }