use of com.adaptris.util.KeyValuePair in project interlok by adaptris.
the class HttpsConsumerTest method createConnection.
@Override
protected HttpConnection createConnection(SecurityHandlerWrapper sh) {
HttpsConnection https = new HttpsConnection();
int port = PortManager.nextUnusedPort(Integer.parseInt(PROPERTIES.getProperty(JETTY_HTTPS_PORT)));
https.setPort(port);
https.getServerConnectorProperties().clear();
https.getServerConnectorProperties().add(new KeyValuePair(ServerConnectorProperty.ReuseAaddress.name(), "true"));
https.getSslProperties().clear();
https.getSslProperties().add(new KeyValuePair(SslProperty.KeyStorePassword.name(), PROPERTIES.getProperty(SECURITY_PASSWORD)));
https.getSslProperties().add(new KeyValuePair(SslProperty.KeyStorePath.name(), PROPERTIES.getProperty(KEYSTORE_PATH)));
https.getSslProperties().add(new KeyValuePair(SslProperty.KeyStoreType.name(), PROPERTIES.getProperty(KEYSTORE_TYPE)));
https.getSslProperties().add(new KeyValuePair(SslProperty.KeyManagerPassword.name(), PROPERTIES.getProperty(SECURITY_PASSWORD)));
https.getSslProperties().add(new KeyValuePair(SslProperty.TrustStorePassword.name(), PROPERTIES.getProperty(SECURITY_PASSWORD)));
https.getSslProperties().add(new KeyValuePair(SslProperty.TrustStoreType.name(), PROPERTIES.getProperty(KEYSTORE_TYPE)));
https.getSslProperties().add(new KeyValuePair(SslProperty.TrustStorePath.name(), PROPERTIES.getProperty(KEYSTORE_PATH)));
https.getHttpConfiguration().clear();
https.getHttpConfiguration().add(new KeyValuePair(HttpConfigurationProperty.OutputBufferSize.name(), "8192"));
https.getHttpConfiguration().add(new KeyValuePair(HttpConfigurationProperty.SendServerVersion.name(), "false"));
https.getHttpConfiguration().add(new KeyValuePair(HttpConfigurationProperty.SendDateHeader.name(), "false"));
if (sh != null) {
https.setSecurityHandler(sh);
}
return https;
}
use of com.adaptris.util.KeyValuePair in project interlok by adaptris.
the class HttpsConsumerTest method testTLS_ConsumeWorkflow.
@Test
public void testTLS_ConsumeWorkflow() throws Exception {
String oldName = Thread.currentThread().getName();
Thread.currentThread().setName(getName());
HttpConnection connection = createConnection(null);
((HttpsConnection) connection).getSslProperties().add(new KeyValuePair(SslProperty.ExcludeProtocols.name(), "SSLv3,TLSv1.1,"));
MockMessageProducer mockProducer = new MockMessageProducer();
SimpleHttpProducer myHttpProducer = createProducer(new VersionedHttpsProduceConnection("TLSv1.2"));
Channel channel = JettyHelper.createChannel(connection, JettyHelper.createConsumer(URL_TO_POST_TO), mockProducer);
try {
channel.requestStart();
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
msg.addMetadata(CONTENT_TYPE_METADATA_KEY, "text/xml");
myHttpProducer.setUrl(createProduceDestinationUrl(connection.getPort()));
start(myHttpProducer);
AdaptrisMessage reply = myHttpProducer.request(msg);
assertEquals("Reply Payloads", XML_PAYLOAD, reply.getContent());
doAssertions(mockProducer);
} finally {
stop(myHttpProducer);
channel.requestClose();
PortManager.release(connection.getPort());
Thread.currentThread().setName(oldName);
}
}
use of com.adaptris.util.KeyValuePair in project interlok by adaptris.
the class PluggableJdbcPooledConnectionTest method configure.
@Override
protected PluggableJdbcPooledConnection configure(PluggableJdbcPooledConnection conn1) throws Exception {
String url = initialiseDatabase();
conn1.setConnectUrl(url);
conn1.setDriverImp(DRIVER_IMP);
conn1.setConnectionAttempts(1);
conn1.setConnectionRetryInterval(new TimeInterval(10L, TimeUnit.MILLISECONDS.name()));
KeyValuePairSet poolProps = new KeyValuePairSet();
poolProps.add(new KeyValuePair("maximumPoolSize", "50"));
poolProps.add(new KeyValuePair("minimumIdle", "1"));
conn1.setPoolProperties(poolProps);
return conn1;
}
use of com.adaptris.util.KeyValuePair in project interlok by adaptris.
the class PluggableJdbcPooledConnectionTest method testConnection_UsesPool.
@Test
public void testConnection_UsesPool() throws Exception {
String originalThread = Thread.currentThread().getName();
Thread.currentThread().setName("testConnectionDataSource_Poolsize");
PluggableJdbcPooledConnection con = configure(createConnection());
con.setConnectUrl("jdbc:derby:memory:" + GUID.safeUUID() + ";create=true");
con.setDriverImp("org.apache.derby.jdbc.EmbeddedDriver");
KeyValuePairSet poolProps = new KeyValuePairSet();
poolProps.add(new KeyValuePair("maximumPoolSize", "50"));
poolProps.add(new KeyValuePair("minimumIdle", "1"));
con.withPoolProperties(poolProps);
try {
LifecycleHelper.initAndStart(con);
Awaitility.await().atMost(Duration.ofSeconds(5)).with().pollInterval(Duration.ofMillis(100)).until(() -> con.retrieveComponentState().equals(StartedState.getInstance()));
Connection c1 = con.connect();
Connection c2 = con.connect();
// Shouldn't be the same object...
assertNotSame(c1, c2);
JdbcUtil.closeQuietly(c1, c2);
} finally {
Thread.currentThread().setName(originalThread);
LifecycleHelper.stopAndClose(con);
}
}
use of com.adaptris.util.KeyValuePair in project interlok by adaptris.
the class LoggingContextInterceptorTest method testInterceptor_KVP_Expression.
@Test
public void testInterceptor_KVP_Expression() throws Exception {
KeyValuePairList kvp = new KeyValuePairList();
kvp.add(new KeyValuePair("key1", "%message{mk1}"));
kvp.add(new KeyValuePair("key2", "%message{mk2}"));
LoggingContextWorkflowInterceptor interceptor = new LoggingContextWorkflowInterceptor(null);
interceptor.setValuesToSet(kvp);
StandardWorkflow wf = StatisticsMBeanCase.createWorkflow("workflowName", interceptor);
MockMessageProducer prod = new MockMessageProducer();
wf.setProducer(prod);
wf.getServiceCollection().add(new LoggingContextToMetadata());
MockChannel c = new MockChannel();
c.setUniqueId("channelName");
c.getWorkflowList().add(wf);
try {
BaseCase.start(c);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata("mk1", "mv1");
msg.addMetadata("mk2", "mv2");
wf.onAdaptrisMessage(msg);
Map<String, String> metadata = prod.getMessages().get(0).getMessageHeaders();
assertTrue(metadata.containsKey("key1"));
assertEquals("mv1", metadata.get("key1"));
assertTrue(metadata.containsKey("key2"));
assertEquals("mv2", metadata.get("key2"));
} finally {
BaseCase.stop(c);
}
}
Aggregations