@Override public StoreChannel create( File fileName ) throws IOException { return delegate.create( fileName ); }
@Override public StoreChannel create( File fileName ) throws IOException { return fs.create( fileName ); }
@Override public StoreChannel create( File fileName ) throws IOException { return chooseFileSystem( fileName ).create( fileName ); }
private void storeFileContent( File file, ByteBuffer sourceBuffer ) throws IOException { try ( StoreChannel storeChannel = fileSystem.create( file ) ) { storeChannel.writeAll( sourceBuffer ); } } }
private File badDataFile( FileSystemAbstraction fileSystem, File badDataPath ) throws IOException { fileSystem.mkdir( badDataPath.getParentFile() ); fileSystem.create( badDataPath ); return badDataPath; }
private void writeInitialDataTo( File file ) throws IOException { try ( StoreChannel channel = fs.create( file ) ) { ByteBuffer buf = ByteBuffer.allocate( 16 ); buf.putLong( x ); buf.putLong( y ); buf.flip(); channel.writeAll( buf ); } }
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(); } }
protected void ensureExists( File file ) throws IOException { fs.mkdirs( file.getParentFile() ); fs.create( file ).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; }
@Override public StoreChannel create( File fileName ) throws IOException { adversary.injectFailure( FileNotFoundException.class, IOException.class, SecurityException.class ); return AdversarialFileChannel.wrap( (StoreFileChannel) delegate.create( fileName ), adversary ); }
@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(); }
@Before public void before() throws IOException { fs = fsr.get(); pageCache = pageCacheRule.getPageCache( fsr.get() ); try ( StoreChannel channel = fs.create( storeFile ) ) { ByteBuffer buffer = ByteBuffer.allocate( 4 ); buffer.putInt( BLOCK_SIZE ); buffer.flip(); channel.write( buffer ); } }
@Test void shouldCreatePathThatPointsToFile() throws Exception { fsa.mkdirs( path ); assertTrue( fsa.fileExists( path ) ); path = new File( path, "some_file" ); try ( StoreChannel channel = fsa.create( path ) ) { assertThat( channel, is( not( nullValue() ) ) ); fsa.mkdirs( path ); assertTrue( fsa.fileExists( path ) ); } }
@Test public void shouldOverwriteInitialPasswordFileIfExists() throws Throwable { // Given fileSystem.mkdirs( authInitFile.getParentFile() ); fileSystem.create( authInitFile ); // When String[] arguments = {"123"}; setPasswordCommand.execute( arguments ); // Then assertAuthIniFile( "123" ); }
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 ) ); }
@Test public void shouldHandleStoreConsistingOfOneEmptyFile() throws Exception { StoreFactory storeFactory = storeFactory( Config.defaults() ); FileSystemAbstraction fs = fsRule.get(); fs.create( testDirectory.databaseLayout().file( "neostore.nodestore.db.labels" ) ); storeFactory.openAllNeoStores( true ).close(); }
@ParameterizedTest @ValueSource( ints = {0, 1} ) void swappingInMustFillPageWithData( int noChannelStriping ) throws Exception { byte[] bytes = new byte[] { 1, 2, 3, 4 }; StoreChannel channel = getFs().create( getFile() ); channel.writeAll( wrap( bytes ) ); channel.close(); PageSwapperFactory factory = createSwapperFactory(); PageSwapper swapper = createSwapper( factory, getFile(), 4, null, false, bool( noChannelStriping ) ); long target = createPage( 4 ); swapper.read( 0, target, sizeOfAsInt( target ) ); assertThat( array( target ), byteArray( bytes ) ); }