Example usage for org.apache.commons.vfs FileObject getName

List of usage examples for org.apache.commons.vfs FileObject getName

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileObject getName.

Prototype

public FileName getName();

Source Link

Document

Returns the name of this file.

Usage

From source file:unitTests.dataspaces.VFSFileObjectAdapterTest.java

@Before
public void setUp() throws IOException, MalformedURIException {

    testDir = new File(System.getProperty("java.io.tmpdir"), "ProActive-VFSFileObjectAdapterTest");
    final File differentDir = new File(testDir, "different");
    final File rootDir = new File(testDir, "root space");
    final File aoDir = new File(rootDir, "ao1");
    final File someDir = new File(aoDir, "dir");
    final File someFile = new File(someDir, "file.txt");
    assertTrue(someDir.mkdirs());//  w w w  .j  a  v  a 2s  . c om
    assertTrue(differentDir.mkdir());
    assertTrue(someFile.createNewFile());

    rootDirPath = rootDir.getCanonicalPath();
    rootFileUri = rootDir.toURI().toURL().toExternalForm();
    differentDirPath = differentDir.getCanonicalPath();

    final FileObject rootFileObject = fileSystemManager.resolveFile(rootFileUri);
    if (server == null) {
        server = new FileSystemServerDeployer(rootDirPath, false);
    }
    vfsServerUrl = server.getVFSRootURL();

    final FileName mountintPointFileName = rootFileObject.getName();
    adaptee = rootFileObject.resolveFile(fileURI.getRelativeToSpace());

    rootUris = new ArrayList<String>();
    rootUris.add(rootFileUri);
    rootUris.add(vfsServerUrl);

    dsFileObject = new VFSFileObjectAdapter(adaptee, spaceURI, mountintPointFileName, rootUris, rootFileUri);
}

From source file:unitTests.dataspaces.VFSFileObjectAdapterTest.java

@Test
public void testGetURI1()
        throws org.apache.commons.vfs.FileSystemException, MalformedURIException, FileSystemException {
    final FileObject rootFileObject = fileSystemManager.resolveFile(rootFileUri);
    final FileName mountintPointFileName = rootFileObject.getName();
    final FileObject rootAdaptee = rootFileObject;
    final DataSpacesFileObject fo = new VFSFileObjectAdapter(rootAdaptee, spaceURI, mountintPointFileName,
            rootUris, rootFileUri);/*from  www.java2s . c  o m*/

    assertEquals(spaceURI.toString(), fo.getVirtualURI());
}

From source file:unitTests.dataspaces.VFSFileObjectAdapterTest.java

@Test(expected = FileSystemException.class)
public void testGetParentOnFilesystemRoot()
        throws org.apache.commons.vfs.FileSystemException, FileSystemException, MalformedURLException {
    FileObject rootFileObject;
    if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
        rootFileObject = fileSystemManager.resolveFile(new File("c:\\").toURI().toURL().toString());
    } else {//from ww w  .java2s .c  o  m
        rootFileObject = fileSystemManager.resolveFile(new File("/").toURI().toURL().toString());
    }
    final FileName mountintPointFileName = rootFileObject.getName();
    final FileObject rootAdaptee = rootFileObject;
    ArrayList<String> fos = new ArrayList<String>();
    fos.add("file:///");
    final DataSpacesFileObject fo = new VFSFileObjectAdapter(rootAdaptee, spaceURI, mountintPointFileName, fos,
            "file:///");
    fo.getParent();
}

From source file:unitTests.dataspaces.VFSSpacesMountManagerImplTest.java

@Test
public void testEnsureExistingOrSwitch() throws Exception {
    String wrongpath = createWrongFileUri();

    ArrayList<String> rootUrisWithWrongFileUri = new ArrayList<String>();
    rootUrisWithWrongFileUri.add(wrongpath);
    rootUrisWithWrongFileUri.add(serverOutput.getVFSRootURL());

    VFSSpacesMountManagerImpl manager2 = createManagerForEnsureExistingTest(wrongpath);

    FileObject fileObjectWithWrongFileUri = fileSystemManager.resolveFile(wrongpath);

    // create Adapter
    DataSpacesFileObject dsFileObjectWithWrongFileUri = new VFSFileObjectAdapter(fileObjectWithWrongFileUri,
            outputUri, fileObjectWithWrongFileUri.getName(), rootUrisWithWrongFileUri, wrongpath, manager2);

    // switch to existing
    DataSpacesFileObject newfo = dsFileObjectWithWrongFileUri.ensureExistingOrSwitch();
    assertEquals(serverOutput.getVFSRootURL(), newfo.getSpaceRootURI());
}