use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class ThrowExceptionServiceTest method testLastKnownExceptionAvailableException.
@Test
public void testLastKnownExceptionAvailableException() throws Exception {
ThrowExceptionService service = new ThrowExceptionService(new LastKnownException());
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.getObjectHeaders().put(CoreConstants.OBJ_METADATA_EXCEPTION, new ServiceException(CONFIGURED));
try {
execute(service, msg);
fail("Expected Exception");
} catch (ServiceException e) {
assertEquals(CONFIGURED, e.getMessage());
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class ThrowExceptionServiceTest method testExceptionFromMetadataConfiguredMessage.
@Test
public void testExceptionFromMetadataConfiguredMessage() throws Exception {
ThrowExceptionService service = new ThrowExceptionService(new ExceptionFromMetadata(CONFIGURED));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
try {
execute(service, msg);
fail("Expected Exception");
} catch (ServiceException e) {
assertEquals(CONFIGURED, e.getMessage());
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class ThrowExceptionServiceTest method testExceptionFromMetadataMetadataOverride.
@Test
public void testExceptionFromMetadataMetadataOverride() throws Exception {
ThrowExceptionService service = new ThrowExceptionService(new ExceptionFromMetadata(CONFIGURED, METADATA_KEY));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(METADATA_KEY, METADATA_VALUE);
try {
execute(service, msg);
fail("Expected Exception");
} catch (ServiceException e) {
assertEquals(METADATA_VALUE, e.getMessage());
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class MetadataIdentitySequenceNumberServiceTest method test_Failure.
@Test
public void test_Failure() throws Exception {
createDatabase();
AdaptrisMessage msg = createMessageForTests();
MetadataIdentitySequenceNumberService service = configureForTests(new MetadataIdentitySequenceNumberService() {
@Override
protected Connection getConnection(AdaptrisMessage msg) throws SQLException {
throw new SQLException();
}
}, true);
try {
execute(service, msg);
fail();
} catch (ServiceException ex) {
// pass
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class NamedParameterApplicatorTest method testParameterApplicatorServiceException.
@Test
public void testParameterApplicatorServiceException() throws Exception {
doThrow(new SQLException("Expected")).when(mockStatement).setObject(anyInt(), anyString());
try {
parameterApplicator.applyStatementParameters(message, mockStatement, parameters, twoParamSqlStatement);
fail("Should throw service exception.");
} catch (ServiceException ex) {
// expected
}
}
Aggregations