List of usage examples for org.apache.commons.vfs2.impl DefaultFileSystemManager DefaultFileSystemManager
DefaultFileSystemManager
From source file:org.pentaho.hadoop.shim.HadoopConfigurationLocatorTest.java
@Test(expected = ConfigurationException.class) public void findHadoopConfigurations_errorLoadingHadoopConfig() throws Exception { FileObject root = VFS.getManager().resolveFile(HADOOP_CONFIGURATIONS_PATH); HadoopConfigurationLocator locator = new HadoopConfigurationLocator() { protected HadoopConfiguration loadHadoopConfiguration(FileObject folder) throws ConfigurationException { throw new ConfigurationException("test"); }/*from www. j av a 2 s . c o m*/ }; locator.init(root, new MockActiveHadoopConfigurationLocator("a"), new DefaultFileSystemManager()); }
From source file:org.pentaho.hadoop.shim.mapr.HadoopShimTest.java
@Test public void onLoad() throws Exception { HadoopConfigurationProvider configProvider = new HadoopConfigurationProvider() { @Override//from w w w . j a va 2s .c om public boolean hasConfiguration(String id) { throw new UnsupportedOperationException(); } @Override public List<? extends HadoopConfiguration> getConfigurations() { throw new UnsupportedOperationException(); } @Override public HadoopConfiguration getConfiguration(String id) throws ConfigurationException { throw new UnsupportedOperationException(); } @Override public HadoopConfiguration getActiveConfiguration() throws ConfigurationException { throw new UnsupportedOperationException(); } }; DefaultFileSystemManager delegate = new DefaultFileSystemManager(); HadoopConfigurationFileSystemManager fsm = new HadoopConfigurationFileSystemManager(configProvider, delegate); assertFalse(fsm.hasProvider("hdfs")); HadoopShim shim = new HadoopShim(); HadoopConfiguration config = new HadoopConfiguration(VFS.getManager().resolveFile("ram:///"), "id", "name", shim, null, null, null); shim.onLoad(config, fsm); assertNotNull(shim.getDistributedCacheUtil()); }
From source file:org.renjin.appengine.AppEngineContextFactory.java
@VisibleForTesting static FileSystemManager createFileSystemManager(LocalFileProvider localFileProvider) throws FileSystemException { try {//w ww.j a v a 2s. co m FastJarFileProvider jarFileProvider = new FastJarFileProvider(); // this provides a fake local file system rooted in the servlet context root. // this is necessary because on the actual appengine platform, any queries to the ancestors // of the servlet context (e.g. /base) will throw a security exception DefaultFileSystemManager dfsm = new DefaultFileSystemManager(); dfsm.addProvider("jar", jarFileProvider); dfsm.addProvider("file", localFileProvider); dfsm.addExtensionMap("jar", "jar"); dfsm.setDefaultProvider(new UrlFileProvider()); dfsm.setFilesCache(new NullFilesCache()); dfsm.setCacheStrategy(CacheStrategy.ON_RESOLVE); dfsm.setBaseFile(new File("/")); dfsm.init(); return dfsm; } catch (FileSystemException e) { LOG.log(Level.SEVERE, "Failed to initialize file system for development server", e); throw new RuntimeException(e); } }
From source file:org.renjin.util.FileSystemUtils.java
public static FileSystemManager getMinimalFileSystemManager() throws FileSystemException { DefaultFileSystemManager fsm = new DefaultFileSystemManager(); fsm.setDefaultProvider(new UrlFileProvider()); fsm.addProvider("file", new DefaultLocalFileProvider()); fsm.addProvider("jar", new FastJarFileProvider()); fsm.init();//from w ww. j a v a2 s . c o m return fsm; }
From source file:tain.kr.test.vfs.v01.TestVfs2FilehandleService.java
@Test public void testCaching() throws Exception { String path = TestVfs2FilehandleService.class.getResource("").getPath(); if (flag)/*from w ww. j a va 2 s. co m*/ System.out.printf("[%s]\n", path); String testFolder = path + "/testfolder"; FileSystemManager manager = VFS.getManager(); FileObject scratchFolder = manager.resolveFile(testFolder); // testfolder scratchFolder.delete(Selectors.EXCLUDE_SELF); FileObject file = manager.resolveFile(path + "/testfolder/dummy.txt"); file.createFile(); // Manager DefaultFileSystemManager fs = new DefaultFileSystemManager(); fs.setFilesCache(manager.getFilesCache()); // zip, jar, tgz, tar, tbz2, file if (!fs.hasProvider("file")) { fs.addProvider("file", new DefaultLocalFileProvider()); } fs.setCacheStrategy(CacheStrategy.ON_RESOLVE); fs.init(); // FileObject foBase2 = fs.resolveFile(testFolder); if (flag) System.out.printf("## scratchFolder.getName().getPath() : %s\n", scratchFolder.getName().getPath()); FileObject cachedFolder = foBase2.resolveFile(scratchFolder.getName().getPath()); // FileObject[] fos = cachedFolder.getChildren(); assertFalse(contains(fos, "file1.txt")); // scratchFolder.resolveFile("file1.txt").createFile(); // // BUT cachedFolder fos = cachedFolder.getChildren(); assertFalse(contains(fos, "file1.txt")); // cachedFolder.refresh(); // fos = cachedFolder.getChildren(); assertTrue(contains(fos, "file1.txt")); }