use of org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder in project jackrabbit by apache.
the class TestVFSDataStore method doSetFileSystemOptionsPropertiesInString.
/**
* Test {@link VFSDataStore#setFileSystemOptionsPropertiesInString(String)} and validate the internal properties.
*/
protected void doSetFileSystemOptionsPropertiesInString() throws Exception {
dataStore = new VFSDataStore();
Properties props = getConfigProps();
baseFolderUri = props.getProperty(VFSDataStore.BASE_FOLDER_URI);
dataStore.setBaseFolderUri(baseFolderUri);
LOG.info("baseFolderUri [{}] set.", baseFolderUri);
dataStore.setFileSystemOptionsProperties(props);
dataStore.setSecret("123456");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(SFTP_FILE_SYSTEM_OPTIONS_PARAM_XML)));
Element paramElem = document.getDocumentElement();
String propsInString = paramElem.getAttribute("value");
dataStore.setFileSystemOptionsPropertiesInString(propsInString);
final Properties internalProps = dataStore.getFileSystemOptionsProperties();
Assert.assertEquals("/home/tester/.ssh/id_rsa", internalProps.getProperty("fso.sftp.identities"));
Assert.assertEquals("30000", internalProps.getProperty("fso.sftp.timeout"));
dataStore.init(dataStoreDir);
final FileSystemOptions fso = dataStore.getFileSystemOptions();
final SftpFileSystemConfigBuilder configBuilder = SftpFileSystemConfigBuilder.getInstance();
File[] identities = configBuilder.getIdentities(fso);
Assert.assertNotNull(identities);
Assert.assertEquals(1, identities.length);
Assert.assertEquals("/home/tester/.ssh/id_rsa", FilenameUtils.separatorsToUnix(identities[0].getPath()));
Assert.assertEquals(Integer.valueOf(30000), configBuilder.getTimeout(fso));
dataStore.close();
}
Aggregations