Package org.apache.commons.vfs2.impl

Examples of org.apache.commons.vfs2.impl.FileContentInfoFilenameFactory


        final Capability[] caps = getRequiredCaps();
        if (caps != null)
        {
            for (int i = 0; i < caps.length; i++)
            {
                final Capability cap = caps[i];
                FileSystem fs = readFolder.getFileSystem();
                if (!fs.hasCapability(cap))
                {
//                    String name = fs.getClass().getName();
//                    int index = name.lastIndexOf('.');
View Full Code Here


        // Get file content as a binary stream
        final byte[] expectedBin = expected.getBytes("utf-8");

        // Check lengths
        final FileContent content = file.getContent();
        assertEquals("same content length", expectedBin.length, content.getSize());

        // Read content into byte array
        final InputStream instr = content.getInputStream();
        final ByteArrayOutputStream outstr;
        try
        {
            outstr = new ByteArrayOutputStream(expectedBin.length);
            final byte[] buffer = new byte[256];
View Full Code Here

     * Tests the root file name.
     */
    public void testRootFileName() throws Exception
    {
        // Locate the root file
        final FileName rootName = getReadFolder().getFileSystem().getRoot().getName();

        // Test that the root path is "/"
        assertEquals("root path", "/", rootName.getPath());

        // Test that the root basname is ""
        assertEquals("root base name", "", rootName.getBaseName());

        // Test that the root name has no parent
        assertNull("root parent", rootName.getParent());
    }
View Full Code Here

    /**
     * Tests child file names.
     */
    public void testChildName() throws Exception
    {
        final FileName baseName = getReadFolder().getName();
        final String basePath = baseName.getPath();
        final FileName name = getManager().resolveName(baseName, "some-child", NameScope.CHILD);

        // Test path is absolute
        assertTrue("is absolute", basePath.startsWith("/"));

        // Test base name
        assertEquals("base name", "some-child", name.getBaseName());

        // Test absolute path
        assertEquals("absolute path", basePath + "/some-child", name.getPath());

        // Test parent path
        assertEquals("parent absolute path", basePath, name.getParent().getPath());

        // Try using a compound name to find a child
        assertBadName(name, "a/b", NameScope.CHILD);

        // Check other invalid names
View Full Code Here

    {
        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

                                final String relName,
                                final NameScope scope)
        throws Exception
    {
        // Try the supplied name
        FileName name = getManager().resolveName(baseName, relName, scope);
        assertEquals(expectedPath, name.getPath());

        String temp;

        // Replace the separators
        temp = relName.replace('\\', '/');
        name = getManager().resolveName(baseName, temp, scope);
        assertEquals(expectedPath, name.getPath());

        // And again
        temp = relName.replace('/', '\\');
        name = getManager().resolveName(baseName, temp, scope);
        assertEquals(expectedPath, name.getPath());
    }
View Full Code Here

    /**
     * Tests relative name resolution, relative to the base folder.
     */
    public void testNameResolution() throws Exception
    {
        final FileName baseName = getReadFolder().getName();
        final String parentPath = baseName.getParent().getPath();
        final String path = baseName.getPath();
        final String childPath = path + "/some-child";

        // Test empty relative path
        assertSameName(path, baseName, "");

View Full Code Here

     * Tests descendent name resolution.
     */
    public void testDescendentName()
        throws Exception
    {
        final FileName baseName = getReadFolder().getName();

        // Test direct child
        String path = baseName.getPath() + "/some-child";
        assertSameName(path, baseName, "some-child", NameScope.DESCENDENT);

        // Test compound name
        path = path + "/grand-child";
        assertSameName(path, baseName, "some-child/grand-child", NameScope.DESCENDENT);
View Full Code Here

     * Tests resolution of absolute names.
     */
    public void testAbsoluteNames() throws Exception
    {
        // Test against the base folder
        FileName name = getReadFolder().getName();
        checkAbsoluteNames(name);

        // Test against the root
        name = getReadFolder().getFileSystem().getRoot().getName();
        checkAbsoluteNames(name);
View Full Code Here

    /**
     * Tests conversion from absolute to relative names.
     */
    public void testAbsoluteNameConvert() throws Exception
    {
        final FileName baseName = getReadFolder().getName();

        String path = "/test1/test2";
        FileName name = getManager().resolveName(baseName, path);
        assertEquals(path, name.getPath());

        // Try child and descendent names
        testRelName(name, "child");
        testRelName(name, "child1/child2");

        // Try own name
        testRelName(name, ".");

        // Try parent, and root
        testRelName(name, "..");
        testRelName(name, "../..");

        // Try sibling and descendent of sibling
        testRelName(name, "../sibling");
        testRelName(name, "../sibling/child");

        // Try siblings with similar names
        testRelName(name, "../test2_not");
        testRelName(name, "../test2_not/child");
        testRelName(name, "../test");
        testRelName(name, "../test/child");

        // Try unrelated
        testRelName(name, "../../unrelated");
        testRelName(name, "../../test");
        testRelName(name, "../../test/child");

        // Test against root
        path = "/";
        name = getManager().resolveName(baseName, path);
        assertEquals(path, name.getPath());

        // Try child and descendent names (against root)
        testRelName(name, "child");
        testRelName(name, "child1/child2");

View Full Code Here

TOP

Related Classes of org.apache.commons.vfs2.impl.FileContentInfoFilenameFactory

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.