use of jetbrains.exodus.env.Transaction in project xodus by JetBrains.
the class VfsStreamsTests method writeOverwriteRead2.
@Test
public void writeOverwriteRead2() throws IOException {
final Transaction txn = env.beginTransaction();
final File file0 = vfs.createFile(txn, "file0");
OutputStream outputStream = vfs.appendFile(txn, file0);
outputStream.write((HOEGAARDEN + HOEGAARDEN + HOEGAARDEN + HOEGAARDEN).getBytes(UTF_8));
outputStream.close();
txn.flush();
outputStream = vfs.writeFile(txn, file0);
outputStream.write("x".getBytes(UTF_8));
outputStream.write(HOEGAARDEN.substring(1).getBytes(UTF_8));
outputStream.write("x".getBytes(UTF_8));
outputStream.write(HOEGAARDEN.substring(1).getBytes(UTF_8));
outputStream.write("x".getBytes(UTF_8));
outputStream.write(HOEGAARDEN.substring(1).getBytes(UTF_8));
outputStream.write("x".getBytes(UTF_8));
outputStream.write(HOEGAARDEN.substring(1).getBytes(UTF_8));
outputStream.close();
txn.flush();
final InputStream inputStream = vfs.readFile(txn, file0);
Assert.assertEquals('x' + HOEGAARDEN.substring(1) + 'x' + HOEGAARDEN.substring(1) + 'x' + HOEGAARDEN.substring(1) + 'x' + HOEGAARDEN.substring(1), streamAsString(inputStream));
inputStream.close();
txn.abort();
}
use of jetbrains.exodus.env.Transaction in project xodus by JetBrains.
the class VfsStreamsTests method writeRead3.
@Test
public void writeRead3() throws IOException {
final Transaction txn = env.beginTransaction();
final File file0 = vfs.createFile(txn, "file0");
final OutputStream outputStream = vfs.writeFile(txn, file0);
outputStream.write(0);
outputStream.close();
final InputStream inputStream = vfs.readFile(txn, file0);
Assert.assertEquals(0, inputStream.read());
inputStream.close();
txn.commit();
}
use of jetbrains.exodus.env.Transaction in project xodus by JetBrains.
the class VfsStreamsTests method testWriteReadWithStrategy.
private void testWriteReadWithStrategy(@NotNull final ClusteringStrategy strategy) throws IOException {
vfs.shutdown();
final VfsConfig config = new VfsConfig();
config.setClusteringStrategy(strategy);
vfs = new VirtualFileSystem(getEnvironment(), config);
final Transaction txn = env.beginTransaction();
final byte[] bytes = RENAT_GILFANOV.getBytes(UTF_8);
final File file0 = vfs.createFile(txn, "file0");
final OutputStream outputStream0 = vfs.appendFile(txn, file0);
outputStream0.write(bytes);
outputStream0.close();
final File file1 = vfs.createFile(txn, "file1");
final OutputStream outputStream1 = vfs.appendFile(txn, file1);
outputStream1.write(bytes);
outputStream1.close();
final InputStream inputStream0 = vfs.readFile(txn, file0);
Assert.assertEquals(RENAT_GILFANOV, streamAsString(inputStream0));
inputStream0.close();
final InputStream inputStream1 = vfs.readFile(txn, file1);
Assert.assertEquals(RENAT_GILFANOV, streamAsString(inputStream1));
inputStream1.close();
Assert.assertEquals((long) bytes.length, vfs.getFileLength(txn, file0));
Assert.assertEquals((long) bytes.length, vfs.getFileLength(txn, file1));
txn.commit();
}
Aggregations