use of com.yahoo.jdisc.http.filter.ResponseHeaderFilter in project vespa by vespa-engine.
the class FilterTestCase method requireThatResponseFilterChainIsRun.
@Test
public void requireThatResponseFilterChainIsRun() {
final ResponseFilter responseFilter1 = new ResponseHeaderFilter("foo", "bar");
final ResponseFilter responseFilter2 = mock(ResponseFilter.class);
final int statusCode = Response.Status.BAD_GATEWAY;
final Response response = new Response(statusCode);
final Request request = null;
ResponseFilterChain.newInstance(responseFilter1, responseFilter2).filter(response, request);
final ArgumentCaptor<Response> responseCaptor = ArgumentCaptor.forClass(Response.class);
verify(responseFilter2).filter(responseCaptor.capture(), any(Request.class));
assertThat(responseCaptor.getValue().getStatus(), is(statusCode));
assertThat(responseCaptor.getValue().headers().getFirst("foo"), is("bar"));
assertThat(response.getStatus(), is(statusCode));
assertThat(response.headers().getFirst("foo"), is("bar"));
}
Aggregations