Example usage for org.apache.commons.vfs2 FileSystemOptions getClass

List of usage examples for org.apache.commons.vfs2 FileSystemOptions getClass

Introduction

In this page you can find the example usage for org.apache.commons.vfs2 FileSystemOptions getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.pentaho.di.core.vfs.configuration.KettleSftpFileSystemConfigBuilderTest.java

@Test
public void recognizesAndSetsUserHomeDirProperty() throws Exception {
    final String fullName = Const.VFS_USER_DIR_IS_ROOT;
    final String name = fullName.substring("vfs.sftp.".length());
    final String vfsInternalName = SftpFileSystemConfigBuilder.class.getName() + ".USER_DIR_IS_ROOT";

    final FileSystemOptions opts = new FileSystemOptions();
    KettleSftpFileSystemConfigBuilder builder = KettleSftpFileSystemConfigBuilder.getInstance();
    builder.setParameter(opts, name, "true", fullName, "sftp://fake-url:22");

    Method getOption = ReflectionUtils.findMethod(opts.getClass(), "getOption", Class.class, String.class);
    getOption.setAccessible(true);/*from  w  ww . j a  v  a2s .  c  o m*/
    Object value = ReflectionUtils.invokeMethod(getOption, opts, builder.getConfigClass(), vfsInternalName);
    assertEquals(true, value);
}

From source file:org.pentaho.di.core.vfs.configuration.KettleSftpFileSystemConfigBuilderTest.java

@Test
public void recognizesAndSetsIdentityKeyFile() throws Exception {
    File tempFile = File.createTempFile("KettleSftpFileSystemConfigBuilderTest", ".tmp");
    tempFile.deleteOnExit();//from  ww w.j a  v a 2 s .c om

    final String fullName = "vfs.sftp.identity";
    final String name = fullName.substring("vfs.sftp.".length());
    final String vfsInternalName = SftpFileSystemConfigBuilder.class.getName() + ".IDENTITIES";

    final FileSystemOptions opts = new FileSystemOptions();
    KettleSftpFileSystemConfigBuilder builder = KettleSftpFileSystemConfigBuilder.getInstance();
    builder.setParameter(opts, name, tempFile.getAbsolutePath(), fullName, "sftp://fake-url:22");

    Method getOption = ReflectionUtils.findMethod(opts.getClass(), "getOption", Class.class, String.class);
    getOption.setAccessible(true);
    Object value = ReflectionUtils.invokeMethod(getOption, opts, builder.getConfigClass(), vfsInternalName);
    assertEquals(IdentityInfo[].class, value.getClass());
    assertEquals(tempFile.getAbsolutePath(), ((IdentityInfo[]) value)[0].getPrivateKey().getAbsolutePath());
}