use of java.util.Properties in project camel by apache.
the class IOConverterTest method testToPropertiesFromReader.
public void testToPropertiesFromReader() throws Exception {
Reader br = IOHelper.buffered(new StringReader("foo=123\nbar=456"));
Properties p = IOConverter.toProperties(br);
assertNotNull(p);
assertEquals(2, p.size());
assertEquals("123", p.get("foo"));
assertEquals("456", p.get("bar"));
}
use of java.util.Properties in project camel by apache.
the class IOConverterTest method testToPropertiesFromFile.
public void testToPropertiesFromFile() throws Exception {
Properties p = IOConverter.toProperties(new File("src/test/resources/log4j2.properties"));
assertNotNull(p);
assertTrue("Should be 8 or more properties, was " + p.size(), p.size() >= 8);
String root = (String) p.get("rootLogger.level");
assertNotNull(root);
assertTrue(root.contains("INFO"));
}
use of java.util.Properties in project camel by apache.
the class AbstractJsseParametersTest method createPropertiesPlaceholderAwareContext.
protected CamelContext createPropertiesPlaceholderAwareContext() throws Exception {
Properties supplementalProperties = new Properties();
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
SecureRandom sr = null;
try {
sr = SecureRandom.getInstance("SHA1PRNG");
} catch (NoSuchAlgorithmException e) {
// Ignore
}
SSLContext sslc = SSLContext.getInstance("TLS");
sslc.init(null, null, null);
SSLSocket socket = (SSLSocket) sslc.getSocketFactory().createSocket();
supplementalProperties.setProperty("keyStoreParameters.type", KeyStore.getDefaultType());
supplementalProperties.setProperty("keyStoreParameters.provider", ks.getProvider().getName());
supplementalProperties.setProperty("keyManagersParameters.algorithm", KeyManagerFactory.getDefaultAlgorithm());
supplementalProperties.setProperty("keyManagersParameters.provider", kmf.getProvider().getName());
supplementalProperties.setProperty("trustManagersParameters.algorithm", TrustManagerFactory.getDefaultAlgorithm());
supplementalProperties.setProperty("trustManagersParameters.provider", tmf.getProvider().getName());
if (sr != null) {
supplementalProperties.setProperty("secureRandomParameters.algorithm", "SHA1PRNG");
supplementalProperties.setProperty("secureRandomParameters.provider", sr.getProvider().getName());
}
supplementalProperties.setProperty("sslContextParameters.provider", sslc.getProvider().getName());
supplementalProperties.setProperty("cipherSuite.0", socket.getSupportedCipherSuites()[0]);
// Have to skip this guy because he doesn't work with TLS as the SSLContext protocol
String ssp = "";
for (String protocol : socket.getSupportedProtocols()) {
if (!"SSLv2Hello".equals(protocol)) {
ssp = protocol;
break;
}
}
supplementalProperties.setProperty("secureSocketProtocol.0", ssp);
return this.createPropertiesPlaceholderAwareContext(supplementalProperties);
}
use of java.util.Properties in project camel by apache.
the class AbstractJsseParametersTest method createPropertiesPlaceholderAwareContext.
protected CamelContext createPropertiesPlaceholderAwareContext(Properties supplementalProperties) throws IOException {
Properties properties = new Properties(supplementalProperties);
properties.load(AbstractJsseParametersTest.class.getResourceAsStream("test.properties"));
if (supplementalProperties != null) {
Properties mergedProps = new Properties();
Set<String> keys = new HashSet<String>();
keys.addAll(properties.stringPropertyNames());
keys.addAll(supplementalProperties.stringPropertyNames());
for (String key : keys) {
mergedProps.setProperty(key, properties.getProperty(key));
}
properties = mergedProps;
}
properties.store(new FileOutputStream("target/jsse-test.properties"), "Generated by " + AbstractJsseParametersTest.class.getName());
PropertiesComponent pc = new PropertiesComponent();
pc.setLocation("file:./target/jsse-test.properties");
CamelContext context = new DefaultCamelContext();
context.addComponent("properties", pc);
return context;
}
use of java.util.Properties in project camel by apache.
the class AbstractBraintreeTestSupport method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
final CamelContext context = super.createCamelContext();
// read Braintree component configuration from TEST_OPTIONS_PROPERTIES
final Properties properties = new Properties();
try {
properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES));
} catch (Exception e) {
throw new IOException(String.format("%s could not be loaded: %s", TEST_OPTIONS_PROPERTIES, e.getMessage()), e);
}
Map<String, Object> options = new HashMap<>();
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
options.put(entry.getKey().toString(), entry.getValue());
}
addOptionIfMissing(options, "environment", "CAMEL_BRAINTREE_ENVIRONMENT");
addOptionIfMissing(options, "merchantId", "CAMEL_BRAINTREE_MERCHANT_ID");
addOptionIfMissing(options, "publicKey", "CAMEL_BRAINTREE_PUBLIC_KEY");
addOptionIfMissing(options, "privateKey", "CAMEL_BRAINTREE_PRIVATE_KEY");
final BraintreeConfiguration configuration = new BraintreeConfiguration();
configuration.setHttpLogLevel(BraintreeLogHandler.DEFAULT_LOGGER_VERSION);
configuration.setHttpLogName(BraintreeLogHandler.DEFAULT_LOGGER_NAME);
IntrospectionSupport.setProperties(configuration, options);
// add BraintreeComponent to Camel context
final BraintreeComponent component = new BraintreeComponent(context);
component.setConfiguration(configuration);
context.addComponent("braintree", component);
return context;
}
Aggregations