use of com.adaptris.core.jdbc.AdvancedJdbcPooledConnection in project interlok by adaptris.
the class JdbcDataCaptureServiceCase method testService_AdvancedPooledConnection.
@Test
public void testService_AdvancedPooledConnection() throws Exception {
int maxServices = 5;
final int iterations = 5;
int poolsize = maxServices - 1;
createDatabase();
List<Service> serviceList = new ArrayList<>();
String name = Thread.currentThread().getName();
Thread.currentThread().setName(getName());
AdvancedJdbcPooledConnection conn = createAdvancedPooledJdbcConnection(poolsize);
try {
for (int i = 0; i < maxServices; i++) {
JdbcIteratingDataCaptureServiceImpl service = createBasicService(false);
service.setConnection(conn);
serviceList.add(service);
start(service);
}
PooledConnectionHelper.executeTest(serviceList, iterations, new PooledConnectionHelper.MessageCreator() {
@Override
public AdaptrisMessage createMsgForPooledConnectionTest() {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_DOCUMENT);
msg.addMetadata(METADATA_KEY, METADATA_VALUE);
return msg;
}
});
assertEquals(0, conn.currentBusyConnectionCount());
assertEquals(poolsize, conn.currentIdleConnectionCount());
assertEquals(poolsize, conn.currentConnectionCount());
doBasicCaptureAsserts(maxServices * iterations);
} finally {
stop(serviceList.toArray(new ComponentLifecycle[0]));
Thread.currentThread().setName(name);
}
}
use of com.adaptris.core.jdbc.AdvancedJdbcPooledConnection in project interlok by adaptris.
the class JdbcBatchingDataCaptureServiceTest method createAdvancedPooledJdbcConnection.
@Override
protected AdvancedJdbcPooledConnection createAdvancedPooledJdbcConnection(int poolsize) {
AdvancedJdbcPooledConnection conn = PooledConnectionHelper.createAdvancedPooledConnection(PROPERTIES.getProperty(JDBC_CAPTURE_SERVICE_DRIVER), PROPERTIES.getProperty(JDBC_CAPTURE_SERVICE_URL), poolsize);
conn.setAutoCommit(false);
return conn;
}
use of com.adaptris.core.jdbc.AdvancedJdbcPooledConnection in project interlok by adaptris.
the class StaticIdentitySequenceNumberServiceTest method testService_AdvancedPooledConnection.
@Test
public void testService_AdvancedPooledConnection() throws Exception {
int maxServices = 5;
final int iterations = 5;
int poolsize = maxServices - 1;
createDatabase();
List<Service> serviceList = new ArrayList<Service>();
String name = Thread.currentThread().getName();
Thread.currentThread().setName(getName());
AdvancedJdbcPooledConnection conn = PooledConnectionHelper.createAdvancedPooledConnection(PROPERTIES.getProperty(JDBC_SEQUENCENUMBER_DRIVER), PROPERTIES.getProperty(JDBC_SEQUENCENUMBER_URL), poolsize);
try {
for (int i = 0; i < maxServices; i++) {
StaticIdentitySequenceNumberService service = createServiceForTests(false);
service.setConnection(conn);
service.setIdentity(new GuidGenerator().safeUUID());
serviceList.add(service);
start(service);
}
PooledConnectionHelper.executeTest(serviceList, iterations, new PooledConnectionHelper.MessageCreator() {
@Override
public AdaptrisMessage createMsgForPooledConnectionTest() throws Exception {
return createMessageForTests();
}
});
assertEquals(0, conn.currentBusyConnectionCount());
assertEquals(poolsize, conn.currentIdleConnectionCount());
assertEquals(poolsize, conn.currentConnectionCount());
} finally {
stop(serviceList.toArray(new ComponentLifecycle[0]));
Thread.currentThread().setName(name);
}
}
use of com.adaptris.core.jdbc.AdvancedJdbcPooledConnection in project interlok by adaptris.
the class JdbcRawDataCaptureServiceTest method testService_AdvancedPooledConnection.
@Test
public void testService_AdvancedPooledConnection() throws Exception {
int maxServices = 5;
final int iterations = 5;
int poolsize = maxServices - 1;
createDatabase();
List<Service> serviceList = new ArrayList<>();
String name = Thread.currentThread().getName();
Thread.currentThread().setName(getName());
AdvancedJdbcPooledConnection conn = PooledConnectionHelper.createAdvancedPooledConnection(PROPERTIES.getProperty(JDBC_CAPTURE_SERVICE_DRIVER), PROPERTIES.getProperty(JDBC_CAPTURE_SERVICE_URL), poolsize);
try {
for (int i = 0; i < maxServices; i++) {
JdbcRawDataCaptureService service = createService(false);
service.setConnection(conn);
serviceList.add(service);
start(service);
}
PooledConnectionHelper.executeTest(serviceList, iterations, new PooledConnectionHelper.MessageCreator() {
@Override
public AdaptrisMessage createMsgForPooledConnectionTest() throws Exception {
return createMessage();
}
});
assertEquals(0, conn.currentBusyConnectionCount());
assertEquals(poolsize, conn.currentIdleConnectionCount());
assertEquals(poolsize, conn.currentConnectionCount());
doBasicCaptureAsserts(iterations * maxServices);
} finally {
stop(serviceList.toArray(new ComponentLifecycle[0]));
Thread.currentThread().setName(name);
}
}
use of com.adaptris.core.jdbc.AdvancedJdbcPooledConnection in project interlok by adaptris.
the class FirstRowMetadataTranslatorTest method testService_AdvancedPooledConnection.
@Test
public void testService_AdvancedPooledConnection() throws Exception {
int maxServices = 5;
final int iterations = 5;
int poolsize = maxServices - 1;
String name = Thread.currentThread().getName();
Thread.currentThread().setName(getName());
createDatabase();
List<AdapterTypeVersion> dbItems = generate(10);
final AdapterTypeVersion entry = dbItems.get(0);
populateDatabase(dbItems, false);
List<Service> serviceList = new ArrayList<Service>();
AdvancedJdbcPooledConnection conn = PooledConnectionHelper.createAdvancedPooledConnection(PROPERTIES.getProperty(JDBC_QUERYSERVICE_DRIVER), PROPERTIES.getProperty(JDBC_QUERYSERVICE_URL), poolsize);
try {
for (int i = 0; i < maxServices; i++) {
JdbcDataQueryService service = createMetadataService(false);
service.setConnection(conn);
serviceList.add(service);
start(service);
}
PooledConnectionHelper.executeTest(serviceList, iterations, new PooledConnectionHelper.MessageCreator() {
@Override
public AdaptrisMessage createMsgForPooledConnectionTest() throws Exception {
return createMessage(entry);
}
});
assertEquals(0, conn.currentBusyConnectionCount());
assertEquals(poolsize, conn.currentIdleConnectionCount());
assertEquals(poolsize, conn.currentConnectionCount());
} finally {
stop(serviceList.toArray(new ComponentLifecycle[0]));
Thread.currentThread().setName(name);
}
}
Aggregations