Search in sources :

Example 51 with KeyValuePairSet

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

the class AdvancedJdbcPooledConnectionTest method testConnectionDataSource_Poolsize.

@Test
public void testConnectionDataSource_Poolsize() throws Exception {
    String originalThread = Thread.currentThread().getName();
    Thread.currentThread().setName("testConnectionDataSource_Poolsize");
    AdvancedJdbcPooledConnection 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(PooledConnectionProperties.acquireIncrement.name(), "5"));
    poolProps.add(new KeyValuePair(PooledConnectionProperties.minPoolSize.name(), "10"));
    poolProps.add(new KeyValuePair(PooledConnectionProperties.maxPoolSize.name(), "50"));
    poolProps.add(new KeyValuePair(PooledConnectionProperties.checkoutTimeout.name(), "30000"));
    con.setConnectionPoolProperties(poolProps);
    try {
        LifecycleHelper.initAndStart(con);
        Awaitility.await().atMost(Duration.ofSeconds(5)).with().pollInterval(Duration.ofMillis(100)).until(() -> con.retrieveComponentState().equals(StartedState.getInstance()));
        ComboPooledDataSource poolDs = ((C3P0PooledDataSource) con.asDataSource()).wrapped();
        assertEquals(0, poolDs.getNumBusyConnections());
        Connection c0 = null;
        try {
            c0 = poolDs.getConnection();
            slf4jLogger.info("1 get: NumConnections={}, NumBusyConnnections={}, NumIdleConnections={}", poolDs.getNumConnections(), poolDs.getNumBusyConnections(), poolDs.getNumIdleConnections());
        } finally {
            JdbcUtil.closeQuietly(c0);
        }
        Awaitility.await().atMost(Duration.ofSeconds(5)).with().pollInterval(Duration.ofMillis(100)).until(() -> poolDs.getNumBusyConnections() == 0);
        Connection c1 = poolDs.getConnection();
        slf4jLogger.info("1 get (again): NumConnections={}, NumBusyConnnections={}, NumIdleConnections={}", poolDs.getNumConnections(), poolDs.getNumBusyConnections(), poolDs.getNumIdleConnections());
        Connection c2 = poolDs.getConnection();
        slf4jLogger.info("2 get: NumConnections={}, NumBusyConnnections={}, NumIdleConnections={}", poolDs.getNumConnections(), poolDs.getNumBusyConnections(), poolDs.getNumIdleConnections());
        Connection c3 = poolDs.getConnection();
        slf4jLogger.info("3 get: NumConnections={}, NumBusyConnnections={}, NumIdleConnections={}", poolDs.getNumConnections(), poolDs.getNumBusyConnections(), poolDs.getNumIdleConnections());
        Connection c4 = poolDs.getConnection();
        slf4jLogger.info("4 get: NumConnections={}, NumBusyConnnections={}, NumIdleConnections={}", poolDs.getNumConnections(), poolDs.getNumBusyConnections(), poolDs.getNumIdleConnections());
        Connection c5 = poolDs.getConnection();
        slf4jLogger.info("5 get: NumConnections={}, NumBusyConnnections={}, NumIdleConnections={}", poolDs.getNumConnections(), poolDs.getNumBusyConnections(), poolDs.getNumIdleConnections());
        Connection c6 = poolDs.getConnection();
        slf4jLogger.info("6 get: NumConnections={}, NumBusyConnnections={}, NumIdleConnections={}", poolDs.getNumConnections(), poolDs.getNumBusyConnections(), poolDs.getNumIdleConnections());
        Connection c7 = poolDs.getConnection();
        slf4jLogger.info("7 get: NumConnections={}, NumBusyConnnections={}, NumIdleConnections={}", poolDs.getNumConnections(), poolDs.getNumBusyConnections(), poolDs.getNumIdleConnections());
        assertTrue(poolDs.getNumBusyConnections() > 0);
        JdbcUtil.closeQuietly(c1, c2, c3, c4, c5, c6, c7);
        Awaitility.await().atMost(Duration.ofSeconds(5)).with().pollInterval(Duration.ofMillis(100)).until(() -> poolDs.getNumBusyConnections() == 0);
        slf4jLogger.info("closed: NumConnections={}, NumBusyConnnections={}, NumIdleConnections={}", poolDs.getNumConnections(), poolDs.getNumBusyConnections(), poolDs.getNumIdleConnections());
        assertEquals(0, poolDs.getNumBusyConnections());
    } finally {
        Thread.currentThread().setName(originalThread);
        LifecycleHelper.stopAndClose(con);
    }
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) KeyValuePair(com.adaptris.util.KeyValuePair) Connection(java.sql.Connection) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test)

Example 52 with KeyValuePairSet

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

the class AddNamespaceObjectMetadataTest method createContextEntries.

private KeyValuePairSet createContextEntries() {
    KeyValuePairSet contextEntries = new KeyValuePairSet();
    contextEntries.add(new KeyValuePair("svrl", "http://purl.oclc.org/dsdl/svrl"));
    contextEntries.add(new KeyValuePair("xsd", "http://www.w3.org/2001/XMLSchema"));
    contextEntries.add(new KeyValuePair("xs", "http://www.w3.org/2001/XMLSchema"));
    contextEntries.add(new KeyValuePair("sch", "http://www.ascc.net/xml/schematron"));
    contextEntries.add(new KeyValuePair("iso", "http://purl.oclc.org/dsdl/schematron"));
    contextEntries.add(new KeyValuePair("dp", "http://www.dpawson.co.uk/ns#"));
    return contextEntries;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 53 with KeyValuePairSet

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

the class IntegerValueMatcherTest method createBadMappings.

private static KeyValuePairSet createBadMappings() {
    KeyValuePairSet result = new KeyValuePairSet();
    result.addKeyValuePair(new KeyValuePair("123456", EQUALS));
    result.addKeyValuePair(new KeyValuePair("ABCDEFG", EQUALS));
    result.addKeyValuePair(new KeyValuePair(">>10", EQUALS));
    result.addKeyValuePair(new KeyValuePair(">=ABCDEFG", EQUALS));
    return result;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 54 with KeyValuePairSet

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

the class DatabaseConnectionCase method testConnectWithProperties.

@Test
public void testConnectWithProperties() throws Exception {
    DatabaseConnection con = configure(createConnection());
    con.setConnectionProperties(new KeyValuePairSet());
    LifecycleHelper.init(con);
    LifecycleHelper.start(con);
    con.connect();
}
Also used : DatabaseConnection(com.adaptris.core.jdbc.DatabaseConnection) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test)

Example 55 with KeyValuePairSet

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

the class SharedComponentListTest method createPtpConnection.

private JmsConnection createPtpConnection(String uniqueId) throws PasswordException {
    JmsConnection c = new JmsConnection();
    StandardJndiImplementation jndi = new StandardJndiImplementation();
    jndi.setJndiName("Connection_Factory_To_Lookup");
    KeyValuePairSet kvps = jndi.getJndiParams();
    kvps.addKeyValuePair(new KeyValuePair(Context.SECURITY_PRINCIPAL, "Administrator"));
    kvps.addKeyValuePair(new KeyValuePair(Context.SECURITY_CREDENTIALS, "Administrator"));
    kvps.addKeyValuePair(new KeyValuePair("com.sonicsw.jndi.mfcontext.domain", "Domain1"));
    kvps.addKeyValuePair(new KeyValuePair(Context.INITIAL_CONTEXT_FACTORY, "com.sonicsw.jndi.mfcontext.MFContextFactory"));
    jndi.getJndiParams().addKeyValuePair(new KeyValuePair(Context.PROVIDER_URL, "tcp://localhost:2506"));
    c.setVendorImplementation(jndi);
    if (!isEmpty(uniqueId)) {
        c.setUniqueId(uniqueId);
    }
    return c;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) JmsConnection(com.adaptris.core.jms.JmsConnection) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

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