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);
}
}
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;
}
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;
}
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();
}
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;
}
Aggregations