@Test
 public void testHandleResponseValidArticleMessage() throws Exception {
   exc.setRequest(requestTB);
   exc.setResponse(Response.ok().body(getContent("/articleResponse.xml")).build());
   assertEquals(
       Outcome.CONTINUE, createValidatorInterceptor(ARTICLE_SERVICE_WSDL).handleResponse(exc));
 }
 private Exchange getExchangeCP(String path) throws IOException {
   Exchange exc = new Exchange(null);
   exc.setResponse(
       Response.ok()
           .contentType("text/xml")
           .body(getClass().getClassLoader().getResourceAsStream(path), true)
           .build());
   return exc;
 }
  public void setResponse(Response res) {
    response = res;
    if (response != null) {
      response.setErrorMessage(errMessage);
    }

    for (IExchangeViewerListener listener : exchangeViewerListeners) {
      listener.addResponse(res);
    }
  }
  public void finishExchange(boolean refresh, String errmsg) {
    errMessage = errmsg;
    if (status != ExchangeState.COMPLETED) {
      status = ExchangeState.FAILED;
      forceToStop = true;
    }

    if (request != null) request.release();
    if (response != null) response.release();

    if (refresh) {
      notifyExchangeFinished();
    }
  }
  @Test
  public void doit() throws Exception {
    Exchange exc = new Exchange(null);
    exc.setResponse(
        Response.ok().header("a", "b").header("c", "d").header("c", "d2").header("e", "f").build());

    HeaderFilterInterceptor fhi = new HeaderFilterInterceptor();
    fhi.setRules(
        Lists.newArrayList(
            new Rule[] {
              new Rule("Server", Action.REMOVE), // implicitly set by Response.ok()
              new Rule("a", Action.KEEP),
              new Rule("c.*", Action.REMOVE),
            }));
    fhi.handleResponse(exc);

    HeaderField[] h = exc.getResponse().getHeader().getAllHeaderFields();
    assertEquals(3, h.length);
    assertEquals("Content-Length", h[0].getHeaderName().toString());
    assertEquals("a", h[1].getHeaderName().toString());
    assertEquals("e", h[2].getHeaderName().toString());
  }
 protected int estimateHeapSize() {
   return 2000
       + (originalRequestUri != null ? originalRequestUri.length() : 0)
       + (request != null ? request.estimateHeapSize() : 0)
       + (response != null ? response.estimateHeapSize() : 0);
 }