use of com.adaptris.core.jdbc.DatabaseConnection in project interlok by adaptris.
the class JdbcServiceListTest method testServiceList_ExceptionRollsback.
@Test
public void testServiceList_ExceptionRollsback() throws Exception {
createDatabase();
JdbcServiceList service = createServiceCollection();
DatabaseConnection c = createJdbcConnection();
c.setAutoCommit(false);
c.setDebugMode(true);
service.setConnection(c);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
String oldName = Thread.currentThread().getName();
Thread.currentThread().setName("testServiceList_ExceptionRollsback");
try {
service.add(createSequenceNumberService(null, getName(), SequenceNumberCase.DEFAULT_ID));
service.add(new NullService() {
@Override
public void doService(AdaptrisMessage msg) throws ServiceException {
throw new ServiceException("testServiceList_ExceptionRollsback throws an Exception");
}
});
try {
execute(service, msg);
} catch (ServiceException expected) {
}
assertTrue(msg.getObjectHeaders().containsKey(JdbcConstants.OBJ_METADATA_DATABASE_CONNECTION_KEY));
Connection conn = (Connection) msg.getObjectHeaders().get(JdbcConstants.OBJ_METADATA_DATABASE_CONNECTION_KEY);
assertTrue(conn.isClosed());
// Here, we will expect there to be in row inserted.
// getCurrentSequenceNumber returns -1 in that instance, C-Styley
assertEquals(-1, getCurrentSequenceNumber(SequenceNumberCase.DEFAULT_ID));
} finally {
Thread.currentThread().setName(oldName);
}
}
use of com.adaptris.core.jdbc.DatabaseConnection in project interlok by adaptris.
the class DatabaseConnectionCase method testConnectWithDebugMode.
@Test
public void testConnectWithDebugMode() throws Exception {
DatabaseConnection conn = configure(createConnection());
conn.setDebugMode(true);
LifecycleHelper.init(conn);
conn.connect();
}
use of com.adaptris.core.jdbc.DatabaseConnection in project interlok by adaptris.
the class DatabaseConnectionCase method testSetConnectionRetryInterval.
@Test
public void testSetConnectionRetryInterval() throws Exception {
DatabaseConnection con = createConnection();
assertNull(con.getConnectionRetryInterval());
assertEquals(60000, con.connectionRetryInterval());
TimeInterval t = new TimeInterval(1L, TimeUnit.HOURS);
con.setConnectionRetryInterval(t);
assertEquals(t, con.getConnectionRetryInterval());
assertEquals(t.toMilliseconds(), con.connectionRetryInterval());
con.setConnectionRetryInterval(null);
assertNull(con.getConnectionRetryInterval());
assertEquals(60000, con.connectionRetryInterval());
}
use of com.adaptris.core.jdbc.DatabaseConnection 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.core.jdbc.DatabaseConnection in project interlok by adaptris.
the class DatabaseConnectionCase method testConnectWithoutAlwaysValidate.
@Test
public void testConnectWithoutAlwaysValidate() throws Exception {
DatabaseConnection conn = configure(createConnection());
conn.setAlwaysValidateConnection(false);
LifecycleHelper.init(conn);
conn.connect();
}
Aggregations