@Test public void rasterizeToResponseDoesNothingIfNotHttpResponse() throws Exception { Response r = Mockito.mock(Response.class); when(this.container.getResponse()).thenReturn(r); this.mocker.getComponentUnderTest().rasterizeToResponse(VALID_SVG, 100, 200); Mockito.verifyZeroInteractions(r); }
@Override public void rasterizeToResponse(String content, int width, int height) throws IOException { if (!(this.container.getResponse() instanceof ServletResponse)) { return; } HttpServletResponse response = ((ServletResponse) this.container.getResponse()).getHttpServletResponse(); File result = rasterizeToTemporaryFile(content, width, height); if (result == null) { return; } response.setContentLength((int) result.length()); response.setContentType("image/png"); OutputStream os = response.getOutputStream(); FileUtils.copyFile(result, os); os.flush(); }
BatikSVGRasterizer implements SVGRasterizer { @Override public void rasterizeToResponse(String content, int width, int height) throws IOException { if (!(this.container.getResponse() instanceof ServletResponse)) { return; } HttpServletResponse response = ((ServletResponse) this.container.getResponse()).getHttpServletResponse(); File result = rasterizeToTemporaryFile(content, width, height); if (result == null) { return; } response.setContentLength((int) result.length()); response.setContentType("image/png"); OutputStream os = response.getOutputStream(); FileUtils.copyFile(result, os); os.flush(); } }
BatikSVGRasterizer implements SVGRasterizer { @Override public void rasterizeToResponse(String content, int width, int height) throws IOException { if (!(this.container.getResponse() instanceof ServletResponse)) { return; } HttpServletResponse response = ((ServletResponse) this.container.getResponse()).getHttpServletResponse(); File result = rasterizeToTemporaryFile(content, width, height); if (result == null) { return; } response.setContentLength((int) result.length()); response.setContentType("image/png"); OutputStream os = response.getOutputStream(); FileUtils.copyFile(result, os); os.flush(); }  }
BatikSVGRasterizer implements SVGRasterizer { @Override public void rasterizeToResponse(String content, int width, int height) throws IOException { if (!(this.container.getResponse() instanceof ServletResponse)) { return; } HttpServletResponse response = ((ServletResponse) this.container.getResponse()).getHttpServletResponse(); File result = rasterizeToTemporaryFile(content, width, height); if (result == null) { return; } response.setContentLength((int) result.length()); response.setContentType("image/png"); OutputStream os = response.getOutputStream(); FileUtils.copyFile(result, os); os.flush(); }  @Override File rasterizeToTemporaryFile(String content, int width, int height); @Override TemporaryResourceReference rasterizeToTemporaryResource(String content, int width, int height); @Override TemporaryResourceReference rasterizeToTemporaryResource(String content, int width, int height,
        DocumentReference targetContext); @Override void rasterizeToResponse(String content, int width, int height); }
BatikSVGRasterizer implements SVGRasterizer { @Override public void rasterizeToResponse(String content, int width, int height) throws IOException { if (!(this.container.getResponse() instanceof ServletResponse)) { return; } HttpServletResponse response = ((ServletResponse) this.container.getResponse()).getHttpServletResponse(); File result = rasterizeToTemporaryFile(content, width, height); if (result == null) { return; } response.setContentLength((int) result.length()); response.setContentType("image/png"); OutputStream os = response.getOutputStream(); FileUtils.copyFile(result, os); os.flush(); }  @Override File rasterizeToTemporaryFile(String content, int width, int height); @Override TemporaryResourceReference rasterizeToTemporaryResource(String content, int width, int height); @Override TemporaryResourceReference rasterizeToTemporaryResource(String content, int width, int height,
        DocumentReference targetContext); @Override void rasterizeToResponse(String content, int width, int height);  }