Example usage for org.apache.commons.vfs2.impl DefaultFileSystemManager DefaultFileSystemManager

List of usage examples for org.apache.commons.vfs2.impl DefaultFileSystemManager DefaultFileSystemManager

Introduction

In this page you can find the example usage for org.apache.commons.vfs2.impl DefaultFileSystemManager DefaultFileSystemManager.

Prototype

DefaultFileSystemManager

Source Link

Usage

From source file:org.pentaho.hadoop.shim.common.HadoopShimTest.java

@Test
public void onLoad() throws Exception {
    HadoopConfigurationProvider configProvider = new HadoopConfigurationProvider() {
        @Override/*ww w .jav a  2  s.c o  m*/
        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 HadoopShimImpl();
    CommonHadoopShim shimSpy = (CommonHadoopShim) spy(shim);
    HadoopConfiguration config = new HadoopConfiguration(VFS.getManager().resolveFile("ram:///"), "id", "name",
            shim, null, null, null);

    shimSpy.onLoad(config, fsm);

    verify(shimSpy, atLeast(1)).validateHadoopHomeWithWinutils();
    assertNotNull(shimSpy.getDistributedCacheUtil());
}

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

@Test(expected = ConfigurationException.class)
public void init_invalidDirectory() throws FileSystemException, ConfigurationException {
    HadoopConfigurationLocator locator = new HadoopConfigurationLocator();
    locator.init(VFS.getManager().resolveFile("ram://bogus-path"), new MockActiveHadoopConfigurationLocator(),
            new DefaultFileSystemManager());
}

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

@Test(expected = NullPointerException.class)
public void init_null_basedir() throws FileSystemException, ConfigurationException {
    HadoopConfigurationLocator locator = new HadoopConfigurationLocator();
    locator.init(null, new MockActiveHadoopConfigurationLocator(), new DefaultFileSystemManager());
}

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

@Test(expected = NullPointerException.class)
public void init_null_activeLocator() throws FileSystemException, ConfigurationException {
    HadoopConfigurationLocator locator = new HadoopConfigurationLocator();
    locator.init(VFS.getManager().resolveFile(HADOOP_CONFIGURATIONS_PATH), null,
            new DefaultFileSystemManager());
}

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

@Test
public void init_MissingRequiredClasses() throws IOException {
    Properties properties = new Properties();
    InputStream inputStream = configFile.getContent().getInputStream();
    properties.load(inputStream);//w  ww  .jav a2 s .  c o m
    inputStream.close();
    properties.setProperty("required.classes", "this.class.does.not.Exist");
    properties.store(configFile.getContent().getOutputStream(), "Test Configuration A");
    configFile.close();
    HadoopConfigurationLocator locator = new HadoopConfigurationLocator();
    try {
        locator.init(VFS.getManager().resolveFile(HADOOP_CONFIGURATIONS_PATH),
                new MockActiveHadoopConfigurationLocator("a"), new DefaultFileSystemManager());
        Assert.fail("Should have got exception ");
    } catch (ConfigurationException e) {
        assertEquals(
                "Unable to load class this.class.does.not.Exist that is required to start the Test Configuration A Hadoop Shim",
                e.getCause().getMessage());
    } finally {
        properties.setProperty("required.classes", HadoopConfigurationLocator.class.getName());
        properties.store(configFile.getContent().getOutputStream(), "Test Configuration A");
        configFile.close();
    }
}

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

public void init() throws FileSystemException, ConfigurationException {
    HadoopConfigurationLocator locator = new HadoopConfigurationLocator();
    locator.init(VFS.getManager().resolveFile(HADOOP_CONFIGURATIONS_PATH),
            new MockActiveHadoopConfigurationLocator("a"), new DefaultFileSystemManager());

    assertEquals(1, locator.getConfigurations().size());
    assertEquals(VFS.getManager().resolveFile(HADOOP_CONFIGURATIONS_PATH).resolveFile("a"),
            locator.getConfiguration("a").getLocation());
}

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

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

    assertTrue(locator.hasConfiguration("a"));
}

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

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

    HadoopConfiguration a = locator.getConfiguration("a");
    assertNotNull(a);//from  w  w  w .j  av  a 2s.  c o  m
    assertEquals("a", a.getIdentifier());
    assertEquals("Test Configuration A", a.getName());
}

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

@Test(expected = ConfigurationException.class)
public void getConfiguration_unknown_id() throws Exception {
    HadoopConfigurationLocator locator = new HadoopConfigurationLocator();
    locator.init(VFS.getManager().resolveFile(HADOOP_CONFIGURATIONS_PATH),
            new MockActiveHadoopConfigurationLocator(), new DefaultFileSystemManager());

    locator.getConfiguration("unknown");
}

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 ww .jav a  2s . co m*/
}