@Test public void testProcessShouldCompressResponseBodyAndSetContentTypeWhenResponseFISCompressionIsNeeded() { given(resp.getContentType()).willReturn(ACCEPT_VALUE_XML); given(req.getHeader(ACCEPT_HEADER_KEY)).willReturn(ACCEPT_VALUE_FASTINFOSET); given(fastInfosetCompressor.compress(any(ByteArrayInputStream.class))).willReturn(outputStream); given(outputStream.toByteArray()).willReturn(RESPONSE_BODY.getBytes()); byte[] actual = underTest.process(req, resp, RESPONSE_BODY.getBytes()); verify(resp).setContentType(ACCEPT_VALUE_FASTINFOSET); assertEquals(actual, RESPONSE_BODY.getBytes()); }
@Override public byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody) { ByteArrayInputStream inputStream = new ByteArrayInputStream(responseBody); byte[] result = responseBody; if (isFastInfoSetCompressionNeeded(req, resp)) { resp.setContentType(ACCEPT_VALUE_FASTINFOSET); result = compressResponseXmlToFastInfoset(inputStream); } return result; }
FastInfosetCompressorProcessor implements ResponseProcessor { @Override public byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody) { ByteArrayInputStream inputStream = new ByteArrayInputStream(responseBody); byte[] result = responseBody; if (isFastInfoSetCompressionNeeded(req, resp)) { resp.setContentType(ACCEPT_VALUE_FASTINFOSET); result = compressResponseXmlToFastInfoset(inputStream); } return result; } }
FastInfosetCompressorProcessor implements ResponseProcessor { @Override public byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody) { ByteArrayInputStream inputStream = new ByteArrayInputStream(responseBody); byte[] result = responseBody; if (isFastInfoSetCompressionNeeded(req, resp)) { resp.setContentType(ACCEPT_VALUE_FASTINFOSET); result = compressResponseXmlToFastInfoset(inputStream); } return result; }  }
FastInfosetCompressorProcessor implements ResponseProcessor { @Override public byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody) { ByteArrayInputStream inputStream = new ByteArrayInputStream(responseBody); byte[] result = responseBody; if (isFastInfoSetCompressionNeeded(req, resp)) { resp.setContentType(ACCEPT_VALUE_FASTINFOSET); result = compressResponseXmlToFastInfoset(inputStream); } return result; }  @Override byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody); }
FastInfosetCompressorProcessor implements ResponseProcessor { @Override public byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody) { ByteArrayInputStream inputStream = new ByteArrayInputStream(responseBody); byte[] result = responseBody; if (isFastInfoSetCompressionNeeded(req, resp)) { resp.setContentType(ACCEPT_VALUE_FASTINFOSET); result = compressResponseXmlToFastInfoset(inputStream); } return result; }  @Override byte[] process(final HttpServletRequest req, final HttpServletResponse resp, final byte[] responseBody);  }