ScreenshotImage { public InputStream getAsStream() { if (image == null) { throw new IllegalStateException("image is null"); } return getInputStreamFromImage(image); } ScreenshotImage();  ScreenshotImage(BufferedImage image); boolean isImageCached(); BufferedImage get(); InputStream getAsStream(); @Override String toString();  }
@Test public void testGetAsStream() throws Exception { ScreenshotImage si = new ScreenshotImage(image); BufferedImage actual = ImageIO.read(si.getAsStream()); assertThat(ImageUtils.imageEquals(actual, image), is(true)); }