Map<String, String> inElements = new HashMap<String, String>();
inElements.put("{http://cxf.apache.org/greeter_control/types}noFaultDetail",
"{http://cxf.apache.org/greeter_control/types}faultDetail");
bus.getInInterceptors().add(transIn);
TransformOutInterceptor transOut = new TransformOutInterceptor();
Map<String, String> outElements = new HashMap<String, String>();
outElements.put("{http://cxf.apache.org/greeter_control/types}pingMe",
"{http://cxf.apache.org/greeter_control/types}dontPingMe");
transOut.setOutTransformElements(outElements);
bus.getOutInterceptors().add(transOut);
bus.getOutFaultInterceptors().add(transOut);
GreeterService gs = new GreeterService();
greeter = gs.getGreeterPort();
updateAddressPort(greeter, PORT);
LOG.fine("Created greeter client.");
// ping 1: request-response transformation
greeter.pingMe();
verifyPayload(logOut.getMessage(), "dontPingMe");
verifyPayload(logIn.getMessage(), "pingMeResponse");
verifyPayload(serverlogIn.getMessage(), "dontPingMe");
verifyPayload(serverlogOut.getMessage(), "pingMeResponse");
serverlogOut.cleaerMessage();
serverlogIn.cleaerMessage();
logOut.cleaerMessage();
logIn.cleaerMessage();
// ping 2: request-fault transformation
try {
greeter.pingMe();
} catch (Exception e) {
assertEquals("Pings succeed only every other time.", e.getMessage());
}
verifyPayload(logOut.getMessage(), "dontPingMe");
verifyPayload(logIn.getMessage(), "noFaultDetail");
verifyPayload(serverlogIn.getMessage(), "dontPingMe");
verifyPayload(serverlogOut.getMessage(), "noFaultDetail");
// ping 3: idle
greeter.pingMe();
serverlogOut.cleaerMessage();
serverlogIn.cleaerMessage();
logOut.cleaerMessage();
logIn.cleaerMessage();
// ping 4: request-fault transformation with skipOnFault
transOut.setSkipOnFault(true);
servertransOut.setSkipOnFault(true);
try {
greeter.pingMe();
} catch (Exception e) {
assertEquals("Pings succeed only every other time.", e.getMessage());