use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class NeoStoresRule method open.
public NeoStores open(RecordFormats format, String... config) throws IOException {
efs = new EphemeralFileSystemAbstraction();
Config conf = Config.embeddedDefaults(stringMap(config));
pageCache = getOrCreatePageCache(conf, efs);
return open(efs, pageCache, format, config);
}
use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class BatchInsertersTest method providedFileSystemNotClosedAfterShutdown.
@Test
public void providedFileSystemNotClosedAfterShutdown() throws IOException {
EphemeralFileSystemAbstraction fs = fileSystemRule.get();
vefiryProvidedFileSystemOpenAfterShutdown(inserter(getStoreDir(), fs), fs);
vefiryProvidedFileSystemOpenAfterShutdown(inserter(getStoreDir(), fs, getConfig()), fs);
vefiryProvidedFileSystemOpenAfterShutdown(inserter(getStoreDir(), fs, getConfig(), getKernelExtensions()), fs);
}
use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class TestEphemeralFileChannel method smoke.
@Test
public void smoke() throws Exception {
EphemeralFileSystemAbstraction fs = fileSystemRule.get();
StoreChannel channel = fs.open(new File("yo"), "rw");
// Clear it because we depend on it to be zeros where we haven't written
ByteBuffer buffer = allocateDirect(23);
// zeros
buffer.put(new byte[23]);
buffer.flip();
channel.write(buffer);
channel = fs.open(new File("yo"), "rw");
long longValue = 1234567890L;
// [1].....[2]........[1234567890L]...
buffer.clear();
buffer.limit(1);
buffer.put((byte) 1);
buffer.flip();
channel.write(buffer);
buffer.clear();
buffer.limit(1);
buffer.put((byte) 2);
buffer.flip();
channel.position(6);
channel.write(buffer);
buffer.clear();
buffer.limit(8);
buffer.putLong(longValue);
buffer.flip();
channel.position(15);
channel.write(buffer);
assertEquals(23, channel.size());
// Read with position
// byte 0
buffer.clear();
buffer.limit(1);
channel.read(buffer, 0);
buffer.flip();
assertEquals((byte) 1, buffer.get());
// bytes 5-7
buffer.clear();
buffer.limit(3);
channel.read(buffer, 5);
buffer.flip();
assertEquals((byte) 0, buffer.get());
assertEquals((byte) 2, buffer.get());
assertEquals((byte) 0, buffer.get());
// bytes 15-23
buffer.clear();
buffer.limit(8);
channel.read(buffer, 15);
buffer.flip();
assertEquals(longValue, buffer.getLong());
fs.close();
}
use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class TestEphemeralFileChannel method listFiles.
@Test
public void listFiles() throws Exception {
/* GIVEN
* root
* / \
* ----------- dir1 dir2
* / / | \
* subdir1 file file2 file
* |
* file
*/
EphemeralFileSystemAbstraction fs = fileSystemRule.get();
File root = new File("/root").getCanonicalFile();
File dir1 = new File(root, "dir1");
File dir2 = new File(root, "dir2");
File subdir1 = new File(dir1, "sub");
File file1 = new File(dir1, "file");
File file2 = new File(dir1, "file2");
File file3 = new File(dir2, "file");
File file4 = new File(subdir1, "file");
fs.mkdirs(dir2);
fs.mkdirs(dir1);
fs.mkdirs(subdir1);
fs.create(file1);
fs.create(file2);
fs.create(file3);
fs.create(file4);
// THEN
assertEquals(asSet(dir1, dir2), asSet(fs.listFiles(root)));
assertEquals(asSet(subdir1, file1, file2), asSet(fs.listFiles(dir1)));
assertEquals(asSet(file3), asSet(fs.listFiles(dir2)));
assertEquals(asSet(file4), asSet(fs.listFiles(subdir1)));
fs.close();
}
use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class TestGraphProperties method produceUncleanStore.
private EphemeralFileSystemAbstraction produceUncleanStore(EphemeralFileSystemAbstraction fileSystem, File storeDir) {
GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem(fileSystem).newImpermanentDatabase(storeDir);
Transaction tx = db.beginTx();
Node node = db.createNode();
node.setProperty("name", "Something");
properties((GraphDatabaseAPI) db).setProperty("prop", "Some value");
tx.success();
tx.close();
EphemeralFileSystemAbstraction snapshot = fileSystem.snapshot();
db.shutdown();
return snapshot;
}
Aggregations