@Test public void testResize_acceptServeHugeImages() throws Exception { byte[] imageBytes = getImageBytes(HUGE_IMAGE); HttpResponseBuilder response = getImageResponse(CONTENT_TYPE_GIF, imageBytes); HttpRequest request = getMockRequest(null, null, null, false); mockControl.replay(); rewriter.rewrite(request, response); mockControl.verify(); assertEquals(HttpResponse.SC_OK, response.getHttpStatusCode()); assertTrue(Arrays.equals(imageBytes, IOUtils.toByteArray(response.getContentBytes()))); }
@Test public void testResize_acceptServeHugeImages() throws Exception { byte[] imageBytes = getImageBytes(HUGE_IMAGE); HttpResponseBuilder response = getImageResponse(CONTENT_TYPE_GIF, imageBytes); HttpRequest request = getMockRequest(null, null, null, false); mockControl.replay(); rewriter.rewrite(request, response, null); mockControl.verify(); assertEquals(HttpResponse.SC_OK, response.getHttpStatusCode()); assertTrue(Arrays.equals(imageBytes, IOUtils.toByteArray(response.getContentBytes()))); }
@Test public void testResize_acceptServeHugeImages() throws Exception { byte[] imageBytes = getImageBytes(HUGE_IMAGE); HttpResponseBuilder response = getImageResponse(CONTENT_TYPE_GIF, imageBytes); HttpRequest request = getMockRequest(null, null, null, false); mockControl.replay(); rewriter.rewrite(request, response, null); mockControl.verify(); assertEquals(HttpResponse.SC_OK, response.getHttpStatusCode()); assertTrue(Arrays.equals(imageBytes, IOUtils.toByteArray(response.getContentBytes()))); }
@Test public void testRewriteValidImageWithValidMimeAndExtn() throws Exception { byte[] bytes = getImageBytes("org/apache/shindig/gadgets/rewrite/image/inefficient.png"); HttpResponseBuilder response = getImageResponse(CONTENT_TYPE_PNG, bytes); int originalContentLength = response.getContentLength(); rewriter.rewrite(new HttpRequest(Uri.parse("some.png")), response); assertEquals(HttpResponse.SC_OK, response.getHttpStatusCode()); assertTrue(response.getContentLength() < originalContentLength); }
@Test public void testRewriteValidImageWithValidMimeAndExtn() throws Exception { byte[] bytes = getImageBytes("org/apache/shindig/gadgets/rewrite/image/inefficient.png"); HttpResponseBuilder response = getImageResponse(CONTENT_TYPE_PNG, bytes); int originalContentLength = response.getContentLength(); rewriter.rewrite(new HttpRequest(Uri.parse("some.png")), response, null); assertEquals(HttpResponse.SC_OK, response.getHttpStatusCode()); assertTrue(response.getContentLength() < originalContentLength); }
@Test public void testRewriteValidImageWithValidMimeAndExtn() throws Exception { byte[] bytes = getImageBytes("org/apache/shindig/gadgets/rewrite/image/inefficient.png"); HttpResponseBuilder response = getImageResponse(CONTENT_TYPE_PNG, bytes); int originalContentLength = response.getContentLength(); rewriter.rewrite(new HttpRequest(Uri.parse("some.png")), response, null); assertEquals(HttpResponse.SC_OK, response.getHttpStatusCode()); assertTrue(response.getContentLength() < originalContentLength); }