private BufferedImage getResizedHttpResponseContent(String sourceContentType, String targetContentType, String imageName, Integer width, Integer height, Integer quality) throws Exception { return getResizedHttpResponseContent( sourceContentType, targetContentType, imageName, width, height, quality, false); }
private BufferedImage getResizedHttpResponseContent(String sourceContentType, String targetContentType, String imageName, Integer width, Integer height, Integer quality) throws Exception { return getResizedHttpResponseContent( sourceContentType, targetContentType, imageName, width, height, quality, false); }
@Test public void testResize_height() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_JPG, SCALE_IMAGE, null, 100, null); assertEquals(100, image.getWidth()); assertEquals(100, image.getHeight()); }
@Test public void testResize_wideImage() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_JPG, SCALE_IMAGE, 100, 50, null); assertEquals(100, image.getWidth()); assertEquals(50, image.getHeight()); }
@Test public void testResize_all() throws Exception { // The quality hint apparently has no effect on the result here BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_JPG, SCALE_IMAGE, 100, 100, 10); assertEquals(100, image.getWidth()); assertEquals(100, image.getHeight()); }
@Test public void testResize_noExpandImage() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_PNG /* still optimized */, EXPAND_IMAGE, 120, 60, null, true /* no expand */); assertEquals(60, image.getWidth()); assertEquals(30, image.getHeight()); }
@Test public void testResize_skipResizeHugeOutputImage() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_JPG, SCALE_IMAGE, 10000, 10000, null); assertEquals(500, image.getWidth()); assertEquals(500, image.getHeight()); }
@Test public void testResize_avoidFloatingPointRoundingProblems() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_PNG, RATIO_IMAGE, 171, 171, null, true); assertEquals(171, image.getWidth()); assertEquals(114, image.getHeight()); } }
@Test public void testResize_wideImage() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_JPG, SCALE_IMAGE, 100, 50, null); assertEquals(100, image.getWidth()); assertEquals(50, image.getHeight()); }
@Test public void testResize_skipResizeHugeOutputImage() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_JPG, SCALE_IMAGE, 10000, 10000, null); assertEquals(500, image.getWidth()); assertEquals(500, image.getHeight()); }
@Test public void testResize_brokenParameter() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_GIF, SCALE_IMAGE, -1, null, null); assertEquals(500, image.getWidth()); assertEquals(500, image.getHeight()); }
@Test public void testResize_width() throws Exception { BufferedImage image = getResizedHttpResponseContent(CONTENT_TYPE_GIF, CONTENT_TYPE_JPG, SCALE_IMAGE, 100 /* width */, null /* height */, null /* quality */); assertEquals(100, image.getWidth()); assertEquals(100, image.getHeight()); }
@Test public void testResize_all() throws Exception { // The quality hint apparently has no effect on the result here BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_JPG, SCALE_IMAGE, 100, 100, 10); assertEquals(100, image.getWidth()); assertEquals(100, image.getHeight()); }
@Test public void testResize_wideImage() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_JPG, SCALE_IMAGE, 100, 50, null); assertEquals(100, image.getWidth()); assertEquals(50, image.getHeight()); }
@Test public void testResize_skipResizeHugeOutputImage() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_JPG, SCALE_IMAGE, 10000, 10000, null); assertEquals(500, image.getWidth()); assertEquals(500, image.getHeight()); }
@Test public void testResize_height() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_JPG, SCALE_IMAGE, null, 100, null); assertEquals(100, image.getWidth()); assertEquals(100, image.getHeight()); }
@Test public void testResize_avoidFloatingPointRoundingProblems() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_PNG, RATIO_IMAGE, 171, 171, null, true); assertEquals(171, image.getWidth()); assertEquals(114, image.getHeight()); } }
@Test public void testResize_tallImage() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_JPG, SCALE_IMAGE, 50, 100, null); assertEquals(50, image.getWidth()); assertEquals(100, image.getHeight()); }
@Test public void testResize_noExpandImage() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_PNG /* still optimized */, EXPAND_IMAGE, 120, 60, null, true /* no expand */); assertEquals(60, image.getWidth()); assertEquals(30, image.getHeight()); }
@Test public void testResize_avoidFloatingPointRoundingProblems() throws Exception { BufferedImage image = getResizedHttpResponseContent( CONTENT_TYPE_GIF, CONTENT_TYPE_PNG, RATIO_IMAGE, 171, 171, null, true); assertEquals(171, image.getWidth()); assertEquals(114, image.getHeight()); } }