public void testGetHeightNoInput() { ImageReader reader = createReader(); int height = 0; try { height = reader.getHeight(0); fail("height read without imput"); } catch (IllegalStateException ignore) { } catch (IOException e) { fail("Could not read image height: " + e); } assertEquals("Wrong height reported", 0, height); }
public void testGetWidthNoInput() { ImageReader reader = createReader(); int width = 0; try { width = reader.getWidth(0); fail("Width read without imput"); } catch (IllegalStateException ignore) { } catch (IOException e) { fail("Could not read image width: " + e); } assertEquals("Wrong width reported", 0, width); }
public void testGetAspectratioNoInput() { ImageReader reader = createReader(); float aspect = 0f; try { aspect = reader.getAspectRatio(0); fail("aspect read without imput"); } catch (IllegalStateException ignore) { } catch (IOException e) { fail("Could not read image aspectratio" + e); } assertEquals("Wrong aspect aspectratio", 0f, aspect, 0f); }
public void testReadNoInput() { ImageReader reader = createReader(); // Do not set input BufferedImage image = null; try { image = reader.read(0); fail("Read image with no input"); } catch (IllegalStateException ignore) { } catch (IOException e) { fail("Image could not be read: " + e); } assertNull(image); }
public void testProviderCanReadNull() { boolean canRead = false; try { canRead = createProvider().canDecodeInput(null); } catch (IllegalArgumentException ignore) { } catch (RuntimeException e) { fail("RuntimeException other than IllegalArgumentException thrown: " + e); } catch (IOException e) { fail("Could not test data for read: " + e); } assertFalse("ImageReader can read null input", canRead); }
public void testReadNoInputWithParam() { ImageReader reader = createReader(); // Do not set input BufferedImage image = null; try { image = reader.read(0, reader.getDefaultReadParam()); fail("Read image with no input"); } catch (IllegalStateException ignore) { } catch (IOException e) { fail("Image could not be read: " + e); } assertNull(image); }
public void testSetDestinationOffsetNull() throws IOException { final ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); ImageReadParam param = reader.getDefaultReadParam(); try { param.setDestinationOffset(null); fail("Null offset not allowed"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().toLowerCase().contains("offset")); } }
public void testReadIndexOutOfBoundsWithParam() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); BufferedImage image = null; try { image = reader.read(99, reader.getDefaultReadParam()); fail("Read image with index out of bounds"); } catch (IndexOutOfBoundsException ignore) { } catch (IOException e) { fail("Image could not be read: " + e); } assertNull(image); }
public void testReadAsRenderedImageIndexNegative() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); RenderedImage image = null; try { image = reader.readAsRenderedImage(-1, reader.getDefaultReadParam()); fail("Read image with illegal index"); } catch (IndexOutOfBoundsException expected) { // Ignore } catch (IOException e) { fail("Image could not be read: " + e); } assertNull(image); }
public void testGetFormatName() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); String name = null; try { name = reader.getFormatName(); } catch (IOException e) { fail(e.getMessage()); } assertNotNull(name); }
public void testGetAspectratio() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); float aspect = 0f; try { aspect = reader.getAspectRatio(0); } catch (IOException e) { fail("Could not read image aspectratio" + e); } Dimension d = data.getDimension(0); assertEquals("Wrong aspect aspectratio", d.getWidth() / d.getHeight(), aspect, 0.001); }
public void testGetWidthIndexOutOfBounds() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); //int width = 0; try { /*width = */reader.getWidth(-1); // NOTE: Some readers (like the com.sun.imageio stuff) ignores // index in getWidth/getHeight for formats with only one image... //assertEquals("Wrong width reported", data.getDimension().width, width); } catch (IndexOutOfBoundsException ignore) { } catch (IOException e) { fail("Could not read image aspect ratio: " + e); } }
public void testReadWithSourceRegionParam() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); ImageReadParam param = reader.getDefaultReadParam(); param.setSourceRegion(new Rectangle(0, 0, 10, 10)); BufferedImage image = null; try { image = reader.read(0, param); } catch (IOException e) { fail("Image could not be read: " + e); } assertNotNull("Image was null!", image); assertEquals("Read image has wrong width: " + image.getWidth(), 10, image.getWidth()); assertEquals("Read image has wrong height: " + image.getHeight(), 10, image.getHeight()); }
public void testReadWithNullParam() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); BufferedImage image = null; try { image = reader.read(0, null); } catch (IOException e) { fail("Image could not be read: " + e); } assertNotNull("Image was null!", image); assertEquals("Read image has wrong width: " + image.getWidth(), data.getDimension(0).width, image.getWidth()); assertEquals("Read image has wrong height: " + image.getHeight(), data.getDimension(0).height, image.getHeight()); }
public void testGetHeight() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); int height = 0; try { height = reader.getHeight(0); } catch (IOException e) { fail("Could not read image height: " + e); } assertEquals("Wrong height reported", data.getDimension(0).height, height); }
public void testReadWithNewParam() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); BufferedImage image = null; try { image = reader.read(0, new ImageReadParam()); } catch (IOException e) { fail("Image could not be read: " + e); } assertNotNull("Image was null!", image); assertEquals("Read image has wrong width: " + image.getWidth(), data.getDimension(0).width, image.getWidth()); assertEquals("Read image has wrong height: " + image.getHeight(), data.getDimension(0).height, image.getHeight()); }
public void testGetWidth() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); int width = 0; try { width = reader.getWidth(0); } catch (IOException e) { fail("Could not read image width: " + e); } assertEquals("Wrong width reported", data.getDimension(0).width, width); }
public void testReadAsRenderedImage() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); RenderedImage image = null; try { image = reader.readAsRenderedImage(0, null); } catch (IOException e) { fail("Image could not be read: " + e); } assertNotNull("Image was null!", image); assertEquals("Read image has wrong width: " + image.getWidth(), data.getDimension(0).width, image.getWidth()); assertEquals("Read image has wrong height: " + image.getHeight(), data.getDimension(0).height, image.getHeight()); }
public void testReadWithDefaultParam() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); BufferedImage image = null; try { image = reader.read(0, reader.getDefaultReadParam()); } catch (IOException e) { fail("Image could not be read: " + e); } assertNotNull("Image was null!", image); assertEquals("Read image has wrong width: " + image.getWidth(), data.getDimension(0).width, image.getWidth()); assertEquals("Read image has wrong height: " + image.getHeight(), data.getDimension(0).height, image.getHeight()); }
public void testRemoveAllIIOReadProgressListenersMultiple() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); Mock mockListener = new Mock(IIOReadProgressListener.class); reader.addIIOReadProgressListener((IIOReadProgressListener) mockListener.proxy()); Mock mockListenerToo = new Mock(IIOReadProgressListener.class); reader.addIIOReadProgressListener((IIOReadProgressListener) mockListenerToo.proxy()); reader.removeAllIIOReadProgressListeners(); try { reader.read(0); } catch (IOException e) { fail("Could not read image"); } // Should not have called any methods... mockListener.verify(); mockListenerToo.verify(); }