org.apache.commons.vfs2.impl.DefaultFileReplicator Java Examples
The following examples show how to use
org.apache.commons.vfs2.impl.DefaultFileReplicator.
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 File: DefaultFileSystemManagerProvider.java From spoofax with Apache License 2.0 | 6 votes |
@Override public FileSystemManager get() { try { final DefaultFileSystemManager manager = new DefaultFileSystemManager(); manager.setFilesCache(new DefaultFilesCache()); manager.setCacheStrategy(CacheStrategy.ON_RESOLVE); final String baseTmpDir = System.getProperty("java.io.tmpdir"); final File tempDir = new File(baseTmpDir, "vfs_cache" + new Random().nextLong()).getAbsoluteFile(); final DefaultFileReplicator replicator = new DefaultFileReplicator(tempDir); manager.setTemporaryFileStore(replicator); manager.setReplicator(replicator); addDefaultProvider(manager); addProviders(manager); setBaseFile(manager); manager.init(); return manager; } catch(FileSystemException e) { throw new RuntimeException("Cannot initialize resource service: " + e.getMessage(), e); } }
Example #2
Source File: AbstractTestSuite.java From commons-vfs with Apache License 2.0 | 4 votes |
@Override protected void setUp() throws Exception { startThreadSnapshot = createThreadSnapshot(); // Locate the temp directory, and clean it up tempDir = AbstractVfsTestCase.getTestDirectory("temp"); FileUtils.cleanDirectory(tempDir); checkTempDir("Temp dir not empty before test"); // Create the file system manager manager = providerConfig.getDefaultFileSystemManager(); manager.setFilesCache(providerConfig.getFilesCache()); final DefaultFileReplicator replicator = new DefaultFileReplicator(tempDir); manager.setReplicator(new PrivilegedFileReplicator(replicator)); manager.setTemporaryFileStore(replicator); providerConfig.prepare(manager); if (!manager.hasProvider("file")) { manager.addProvider("file", new DefaultLocalFileProvider()); } manager.init(); // 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()) { Assert.fail("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); } } }