Search in sources :

Example 31 with DefaultFileSystemManager

use of org.apache.commons.vfs2.impl.DefaultFileSystemManager in project commons-vfs by apache.

the class Vfs444TestCase method prepare.

/**
 * Prepares the file system manager. This implementation does nothing.
 */
@Override
public void prepare(final DefaultFileSystemManager manager) throws Exception {
    manager.addProvider("res", new ResourceFileProvider());
    manager.addProvider("zip", new ZipFileProvider());
}
Also used : ZipFileProvider(org.apache.commons.vfs2.provider.zip.ZipFileProvider)

Example 32 with DefaultFileSystemManager

use of org.apache.commons.vfs2.impl.DefaultFileSystemManager in project commons-vfs by apache.

the class WindowsFileNameTests method testWindowsFilenameUNCStartError.

@Test
public void testWindowsFilenameUNCStartError() {
    try {
        final String FILE = "file://///";
        final DefaultFileSystemManager manager = getManager();
        Assertions.assertNotNull(manager, "Unexpected null manager for test " + this);
        final FileObject fo = manager.resolveFile(FILE);
        fail("Windows File Parser should not allow " + FILE + " " + fo);
    } catch (FileSystemException ex) {
        assertEquals("Exception code", "vfs.provider/invalid-absolute-uri.error", ex.getCode());
        ex = (FileSystemException) ex.getCause();
        assertEquals("Exception code", "vfs.provider.local/missing-share-name.error", ex.getCode());
    }
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) DefaultFileSystemManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager) FileObject(org.apache.commons.vfs2.FileObject) Test(org.junit.Test)

Example 33 with DefaultFileSystemManager

use of org.apache.commons.vfs2.impl.DefaultFileSystemManager in project commons-vfs by apache.

the class WindowsFileNameTests method testWindowsWrongRoots.

@Test
public void testWindowsWrongRoots() {
    final String[] tests = { "file:///C:", "file://C:", "file:/C:", "file:C:" };
    for (final String name : tests) {
        try {
            final DefaultFileSystemManager manager = getManager();
            Assertions.assertNotNull(manager, "Unexpected null manager for test " + this);
            final FileName fn = manager.resolveFile(name).getName();
            fail("should not accept root " + name);
        } catch (final FileSystemException ex) {
            assertEquals("vfs.provider/invalid-absolute-uri.error", ex.getCode());
            assertTrue(ex.toString().indexOf(name) >= 0);
        }
    }
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) FileName(org.apache.commons.vfs2.FileName) DefaultFileSystemManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager) Test(org.junit.Test)

Example 34 with DefaultFileSystemManager

use of org.apache.commons.vfs2.impl.DefaultFileSystemManager in project commons-vfs by apache.

the class WindowsFileNameTests method testWindowsFilenameParserError.

@Test
public void testWindowsFilenameParserError() {
    // check VFS-338 with 2+4 slashes we want a dedicated error
    try {
        final String FILE = "file://////";
        final DefaultFileSystemManager manager = getManager();
        Assertions.assertNotNull(manager, "Unexpected null manager for test " + this);
        final FileObject fo = manager.resolveFile(FILE);
        fail("Windows File Parser should not allow " + FILE + " " + fo);
    } catch (FileSystemException ex) {
        assertEquals("Exception code", "vfs.provider/invalid-absolute-uri.error", ex.getCode());
        ex = (FileSystemException) ex.getCause();
        assertEquals("Exception code", "vfs.provider.local/not-absolute-file-name.error", ex.getCode());
    }
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) DefaultFileSystemManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager) FileObject(org.apache.commons.vfs2.FileObject) Test(org.junit.Test)

Example 35 with DefaultFileSystemManager

use of org.apache.commons.vfs2.impl.DefaultFileSystemManager in project commons-vfs by apache.

the class CustomRamProviderTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    manager = new DefaultFileSystemManager();
    manager.addProvider("ram", new RamFileProvider());
    manager.init();
    // File Systems Options
    RamFileSystemConfigBuilder.getInstance().setMaxSize(zeroSizedFso, 0L);
    RamFileSystemConfigBuilder.getInstance().setMaxSize(smallSizedFso, 10L);
}
Also used : DefaultFileSystemManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

DefaultFileSystemManager (org.apache.commons.vfs2.impl.DefaultFileSystemManager)45 File (java.io.File)13 FileSystemException (org.apache.commons.vfs2.FileSystemException)13 Test (org.junit.Test)13 FileSystemManager (org.apache.commons.vfs2.FileSystemManager)10 FileObject (org.apache.commons.vfs2.FileObject)9 IOException (java.io.IOException)6 DefaultLocalFileProvider (org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider)5 Before (org.junit.Before)5 AmazonS3 (com.amazonaws.services.s3.AmazonS3)4 ArrayList (java.util.ArrayList)4 FilesCache (org.apache.commons.vfs2.FilesCache)4 SoftRefFilesCache (org.apache.commons.vfs2.cache.SoftRefFilesCache)4 StandardFileSystemManager (org.apache.commons.vfs2.impl.StandardFileSystemManager)4 VfsComponentContext (org.apache.commons.vfs2.provider.VfsComponentContext)4 RepositoryException (javax.jcr.RepositoryException)3 FileName (org.apache.commons.vfs2.FileName)3 FileSystemOptions (org.apache.commons.vfs2.FileSystemOptions)3 DefaultFileReplicator (org.apache.commons.vfs2.impl.DefaultFileReplicator)3 FileContentInfoFilenameFactory (org.apache.commons.vfs2.impl.FileContentInfoFilenameFactory)3