@Test
public void testFaultTransformSequence() throws Exception {
final QName serviceName = new QName("testFaultTransformSequence");
// Provide the service
MockHandler provider = new MockHandler() {
@Override
public void handleMessage(Exchange exchange) throws HandlerException {
Message fault = exchange.createMessage();
fault.setContent(new Exception("testFaultTransformSequence"));
exchange.sendFault(fault);
}
};
InOutOperation providerContract = new InOutOperation("faultOp",
JavaTypes.toMessageType(String.class), // input
JavaTypes.toMessageType(String.class), // output
JavaTypes.toMessageType(Exception.class)); // fault
InOutOperation consumerContract = new InOutOperation("faultOp",
JavaTypes.toMessageType(String.class), // input
JavaTypes.toMessageType(String.class), // output
JavaTypes.toMessageType(String.class)); // fault
_domain.registerService(serviceName, new InOutService(providerContract), provider);
_domain.getTransformerRegistry().addTransformer(new ExceptionToStringTransformer());
ServiceReference service = _domain.registerServiceReference(serviceName, new InOutService(consumerContract));
// Consume the service
Exchange exchange = service.createExchange(new MockHandler());
exchange.send(exchange.createMessage());
// Make sure the exchange is in fault status
Assert.assertEquals(String.class, exchange.getMessage().getContent().getClass());
Assert.assertEquals(exchange.getMessage().getContent(), "testFaultTransformSequence");