Search in sources :

Example 6 with DataStore

use of org.apache.derby.impl.io.vfmem.DataStore 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());
}
Also used : VirtualFile(org.apache.derby.impl.io.vfmem.VirtualFile) StorageRandomAccessFile(org.apache.derby.io.StorageRandomAccessFile) DataStore(org.apache.derby.impl.io.vfmem.DataStore)

Example 7 with DataStore

use of org.apache.derby.impl.io.vfmem.DataStore 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);
}
Also used : VirtualFile(org.apache.derby.impl.io.vfmem.VirtualFile) DataStore(org.apache.derby.impl.io.vfmem.DataStore) StorageFile(org.apache.derby.io.StorageFile)

Example 8 with DataStore

use of org.apache.derby.impl.io.vfmem.DataStore 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());
}
Also used : VirtualFile(org.apache.derby.impl.io.vfmem.VirtualFile) DataStore(org.apache.derby.impl.io.vfmem.DataStore)

Example 9 with DataStore

use of org.apache.derby.impl.io.vfmem.DataStore in project derby by apache.

the class VirtualFileTest method getStore.

/**
 * Utility method returning a fresh data store.
 */
private static synchronized DataStore getStore() {
    DataStore store = new DataStore("testVFMemDB-" + dbStoreIndex++);
    // We need the root to exist.
    assertNotNull(store.createEntry(java.io.File.separator, true));
    return store;
}
Also used : DataStore(org.apache.derby.impl.io.vfmem.DataStore)

Example 10 with DataStore

use of org.apache.derby.impl.io.vfmem.DataStore 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());
}
Also used : VirtualFile(org.apache.derby.impl.io.vfmem.VirtualFile) DataStore(org.apache.derby.impl.io.vfmem.DataStore)

Aggregations

DataStore (org.apache.derby.impl.io.vfmem.DataStore)21 VirtualFile (org.apache.derby.impl.io.vfmem.VirtualFile)19 FileNotFoundException (java.io.FileNotFoundException)3 StorageFile (org.apache.derby.io.StorageFile)3 StorageRandomAccessFile (org.apache.derby.io.StorageRandomAccessFile)2 File (java.io.File)1