use of jetbrains.exodus.env.Transaction in project xodus by JetBrains.
the class VfsFileTests method testRenameFile.
@Test
public void testRenameFile() throws InterruptedException {
testFileCreation();
final Transaction txn = env.beginTransaction();
File file0 = vfs.openFile(txn, "file0", false);
txn.revert();
Assert.assertNotNull(file0);
final long fd = file0.getDescriptor();
final long created = file0.getCreated();
final long lastModified = file0.getLastModified();
Thread.sleep(50);
vfs.renameFile(txn, file0, "file1");
txn.flush();
file0 = vfs.openFile(txn, "file0", false);
File file1 = vfs.openFile(txn, "file1", false);
txn.abort();
Assert.assertNull(file0);
Assert.assertNotNull(file1);
Assert.assertEquals(fd, file1.getDescriptor());
Assert.assertEquals(created, file1.getCreated());
Assert.assertTrue(file1.getLastModified() > lastModified);
}
use of jetbrains.exodus.env.Transaction in project xodus by JetBrains.
the class VfsFileTests method testDeleteFile4.
@Test
public void testDeleteFile4() throws IOException {
final Transaction txn = env.beginTransaction();
for (int i = 0; i < 50; ++i) {
final File file0 = vfs.createFile(txn, "file0");
final OutputStream outputStream = vfs.writeFile(txn, file0);
for (int j = 0; j < i; ++j) {
outputStream.write(new byte[vfs.getConfig().getClusteringStrategy().getFirstClusterSize()]);
}
outputStream.write("vain bytes to be deleted".getBytes());
for (int j = 0; j < i + 1; ++j) {
outputStream.write(new byte[vfs.getConfig().getClusteringStrategy().getFirstClusterSize()]);
}
outputStream.close();
txn.flush();
Assert.assertNotNull(vfs.deleteFile(txn, "file0"));
txn.flush();
}
Assert.assertEquals(0L, vfs.getContents().count(txn));
txn.commit();
}
use of jetbrains.exodus.env.Transaction in project xodus by JetBrains.
the class VfsFileTests method testDeleteFile2.
@Test
public void testDeleteFile2() {
Transaction txn = env.beginTransaction();
vfs.createFile(txn, "file0");
txn.flush();
vfs.deleteFile(txn, "file0");
txn.flush();
Assert.assertNull(vfs.openFile(txn, "file0", false));
final File file0 = vfs.openFile(txn, "file0", true);
txn.commit();
Assert.assertNotNull(file0);
Assert.assertEquals("file0", file0.getPath());
}
use of jetbrains.exodus.env.Transaction in project xodus by JetBrains.
the class VfsFileTests method testOpenFile.
@Test
public void testOpenFile() {
testFileCreation();
final Transaction txn = env.beginTransaction();
final File file0 = vfs.openFile(txn, "file0", false);
txn.commit();
Assert.assertNotNull(file0);
Assert.assertEquals(0L, file0.getDescriptor());
Assert.assertTrue(file0.getCreated() > 0);
Assert.assertTrue(file0.getLastModified() > 0);
}
use of jetbrains.exodus.env.Transaction in project xodus by JetBrains.
the class VfsFileTests method testDeleteFile.
@Test
public void testDeleteFile() {
Transaction txn = env.beginTransaction();
vfs.createFile(txn, "file0");
txn.commit();
txn = env.beginTransaction();
final File file0 = vfs.deleteFile(txn, "file0");
txn.commit();
Assert.assertNotNull(file0);
Assert.assertEquals("file0", file0.getPath());
}
Aggregations