Search in sources :

Example 1 with KeyValuePair

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;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair)

Example 2 with KeyValuePair

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);
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleHttpProducer(com.adaptris.http.legacy.SimpleHttpProducer) Channel(com.adaptris.core.Channel) VersionedHttpsProduceConnection(com.adaptris.http.legacy.VersionedHttpsProduceConnection) Test(org.junit.Test)

Example 3 with KeyValuePair

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;
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 4 with KeyValuePair

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);
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) Connection(java.sql.Connection) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test)

Example 5 with KeyValuePair

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);
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) MockChannel(com.adaptris.core.stubs.MockChannel) KeyValuePair(com.adaptris.util.KeyValuePair) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) KeyValuePairList(com.adaptris.util.KeyValuePairList) Test(org.junit.Test)

Aggregations

KeyValuePair (com.adaptris.util.KeyValuePair)143 Test (org.junit.Test)79 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)55 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)26 KeyValuePairList (com.adaptris.util.KeyValuePairList)12 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)11 StandaloneProducer (com.adaptris.core.StandaloneProducer)10 Channel (com.adaptris.core.Channel)9 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)9 TimeInterval (com.adaptris.util.TimeInterval)9 ServiceException (com.adaptris.core.ServiceException)7 JmsConnection (com.adaptris.core.jms.JmsConnection)6 ArrayList (java.util.ArrayList)6 CoreException (com.adaptris.core.CoreException)5 StandardWorkflow (com.adaptris.core.StandardWorkflow)5 PasProducer (com.adaptris.core.jms.PasProducer)5 MetadataCollection (com.adaptris.core.MetadataCollection)4 MetadataElement (com.adaptris.core.MetadataElement)4 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)4 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)3