Package org.apache.derby.impl.io.vfmem

Examples of org.apache.derby.impl.io.vfmem.VirtualFile


     * Opening for reading only should work, opening for writing should fail.
     */
    public void testGetRAExistingReadOnly()
            throws FileNotFoundException {
        DataStore store = getStore();
        VirtualFile vFile = new VirtualFile("aNewFile.txt", store);
        assertFalse(vFile.exists());
        assertTrue(vFile.createNewFile());
        assertTrue(vFile.exists());
        assertTrue(vFile.setReadOnly());
        assertNotNull(vFile.getRandomAccessFile("r"));
        // Try opening in write mode, which should fail.
        try {
            vFile.getRandomAccessFile("rw");
            fail("Should not be able to open a read-only file in write mode");
        } catch (FileNotFoundException fnfe) {
            // Expected.
        }
    }
View Full Code Here


    /**
     * Opening a random access file on a directory should fail.
     */
    public void testGetRAFOnDirectory() {
        DataStore store = getStore();
        VirtualFile vFile = new VirtualFile("mydir", store);
        assertTrue(vFile.mkdir());
        assertTrue(vFile.exists());
        assertTrue(vFile.isDirectory());
        // Try opening in read mode.
        try {
            vFile.getRandomAccessFile("r");
            fail("Opening a RAF on a directory should have failed");
        } catch (FileNotFoundException fnfe) {
            // Expected.
        }
        // Try opening in write mode.
        try {
            vFile.getRandomAccessFile("r");
            fail("Opening a RAF on a directory should have failed");
        } catch (FileNotFoundException fnfe) {
            // Expected.
        }
        // A few sanity checks.
        assertTrue(vFile.exists());
        assertTrue(vFile.isDirectory());
    }
View Full Code Here

    /**
     * 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());
View Full Code Here

    public void testCreateRoot() {
        DataStore store = new DataStore("testCreateRootStore");
        String path = PathUtilTest.joinAbs("these", "are", "directories");
        assertTrue(store.createAllParents(path));
        assertNotNull(store.createEntry(path, true));
        VirtualFile vf = new VirtualFile(path, store);
        assertTrue(vf.exists());
        assertTrue(vf.isDirectory());

        // Also test one Windows specific root.
        path = PathUtilTest.join("c:", "Documents and Settings", "directories");
        assertTrue(store.createAllParents(path));
        assertNotNull(store.createEntry(path, true));
        vf = new VirtualFile(path, store);
        assertTrue(vf.exists());
        assertTrue(vf.isDirectory());
    }
View Full Code Here

     * Verify that the close() method of VirtualRandomAccessFile can be
     * called more than once.
     */
    public void testCloseIdempotent() throws IOException {
        DataStore store = getStore();
        VirtualFile f = new VirtualFile("afile", store);
        StorageRandomAccessFile raf = f.getRandomAccessFile("rw");
        raf.close();
        // The second close() used to throw NullPointerException (DERBY-5960)
        raf.close();
    }
View Full Code Here

        super(name);
    }

    public void testCreateFileInRoot() {
        DataStore store = getStore();
        VirtualFile vFile = new VirtualFile("service.properties", store);
        assertFalse(new VirtualFile("service.properties", store).exists());
        assertFalse(vFile.exists());
    }
View Full Code Here

        assertFalse(vFile.exists());
    }

    public void testCreateDirInRoot() {
        DataStore store = getStore();
        VirtualFile vFile = new VirtualFile("seg0", store);
        assertFalse(vFile.exists());
        vFile.mkdir();
        assertTrue(vFile.exists());
        assertTrue(vFile.isDirectory());
    }
View Full Code Here

        assertTrue(vFile.isDirectory());
    }

    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());
    }
View Full Code Here

        assertFalse("Dir creation should have failed", vFile.mkdir());
    }

    public void testMkdirsValidRelative() {
        DataStore store = getStore();
        VirtualFile vFile = new VirtualFile(
                PathUtilTest.join(NON_EXISTING_DIRS),
                store);
        assertTrue(vFile.mkdirs());
    }
View Full Code Here

        assertTrue(vFile.mkdirs());
    }

    public void testMkdirsValidAbsolute() {
        DataStore store = getStore();
        VirtualFile vFile = new VirtualFile(
                PathUtilTest.joinAbs(NON_EXISTING_DIRS),
                store);
        assertTrue(vFile.mkdirs());
    }
View Full Code Here

TOP

Related Classes of org.apache.derby.impl.io.vfmem.VirtualFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.