@Test public void writesBody() throws Exception { TstServletOutputStream output = new TstServletOutputStream(); when(httpServletResponse.getOutputStream()).thenReturn(output); when(containerResponse.getEntity()).thenReturn("hello world"); when(containerResponse.getHttpHeaders()).thenReturn(new MultivaluedHashMap<>()); servletContainerResponseWriter.writeBody(containerResponse, new StringEntityProvider()); assertArrayEquals("hello world".getBytes(), output.getData()); }
@Override @SuppressWarnings({"unchecked"}) public void writeBody(GenericContainerResponse response, MessageBodyWriter entityWriter) throws IOException { if (servletResponse.isCommitted()) { return; } Object entity = response.getEntity(); if (entity != null) { OutputStream out = servletResponse.getOutputStream(); entityWriter.writeTo(entity, entity.getClass(), response.getEntityType(), null, response.getContentType(), response.getHttpHeaders(), out); out.flush(); } }
ServletContainerResponseWriter implements ContainerResponseWriter { @Override @SuppressWarnings({"unchecked"}) public void writeBody(GenericContainerResponse response, MessageBodyWriter entityWriter) throws IOException { if (servletResponse.isCommitted()) { return; } Object entity = response.getEntity(); if (entity != null) { OutputStream out = servletResponse.getOutputStream(); entityWriter.writeTo(entity, entity.getClass(), response.getEntityType(), null, response.getContentType(), response.getHttpHeaders(), out); out.flush(); } } }
ServletContainerResponseWriter implements ContainerResponseWriter { @Override @SuppressWarnings({"unchecked"}) public void writeBody(GenericContainerResponse response, MessageBodyWriter entityWriter) throws IOException { if (servletResponse.isCommitted()) { return; } Object entity = response.getEntity(); if (entity != null) { OutputStream out = servletResponse.getOutputStream(); entityWriter.writeTo(entity, entity.getClass(), response.getEntityType(), null, response.getContentType(), response.getHttpHeaders(), out); out.flush(); } } ServletContainerResponseWriter(HttpServletResponse response); }
ServletContainerResponseWriter implements ContainerResponseWriter { @Override @SuppressWarnings({"unchecked"}) public void writeBody(GenericContainerResponse response, MessageBodyWriter entityWriter) throws IOException { if (servletResponse.isCommitted()) { return; } Object entity = response.getEntity(); if (entity != null) { OutputStream out = servletResponse.getOutputStream(); entityWriter.writeTo(entity, entity.getClass(), response.getEntityType(), null, response.getContentType(), response.getHttpHeaders(), out); out.flush(); } } ServletContainerResponseWriter(HttpServletResponse response); @Override @SuppressWarnings({"unchecked"}) void writeBody(GenericContainerResponse response, MessageBodyWriter entityWriter); @Override void writeHeaders(GenericContainerResponse response); }
ServletContainerResponseWriter implements ContainerResponseWriter { @Override @SuppressWarnings({"unchecked"}) public void writeBody(GenericContainerResponse response, MessageBodyWriter entityWriter) throws IOException { if (servletResponse.isCommitted()) { return; } Object entity = response.getEntity(); if (entity != null) { OutputStream out = servletResponse.getOutputStream(); entityWriter.writeTo(entity, entity.getClass(), response.getEntityType(), null, response.getContentType(), response.getHttpHeaders(), out); out.flush(); } } ServletContainerResponseWriter(HttpServletResponse response); @Override @SuppressWarnings({"unchecked"}) void writeBody(GenericContainerResponse response, MessageBodyWriter entityWriter); @Override void writeHeaders(GenericContainerResponse response);  }