use of com.adaptris.core.NullService in project interlok by adaptris.
the class SharedServiceConfigurationCheckerTest method testServiceConnectionDoesNotExist.
@Test
public void testServiceConnectionDoesNotExist() throws Exception {
BootstrapProperties mockBootProperties = new MockBootProperties(createAdapterConfig(new NullService("SharedNullConnection"), new SharedService("DoesNotExist")));
ConfigurationCheckReport report = checker.performConfigCheck(mockBootProperties);
assertFalse(report.isCheckPassed());
assertTrue(report.getFailureExceptions().size() > 0);
assertNotNull(report.toString());
}
use of com.adaptris.core.NullService in project interlok by adaptris.
the class SharedServiceConfigurationCheckerTest method testSharedNotUsed.
@Test
public void testSharedNotUsed() throws Exception {
BootstrapProperties mockBootProperties = new MockBootProperties(createAdapterConfig(new NullService("SharedNullService"), null));
ConfigurationCheckReport report = checker.performConfigCheck(mockBootProperties);
assertFalse(report.isCheckPassed());
}
use of com.adaptris.core.NullService in project interlok by adaptris.
the class IfElseTest method testNoThenService.
@Test
public void testNoThenService() throws Exception {
logicalExpression.getThen().setService(new NullService());
when(mockCondition.evaluate(message)).thenReturn(true);
// purely to re-initiate the NoOpService
LifecycleHelper.stopAndClose(logicalExpression);
LifecycleHelper.initAndStart(logicalExpression);
logicalExpression.doService(message);
verify(mockElseService, times(0)).doService(message);
}
use of com.adaptris.core.NullService in project interlok by adaptris.
the class JdbcServiceListTest method testServiceList_NoConnectionInObjectMetadata_WithException.
@Test
public void testServiceList_NoConnectionInObjectMetadata_WithException() throws Exception {
createDatabase();
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
JdbcServiceList list = new JdbcServiceList();
list.add(createSequenceNumberService(createJdbcConnection(), getName(), SequenceNumberCase.DEFAULT_ID));
list.add(new NullService() {
@Override
public void doService(AdaptrisMessage msg) throws ServiceException {
throw new ServiceException("testServiceList_NoConnectionInObjectMetadata_WithException throws an Exception");
}
});
try {
execute(list, msg);
} catch (ServiceException expected) {
//
}
// This checks the database has been commited, as the next seq_no == 2.
doStandardAssertions(msg);
assertFalse(msg.getObjectHeaders().containsKey(JdbcConstants.OBJ_METADATA_DATABASE_CONNECTION_KEY));
}
use of com.adaptris.core.NullService 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);
}
}
Aggregations