Example usage for org.apache.commons.vfs2 VFS getManager

List of usage examples for org.apache.commons.vfs2 VFS getManager

Introduction

In this page you can find the example usage for org.apache.commons.vfs2 VFS getManager.

Prototype

public static synchronized FileSystemManager getManager() throws FileSystemException 

Source Link

Document

Returns the default FileSystemManager instance.

Usage

From source file:org.pentaho.hadoop.shim.HadoopConfigurationLocatorTest.java

@Test
public void getActiveConfiguration() throws Exception {
    HadoopConfigurationLocator locator = new HadoopConfigurationLocator();
    locator.init(VFS.getManager().resolveFile(HADOOP_CONFIGURATIONS_PATH),
            new MockActiveHadoopConfigurationLocator("a"), new DefaultFileSystemManager());

    HadoopConfiguration a = locator.getActiveConfiguration();
    assertNotNull(a);/*from w w w .j ava 2 s  .co  m*/
}

From source file:org.pentaho.hadoop.shim.HadoopConfigurationLocatorTest.java

@Test(expected = ConfigurationException.class)
public void createConfigurationLoader_root_not_a_folder() throws Exception {
    HadoopConfigurationLocator locator = new HadoopConfigurationLocator();
    // Try to create a configuration based on a file, not a folder
    FileObject buildProperties = VFS.getManager().resolveFile("ram:///test.file");
    buildProperties.createFile();/*from   w  ww . j  ava 2 s .co  m*/
    assertEquals(FileType.FILE, buildProperties.getType());
    locator.createConfigurationLoader(buildProperties, null, null, new ShimProperties());
}

From source file:org.pentaho.hadoop.shim.HadoopConfigurationLocatorTest.java

@Test
public void loadHadoopConfiguration_with_ignore_classes() throws Exception {
    HadoopConfigurationLocator locator = new HadoopConfigurationLocator();

    FileObject root = VFS.getManager().resolveFile(HADOOP_CONFIGURATIONS_PATH + "/a");
    HadoopConfiguration configuration = locator.loadHadoopConfiguration(root);

    assertNotNull(configuration);//from w w w.j  a v a2 s  .co  m
}

From source file:org.pentaho.hadoop.shim.HadoopConfigurationLocatorTest.java

@Test
public void createConfigurationLoader() throws Exception {
    HadoopConfigurationLocator locator = new HadoopConfigurationLocator();

    FileObject root = VFS.getManager().resolveFile(HADOOP_CONFIGURATIONS_PATH + "/a");
    ClassLoader cl = locator.createConfigurationLoader(root, getClass().getClassLoader(), null,
            new ShimProperties());

    assertNotNull(cl.getResource("config.properties"));
}

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  a v  a  2  s. c  om
    };
    locator.init(root, new MockActiveHadoopConfigurationLocator("a"), new DefaultFileSystemManager());
}

From source file:org.pentaho.hadoop.shim.HadoopConfigurationLocatorTest.java

@Test
public void parseURLs() throws Exception {
    HadoopConfigurationLocator locator = new HadoopConfigurationLocator();
    FileObject root = VFS.getManager().resolveFile(HADOOP_CONFIGURATIONS_PATH);

    List<URL> urls = locator.parseURLs(root, "a,b");
    assertEquals(2, urls.size());/*w  ww  .j a v a  2 s .c  om*/
    assertEquals(root.getURL().toURI().resolve("hadoop-configurations/a/"), urls.get(0).toURI());
    assertEquals(root.getURL().toURI().resolve("hadoop-configurations/a/a-config.jar"), urls.get(1).toURI());
}

From source file:org.pentaho.hadoop.shim.HadoopConfigurationTest.java

@Test(expected = NullPointerException.class)
public void instantiation_null_id() throws Exception {
    new HadoopConfiguration(VFS.getManager().resolveFile("ram:///"), null, "name", new MockHadoopShim());
}

From source file:org.pentaho.hadoop.shim.HadoopConfigurationTest.java

@Test(expected = NullPointerException.class)
public void instantiation_null_name() throws Exception {
    new HadoopConfiguration(VFS.getManager().resolveFile("ram:///"), "id", null, new MockHadoopShim());
}

From source file:org.pentaho.hadoop.shim.HadoopConfigurationTest.java

@Test(expected = NullPointerException.class)
public void instantiation_null_hadoop_shim() throws Exception {
    new HadoopConfiguration(VFS.getManager().resolveFile("ram:///"), "id", "name", null);
}

From source file:org.pentaho.hadoop.shim.HadoopConfigurationTest.java

@Test
public void getLocation() throws Exception {
    FileObject location = VFS.getManager().resolveFile("ram:///");
    HadoopConfiguration c = new HadoopConfiguration(location, "id", "name", new MockHadoopShim());
    assertEquals(location, c.getLocation());
}