SuppressFastInfosetCompression implements ResponseFormatter { @Override public byte[] formatResponse(WilmaHttpRequest wilmaRequest, HttpServletResponse resp, byte[] responseResource, ParameterList params) { String acceptHeader = wilmaRequest.getHeader(ACCEPT_HEADER_KEY); if (acceptHeader != null && acceptHeader.contains(ACCEPT_VALUE_FASTINFOSET)) { String existingHeaderContent = resp.getHeader(HEADER_KEY_SUPPRESS_ENCODING); String newHeaderContent = existingHeaderContent == null ? FASTINFOSET : existingHeaderContent + "," + FASTINFOSET; resp.addHeader(HEADER_KEY_SUPPRESS_ENCODING, newHeaderContent); } return responseResource; }  @Override byte[] formatResponse(WilmaHttpRequest wilmaRequest, HttpServletResponse resp,
                                 byte[] responseResource, ParameterList params);  }
@Test public void testFormatTemplateWithoutExistingHeader() { given(request.getHeader(SuppressFastInfosetCompression.ACCEPT_HEADER_KEY)).willReturn(SuppressFastInfosetCompression.ACCEPT_VALUE_FASTINFOSET); given(response.getHeader(SuppressFastInfosetCompression.HEADER_KEY_SUPPRESS_ENCODING)).willReturn(null); underTest.formatResponse(request, response, null, parameterMap); verify(response).addHeader(SuppressFastInfosetCompression.HEADER_KEY_SUPPRESS_ENCODING, SuppressFastInfosetCompression.FASTINFOSET); }
@Test public void testFormatTemplateWithExistingHeader() { given(request.getHeader(SuppressFastInfosetCompression.ACCEPT_HEADER_KEY)).willReturn(SuppressFastInfosetCompression.ACCEPT_VALUE_FASTINFOSET); given(response.getHeader(SuppressFastInfosetCompression.HEADER_KEY_SUPPRESS_ENCODING)).willReturn(ANY_HEADER_VALUE); underTest.formatResponse(request, response, null, parameterMap); verify(response).addHeader(SuppressFastInfosetCompression.HEADER_KEY_SUPPRESS_ENCODING, ANY_HEADER_VALUE + "," + SuppressFastInfosetCompression.FASTINFOSET); }