Package org.apache.commons.vfs2.provider

Examples of org.apache.commons.vfs2.provider.HostFileNameParser$Authority


        assertEquals(names.size(), files.length);

        // Check for unexpected names
        for (int i = 0; i < files.length; i++)
        {
            FileObject file = files[i];
            assertTrue(names.contains(file.getName().getBaseName()));
        }
    }
View Full Code Here


    public static void main(String[] args) throws FileSystemException
    {
        FileSystemManager mgr = VFS.getManager();

        FileObject root = mgr
                .resolveFile("smb://HOME\\vfsusr:vfs%2f%25\\te:st@10.0.1.54/vfsusr");
        FileName rootName = root.getName();

        testNames(mgr, rootName);

        testChildren(root);
View Full Code Here

    /**
     * Sets up a scratch folder for the test to use.
     */
    protected FileObject createScratchFolder() throws Exception
    {
        FileObject scratchFolder = getWriteFolder();

        // Make sure the test folder is empty
        scratchFolder.delete(Selectors.EXCLUDE_SELF);
        scratchFolder.createFolder();

        final FileObject dir1 = scratchFolder.resolveFile("dir1");
        dir1.createFolder();
        final FileObject dir1file1 = dir1.resolveFile("a.txt");
        dir1file1.createFile();
        final FileObject dir2 = scratchFolder.resolveFile("dir2");
        dir2.createFolder();
        final FileObject dir2file1 = dir2.resolveFile("b.txt");
        dir2file1.createFile();

        return scratchFolder;
    }
View Full Code Here

    /**
     * deletes the complete structure
     */
    public void testDeleteFiles() throws Exception
    {
        final FileObject scratchFolder = createScratchFolder();

        assertEquals(scratchFolder.delete(Selectors.EXCLUDE_SELF), 4);
    }
View Full Code Here

    /**
     * deletes a single file
     */
    public void testDeleteFile() throws Exception
    {
        final FileObject scratchFolder = createScratchFolder();

        final FileObject file = scratchFolder.resolveFile("dir1/a.txt");

        assertTrue(file.delete());
    }
View Full Code Here

    /**
     * Deletes a non existent file
     */
    public void testDeleteNonExistantFile() throws Exception
    {
        final FileObject scratchFolder = createScratchFolder();

        final FileObject file = scratchFolder.resolveFile("dir1/aa.txt");

        assertFalse(file.delete());
    }
View Full Code Here

    /**
     * deletes files
     */
    public void testDeleteAllFiles() throws Exception
    {
        final FileObject scratchFolder = createScratchFolder();

        assertEquals(scratchFolder.delete(new FileTypeSelector(FileType.FILE)), 2);
    }
View Full Code Here

    /**
     * deletes a.txt
     */
    public void testDeleteOneFiles() throws Exception
    {
        final FileObject scratchFolder = createScratchFolder();

        assertEquals(scratchFolder.delete(new FileNameSelector("a.txt")), 1);
    }
View Full Code Here

    {
        // Build base dir
        getManager().setBaseFile(getReadFolder());

        // Locate the base dir
        FileObject file = getManager().resolveFile(".");
        assertSame("file object", getReadFolder(), file);

        // Locate a child
        file = getManager().resolveFile("some-child");
        assertSame("file object", getReadFolder(), file.getParent());

        // Locate a descendent
        file = getManager().resolveFile("some-folder/some-file");
        assertSame("file object", getReadFolder(), file.getParent().getParent());

        // Locate parent
        file = getManager().resolveFile("..");
        assertSame("file object", getReadFolder().getParent(), file);
View Full Code Here

        // Build base dir
        getManager().setBaseFile(getReadFolder());
        final String path = getReadFolder().getName().getPath();

        // §1 Encode "some file"
        FileObject file = getManager().resolveFile("%73%6f%6d%65%20%66%69%6c%65");
        assertEquals(path + "/some file", file.getName().getPathDecoded());

        // §2 Encode "."
        file = getManager().resolveFile("%2e");
        // 18-6-2005 imario@apache.org: no need to keep the "current directory"
        // assertEquals(path + "/.", file.getName().getPathDecoded());
        assertEquals(path, file.getName().getPathDecoded());

        // §3 Encode '%'
        file = getManager().resolveFile("a%25");
        assertEquals(path + "/a%", file.getName().getPathDecoded());

        // §4 Encode /
        file = getManager().resolveFile("dir%2fchild");
        assertEquals(path + "/dir/child", file.getName().getPathDecoded());

        // §5 Encode \
        file = getManager().resolveFile("dir%5cchild");
        // 18-6-2005 imario@apache.org: all file separators normalized to "/"
        // decided to do this to get the same behaviour as in §4 on windows
        // platforms
        // assertEquals(path + "/dir\\child", file.getName().getPathDecoded());
        assertEquals(path + "/dir/child", file.getName().getPathDecoded());

        // §6 Use "%" literal
        try
        {
            getManager().resolveFile("%");
View Full Code Here

TOP

Related Classes of org.apache.commons.vfs2.provider.HostFileNameParser$Authority

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.