use of org.apache.derby.impl.io.vfmem.VirtualFile in project derby by apache.
the class VirtualFileTest method testRenameToSimple.
public void testRenameToSimple() {
DataStore store = getStore();
VirtualFile vFile = new VirtualFile("originalFile", store);
assertFalse(vFile.canWrite());
vFile.createNewFile();
assertTrue(vFile.canWrite());
VirtualFile newFile = new VirtualFile("newFile", store);
assertFalse(newFile.exists());
assertTrue(vFile.renameTo(newFile));
assertFalse(vFile.exists());
assertFalse(vFile.canWrite());
assertTrue(newFile.exists());
}
use of org.apache.derby.impl.io.vfmem.VirtualFile in project derby by apache.
the class VirtualFileTest method testGetParentRelative.
public void testGetParentRelative() {
DataStore store = getStore();
VirtualFile vFile = new VirtualFile(PathUtilTest.join(NON_EXISTING_DIRS), store);
int count = 0;
StorageFile parent = vFile.getParentDir();
while (parent != null) {
count++;
parent = parent.getParentDir();
}
assertEquals(4, count);
}
use of org.apache.derby.impl.io.vfmem.VirtualFile in project derby by apache.
the class VirtualFileTest method testCreateDirInRoot.
public void testCreateDirInRoot() {
DataStore store = getStore();
VirtualFile vFile = new VirtualFile("seg0", store);
assertFalse(vFile.exists());
vFile.mkdir();
assertTrue(vFile.exists());
assertTrue(vFile.isDirectory());
}
use of org.apache.derby.impl.io.vfmem.VirtualFile in project derby by apache.
the class VirtualFileTest method testListChilderen.
/**
* Tests that {@code listChildren} doesn't include too many entries.
*/
public void testListChilderen() {
DataStore store = getStore();
VirtualFile dir1 = new VirtualFile(PathUtilTest.abs("mydir"), store);
VirtualFile dir2 = new VirtualFile(PathUtilTest.abs("mydirectory"), store);
VirtualFile file1 = new VirtualFile(PathUtilTest.joinAbs("mydir", "file1.txt"), store);
VirtualFile file2 = new VirtualFile(PathUtilTest.joinAbs("mydirectory", "file2.txt"), store);
assertTrue(dir1.mkdirs());
assertTrue(dir1.exists());
assertTrue(dir1.isDirectory());
assertTrue(dir2.mkdirs());
assertTrue(dir2.exists());
assertTrue(dir2.isDirectory());
assertTrue(file1.createNewFile());
assertTrue(file1.exists());
assertFalse(file1.isDirectory());
assertTrue(file2.createNewFile());
assertTrue(file2.exists());
assertFalse(file2.isDirectory());
// We should only get one child; file1.txt
String[] children = dir1.list();
assertEquals(1, children.length);
assertEquals(file1.getName(), children[0]);
// Test that the same path ending with the separator results in the
// same list being returned.
VirtualFile dir1abs = new VirtualFile(PathUtilTest.joinAbs("mydir", ""), store);
assertFalse(dir1.getName().equals(dir1abs.getName()));
String[] childrenAbs = dir1abs.list();
assertEquals(1, childrenAbs.length);
assertEquals(children[0], childrenAbs[0]);
// The deleteAll below shouldn't delete "mydirectory" and "file2.txt"..
assertFalse(dir1.delete());
assertTrue(dir1.deleteAll());
assertTrue(dir2.exists());
assertTrue(file2.exists());
}
Aggregations