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