use of org.apache.derby.impl.io.vfmem.VirtualFile in project derby by apache.
the class VirtualFileTest method testGetRAFNonExisting.
/**
* Getting a random access file in write mode for a non-existing file
* should cause the file to be created.
*/
public void testGetRAFNonExisting() throws FileNotFoundException {
DataStore store = getStore();
VirtualFile vFile = new VirtualFile("aNewFile.txt", store);
assertFalse(vFile.exists());
StorageRandomAccessFile vRAF = vFile.getRandomAccessFile("rw");
assertNotNull(vRAF);
assertTrue(vFile.exists());
}
use of org.apache.derby.impl.io.vfmem.VirtualFile in project derby by apache.
the class VirtualFileTest method testGetParentAbsolute.
public void testGetParentAbsolute() {
DataStore store = getStore();
VirtualFile vFile = new VirtualFile(PathUtilTest.joinAbs(NON_EXISTING_DIRS), store);
int count = 0;
StorageFile parent = vFile.getParentDir();
while (parent != null) {
count++;
parent = parent.getParentDir();
}
assertEquals(5, count);
}
use of org.apache.derby.impl.io.vfmem.VirtualFile in project derby by apache.
the class VirtualFileTest method testCreateInvalidDir.
public void testCreateInvalidDir() {
DataStore store = getStore();
VirtualFile vFile = new VirtualFile(PathUtilTest.join(NON_EXISTING_DIRS), store);
assertFalse(vFile.exists());
VirtualFile tmp = new VirtualFile("", store);
assertTrue(tmp.mkdir());
assertFalse("Dir creation should have failed", vFile.mkdir());
}
use of org.apache.derby.impl.io.vfmem.VirtualFile in project derby by apache.
the class VirtualFileTest method testMkdirsValidRelative.
public void testMkdirsValidRelative() {
DataStore store = getStore();
VirtualFile vFile = new VirtualFile(PathUtilTest.join(NON_EXISTING_DIRS), store);
assertTrue(vFile.mkdirs());
}
use of org.apache.derby.impl.io.vfmem.VirtualFile in project derby by apache.
the class VirtualFileTest method testGetRAFNonExistingReadMode.
/**
* Getting a random access file in read mode for a non-existing file
* should fail, and the file shouldn't be created.
*/
public void testGetRAFNonExistingReadMode() throws FileNotFoundException {
DataStore store = getStore();
VirtualFile vFile = new VirtualFile("aNewFile.txt", store);
assertFalse(vFile.exists());
try {
vFile.getRandomAccessFile("r");
fail("Cannot read from a non-exsiting file");
} catch (FileNotFoundException fnfe) {
// Expected.
}
assertFalse(vFile.exists());
}
Aggregations