@Test public void testSetDestinationTypeIllegal() throws IOException { final ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); List<ImageTypeSpecifier> illegalTypes = createIllegalTypes(reader.getImageTypes(0)); ImageReadParam param = reader.getDefaultReadParam(); for (ImageTypeSpecifier illegalType : illegalTypes) { param.setDestinationType(illegalType); try { reader.read(0, param); fail("Expected to throw exception with illegal type specifier"); } catch (IIOException | IllegalArgumentException expected) { // TODO: This is thrown by ImageReader.getDestination. But are we happy with that? String message = expected.getMessage().toLowerCase(); if (!(message.contains("destination") && message.contains("type") || message.contains("num source & dest bands differ"))) { // Allow this to bubble up, due to a bug in the Sun PNGImageReader throw expected; } } } reader.dispose(); }
reader.setInput(data.getInputStream()); List<ImageTypeSpecifier> illegalTypes = createIllegalTypes(reader.getImageTypes(0));
@Test public void testSetDestinationTypeIllegal() throws IOException { final ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); List<ImageTypeSpecifier> illegalTypes = createIllegalTypes(reader.getImageTypes(0)); ImageReadParam param = reader.getDefaultReadParam(); for (ImageTypeSpecifier illegalType : illegalTypes) { param.setDestinationType(illegalType); try { reader.read(0, param); fail("Expected to throw exception with illegal type specifier"); } catch (IIOException | IllegalArgumentException expected) { // TODO: This is thrown by ImageReader.getDestination. But are we happy with that? String message = expected.getMessage().toLowerCase(); if (!(message.contains("destination") && message.contains("type"))) { // Allow this to bubble up, du to a bug in the Sun PNGImageReader throw expected; } } } }
reader.setInput(data.getInputStream()); List<ImageTypeSpecifier> illegalTypes = createIllegalTypes(reader.getImageTypes(0));