### Question:
TraceeEndpointInterceptor extends AbstractTraceeInterceptor implements EndpointInterceptor { @Override public boolean handleResponse(MessageContext messageContext, Object o) { serializeContextToSoapHeader(messageContext.getResponse(), OutgoingResponse); return true; } TraceeEndpointInterceptor();  TraceeEndpointInterceptor(final String profile);  TraceeEndpointInterceptor(final TraceeBackend backend, final String profile); @Override boolean handleRequest(MessageContext messageContext, Object o); @Override boolean handleResponse(MessageContext messageContext, Object o); @Override boolean handleFault(MessageContext messageContext, Object o); @Override void afterCompletion(MessageContext messageContext, Object o, Exception e);  }### Answer:
@Test public void catchJaxbExceptionOnRenderingAndReturnWithoutException() throws Exception { backend.put("our key", "is our value"); when(((SoapMessage) messageContext.getResponse()).getSoapHeader()).thenReturn(mock(SoapHeader.class)); unit.handleResponse(messageContext, new Object()); verify(((SoapMessage) messageContext.getResponse()).getSoapHeader()).getResult(); }
@Test public void renderTpicContextToResultForResponses() throws Exception { backend.put("our key", "is our value"); final StringWriter writer = new StringWriter(); final SoapHeader soapHeader = mock(SoapHeader.class); when(((SoapMessage) messageContext.getResponse()).getSoapHeader()).thenReturn(soapHeader); when(soapHeader.getResult()).thenReturn(new StreamResult(writer)); unit.handleResponse(messageContext, new Object()); assertThat(writer.toString(), containsString("<entry key=\"our key\">is our value</entry>")); }
@Test public void skipProcessingWithWrongMessageTypeOnResponse() throws Exception { when(messageContext.getResponse()).thenReturn(mock(WebServiceMessage.class)); unit.handleResponse(messageContext, new Object()); assertThat(backend.isEmpty(), is(true)); }