Search in sources :

Example 1 with KeyValuePairSet

use of com.adaptris.util.KeyValuePairSet 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 2 with KeyValuePairSet

use of com.adaptris.util.KeyValuePairSet 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 3 with KeyValuePairSet

use of com.adaptris.util.KeyValuePairSet in project interlok by adaptris.

the class JdbcXPathParameterTest method testSetNamespaceContext.

@Test
public void testSetNamespaceContext() {
    JdbcXPathParameter parameter = new JdbcXPathParameter();
    assertNull(parameter.getNamespaceContext());
    KeyValuePairSet kvps = new KeyValuePairSet();
    kvps.add(new KeyValuePair("hello", "world"));
    parameter.setNamespaceContext(kvps);
    assertEquals(kvps, parameter.getNamespaceContext());
    parameter.setNamespaceContext(null);
    assertNull(parameter.getNamespaceContext());
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test)

Example 4 with KeyValuePairSet

use of com.adaptris.util.KeyValuePairSet in project interlok by adaptris.

the class JmsConnectionErrorHandlerTest method testComparatorWith2IdenticalJNDIConnections.

@Test
public void testComparatorWith2IdenticalJNDIConnections() throws Exception {
    JmsConnectionErrorHandler connectionErrorHandler1 = new JmsConnectionErrorHandler();
    JmsConnectionErrorHandler connectionErrorHandler2 = new JmsConnectionErrorHandler();
    JmsConnection connection1 = new JmsConnection();
    JmsConnection connection2 = new JmsConnection();
    KeyValuePairSet keyValuePairSet = new KeyValuePairSet();
    KeyValuePair keyVPInitial = new KeyValuePair();
    keyVPInitial.setKey("java.naming.factory.initial");
    keyVPInitial.setValue("com.sonicsw.jndi.mfcontext.MFContextFactory");
    KeyValuePair keyVPCred = new KeyValuePair();
    keyVPCred.setKey("java.naming.security.credentials");
    keyVPCred.setValue("Administrator");
    KeyValuePair keyVPDomain = new KeyValuePair();
    keyVPDomain.setKey("com.sonicsw.jndi.mfcontext.domain");
    keyVPDomain.setValue("Domain1");
    KeyValuePair keyVPUrl = new KeyValuePair();
    keyVPUrl.setKey("java.naming.provider.url");
    keyVPUrl.setValue("tcp://localhost:2506");
    KeyValuePair keyVPPrinciple = new KeyValuePair();
    keyVPPrinciple.setKey("java.naming.security.principal");
    keyVPPrinciple.setValue("Administrator");
    keyValuePairSet.add(keyVPInitial);
    keyValuePairSet.add(keyVPCred);
    keyValuePairSet.add(keyVPCred);
    keyValuePairSet.add(keyVPInitial);
    StandardJndiImplementation jndiVendor1 = new StandardJndiImplementation();
    jndiVendor1.setJndiParams(keyValuePairSet);
    StandardJndiImplementation jndiVendor2 = new StandardJndiImplementation();
    jndiVendor2.setJndiParams(keyValuePairSet);
    connection1.setVendorImplementation(jndiVendor1);
    connection2.setVendorImplementation(jndiVendor2);
    connectionErrorHandler1.registerConnection(connection1);
    connectionErrorHandler2.registerConnection(connection2);
    assertFalse(connectionErrorHandler1.allowedInConjunctionWith(connectionErrorHandler2));
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test)

Example 5 with KeyValuePairSet

use of com.adaptris.util.KeyValuePairSet in project interlok by adaptris.

the class JmsConnectionErrorHandlerTest method testComparatorWith2DifferemtJNDIConnections.

@Test
public void testComparatorWith2DifferemtJNDIConnections() throws Exception {
    JmsConnectionErrorHandler connectionErrorHandler1 = new JmsConnectionErrorHandler();
    JmsConnectionErrorHandler connectionErrorHandler2 = new JmsConnectionErrorHandler();
    JmsConnection connection1 = new JmsConnection();
    JmsConnection connection2 = new JmsConnection();
    KeyValuePairSet keyValuePairSet1 = new KeyValuePairSet();
    KeyValuePair keyVPInitial = new KeyValuePair();
    keyVPInitial.setKey("java.naming.factory.initial");
    keyVPInitial.setValue("com.sonicsw.jndi.mfcontext.MFContextFactory");
    KeyValuePair keyVPCred = new KeyValuePair();
    keyVPCred.setKey("java.naming.security.credentials");
    keyVPCred.setValue("Administrator");
    KeyValuePair keyVPDomain = new KeyValuePair();
    keyVPDomain.setKey("com.sonicsw.jndi.mfcontext.domain");
    keyVPDomain.setValue("Domain1");
    KeyValuePair keyVPUrl = new KeyValuePair();
    keyVPUrl.setKey("java.naming.provider.url");
    keyVPUrl.setValue("tcp://localhost:2506");
    KeyValuePair keyVPPrinciple = new KeyValuePair();
    keyVPPrinciple.setKey("java.naming.security.principal");
    keyVPPrinciple.setValue("Administrator");
    keyValuePairSet1.add(keyVPInitial);
    keyValuePairSet1.add(keyVPCred);
    keyValuePairSet1.add(keyVPCred);
    keyValuePairSet1.add(keyVPInitial);
    KeyValuePairSet keyValuePairSet2 = new KeyValuePairSet(keyValuePairSet1);
    keyValuePairSet2.addKeyValuePair(new KeyValuePair("java.naming.provider.url", "tcp://localhost:2507"));
    StandardJndiImplementation jndiVendor1 = new StandardJndiImplementation();
    jndiVendor1.setJndiParams(keyValuePairSet1);
    StandardJndiImplementation jndiVendor2 = new StandardJndiImplementation();
    jndiVendor2.setJndiParams(keyValuePairSet2);
    connection1.setVendorImplementation(jndiVendor1);
    connection2.setVendorImplementation(jndiVendor2);
    connectionErrorHandler1.registerConnection(connection1);
    connectionErrorHandler2.registerConnection(connection2);
    assertTrue(connectionErrorHandler1.allowedInConjunctionWith(connectionErrorHandler2));
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test)

Aggregations

KeyValuePairSet (com.adaptris.util.KeyValuePairSet)62 KeyValuePair (com.adaptris.util.KeyValuePair)54 Test (org.junit.Test)30 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)5 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)5 TimeInterval (com.adaptris.util.TimeInterval)4 SimpleFactoryConfiguration (com.adaptris.core.jms.jndi.SimpleFactoryConfiguration)3 Connection (java.sql.Connection)3 ArrayList (java.util.ArrayList)3 CoreException (com.adaptris.core.CoreException)2 ServiceException (com.adaptris.core.ServiceException)2 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)2 StandaloneProducer (com.adaptris.core.StandaloneProducer)2 Execution (com.adaptris.core.common.Execution)2 MetadataDataInputParameter (com.adaptris.core.common.MetadataDataInputParameter)2 StringPayloadDataInputParameter (com.adaptris.core.common.StringPayloadDataInputParameter)2 JdbcConnection (com.adaptris.core.jdbc.JdbcConnection)2 JunitBootstrapProperties (com.adaptris.core.stubs.JunitBootstrapProperties)2 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)2 ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)2