use of com.adaptris.core.jdbc.DatabaseConnection in project interlok by adaptris.
the class JdbcServiceListTest method testServiceList_RuntimeExceptionRollsback.
@Test
public void testServiceList_RuntimeExceptionRollsback() throws Exception {
createDatabase();
JdbcServiceList service = createServiceCollection();
DatabaseConnection c = createJdbcConnection();
c.setAutoCommit(false);
service.setConnection(c);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
service.add(createSequenceNumberService(null, getName(), SequenceNumberCase.DEFAULT_ID));
service.add(new NullService() {
@Override
public void doService(AdaptrisMessage msg) throws ServiceException {
throw new RuntimeException("testServiceList_RuntimeExceptionRollsback");
}
});
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));
}
use of com.adaptris.core.jdbc.DatabaseConnection in project interlok by adaptris.
the class DatabaseConnectionCase method testConnectionWhenStarted.
@Test
public void testConnectionWhenStarted() throws Exception {
DatabaseConnection con = configure(createConnection());
LifecycleHelper.init(con);
LifecycleHelper.start(con);
con.connect();
}
use of com.adaptris.core.jdbc.DatabaseConnection in project interlok by adaptris.
the class DatabaseConnectionCase method testEquality.
@Test
public void testEquality() throws Exception {
DatabaseConnection conn1 = configure(createConnection());
DatabaseConnection conn2 = roundTrip(conn1, DefaultMarshaller.getDefaultMarshaller());
assertRoundtripEquality(conn1, conn2);
}
use of com.adaptris.core.jdbc.DatabaseConnection in project interlok by adaptris.
the class DatabaseConnectionCase method testConnectWithAlwaysValidate.
@Test
public void testConnectWithAlwaysValidate() throws Exception {
DatabaseConnection conn = configure(createConnection());
conn.setAlwaysValidateConnection(true);
LifecycleHelper.init(conn);
conn.connect();
}
use of com.adaptris.core.jdbc.DatabaseConnection in project interlok by adaptris.
the class DatabaseConnectionCase method testConnectionWhenClosed.
@Test
public void testConnectionWhenClosed() throws Exception {
DatabaseConnection con = configure(createConnection());
LifecycleHelper.init(con);
LifecycleHelper.start(con);
LifecycleHelper.stop(con);
LifecycleHelper.close(con);
try {
con.connect();
fail("Expected failure as not initialised");
} catch (Exception e) {
// Expected
;
}
}
Aggregations