Java Code Examples for org.apache.commons.vfs2.impl.DefaultFileReplicator

The following examples show how to use org.apache.commons.vfs2.impl.DefaultFileReplicator. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spoofax   Source File:    License: Apache License 2.0 6 votes vote down vote up
@Override public FileSystemManager get() {
    try {
        final DefaultFileSystemManager manager = new DefaultFileSystemManager();

        manager.setFilesCache(new DefaultFilesCache());

        final String baseTmpDir = System.getProperty("");
        final File tempDir = new File(baseTmpDir, "vfs_cache" + new Random().nextLong()).getAbsoluteFile();
        final DefaultFileReplicator replicator = new DefaultFileReplicator(tempDir);



        return manager;
    } catch(FileSystemException e) {
        throw new RuntimeException("Cannot initialize resource service: " + e.getMessage(), e);
Example 2
Source Project: commons-vfs   Source File:    License: Apache License 2.0 4 votes vote down vote up
protected void setUp() throws Exception {
    startThreadSnapshot = createThreadSnapshot();

    // Locate the temp directory, and clean it up
    tempDir = AbstractVfsTestCase.getTestDirectory("temp");
    checkTempDir("Temp dir not empty before test");

    // Create the file system manager
    manager = providerConfig.getDefaultFileSystemManager();

    final DefaultFileReplicator replicator = new DefaultFileReplicator(tempDir);
    manager.setReplicator(new PrivilegedFileReplicator(replicator));


    if (!manager.hasProvider("file")) {
        manager.addProvider("file", new DefaultLocalFileProvider());


    // Locate the base folders
    baseFolder = providerConfig.getBaseTestFolder(manager);
    readFolder = baseFolder.resolveFile("read-tests");
    writeFolder = baseFolder.resolveFile("write-tests");

    // Make some assumptions about the read folder
    Assert.assertTrue("Folder does not exist: " + readFolder, readFolder.exists());
    Assert.assertNotEquals(readFolder.getName().getPath(), FileName.ROOT_PATH);

    // Configure the tests
    final Enumeration<Test> tests = testSuite.tests();
    if (!tests.hasMoreElements()) {"No tests.");
    while (tests.hasMoreElements()) {
        final Test test = tests.nextElement();
        if (test instanceof AbstractProviderTestCase) {
            final AbstractProviderTestCase providerTestCase = (AbstractProviderTestCase) test;
            providerTestCase.setConfig(manager, providerConfig, baseFolder, readFolder, writeFolder);