use of com.helger.commons.lang.NonBlockingProperties in project ph-web by phax.
the class CommandRunnerTest method initializeClass.
@BeforeClass
public static void initializeClass() {
try (final InputStream inputStream = ClassLoader.getSystemResourceAsStream("configuration.properties")) {
Assume.assumeNotNull(inputStream);
properties = new NonBlockingProperties();
properties.load(inputStream);
} catch (final IOException e) {
LOGGER.warn("cant find properties file (tests will be skipped)", e);
properties = null;
return;
}
final String knownHosts = properties.getProperty("ssh.knownHosts");
final String privateKey = properties.getProperty("ssh.privateKey");
final String username = properties.getProperty("scp.out.test.username");
final String hostname = "localhost";
final int port = Integer.parseInt(properties.getProperty("scp.out.test.port"));
final DefaultSessionFactory defaultSessionFactory = new DefaultSessionFactory(username, hostname, port);
try {
defaultSessionFactory.setKnownHosts(knownHosts);
defaultSessionFactory.setIdentityFromPrivateKey(privateKey);
} catch (final JSchException e) {
Assume.assumeNoException(e);
}
sessionFactory = defaultSessionFactory;
}
use of com.helger.commons.lang.NonBlockingProperties in project ph-web by phax.
the class SshProxyTest method initializeClass.
@BeforeClass
public static void initializeClass() {
try (final InputStream inputStream = ClassLoader.getSystemResourceAsStream("configuration.properties")) {
Assume.assumeNotNull(inputStream);
properties = new NonBlockingProperties();
properties.load(inputStream);
} catch (final IOException e) {
LOGGER.warn("cant find properties file (tests will be skipped)", e);
properties = null;
return;
}
final String knownHosts = properties.getProperty("ssh.knownHosts");
final String privateKey = properties.getProperty("ssh.privateKey");
username = properties.getProperty("scp.out.test.username");
hostname = "localhost";
port = Integer.parseInt(properties.getProperty("scp.out.test.port"));
sessionFactory = new DefaultSessionFactory(username, hostname, port);
try {
sessionFactory.setKnownHosts(knownHosts);
sessionFactory.setIdentityFromPrivateKey(privateKey);
} catch (final JSchException e) {
Assume.assumeNoException(e);
}
}
use of com.helger.commons.lang.NonBlockingProperties in project ph-commons by phax.
the class ConfigurationSourceProperties method reload.
@Nonnull
public ESuccess reload() {
// Main load
final NonBlockingProperties aProps = _load(getResource(), m_aCharset);
// Replace in write-lock
m_aRWLock.writeLockedGet(() -> m_aProps = aProps);
return ESuccess.valueOf(aProps != null);
}
use of com.helger.commons.lang.NonBlockingProperties in project ph-commons by phax.
the class SettingsPersistenceProperties method readSettings.
@Nonnull
public ISettings readSettings(@Nonnull @WillClose final InputStream aIS) {
ValueEnforcer.notNull(aIS, "InputStream");
// Create the settings object
final ISettings aSettings = m_aSettingsFactory.apply(getReadSettingsName());
// Read the properties file from the input stream
final NonBlockingProperties aProps = PropertiesHelper.loadProperties(aIS);
if (aProps != null)
for (final Map.Entry<String, String> aEntry : aProps.entrySet()) aSettings.putIn(aEntry.getKey(), aEntry.getValue());
return aSettings;
}
use of com.helger.commons.lang.NonBlockingProperties in project ph-commons by phax.
the class XMLResourceBundleTest method testAll.
@Test
public void testAll() {
final File aFile = new File("target/test-classes/unittest-xml-props.xml");
try {
// Create dummy properties file
final NonBlockingProperties p = new NonBlockingProperties();
p.setProperty("prop1", "Value 1");
p.setProperty("prop2", "äöü");
MicroWriter.writeToFile(XMLResourceBundle.getAsPropertiesXML(p), aFile);
// Read again
final XMLResourceBundle aRB = XMLResourceBundle.getXMLBundle("unittest-xml-props");
assertNotNull(aRB);
assertEquals("Value 1", aRB.getString("prop1"));
assertEquals("äöü", aRB.getString("prop2"));
try {
aRB.getObject("prop3");
fail();
} catch (final MissingResourceException ex) {
// expected
}
} finally {
FileOperations.deleteFile(aFile);
}
}
Aggregations