Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outbound) {
LogicalMessage msg = ctx.getMessage();
assertNotNull("logical message is null", msg);
JAXBContext jaxbCtx = JAXBContext.newInstance(GreetMe.class.getPackage().getName());
PingResponse resp = new PingResponse();
resp.getHandlersInfo().add(clientHandlerMessage);
msg.setPayload(resp, jaxbCtx);
}
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
return false;
}
};
addHandlersToChain((BindingProvider)handlerTest, handler1, handler2);
List<String> resp = handlerTest.ping();
assertEquals(clientHandlerMessage, resp.get(0));
assertEquals("handler must be invoked for inbound & outbound message",
2, handler1.getHandleMessageInvoked());
assertEquals("second handler must be invoked exactly once", 1, handler2.getHandleMessageInvoked());
assertTrue("close must be called", handler1.isCloseInvoked());