@Override
    public void verifyImageResult(long numberOfImages, ImageResult lastResult, AsyncReport report) {
      assertNotNull(report.getException());

      Class<?> receviedType = report.getException().getClass();
      assertTrue(
          "Invalid exception type: " + receviedType,
          expectedException.isAssignableFrom(receviedType));
    }
    @Override
    public void verifyImageResult(long numberOfImages, ImageResult lastResult, AsyncReport report) {
      assertTrue("Must have received an image.", numberOfImages > 0);
      assertTrue("Unexpected report: " + report.toString(), report.isSuccess());

      BufferedImage lastImage = lastResult.getImage();
      assertEquals(TEST_IMG_WIDTH, lastImage.getWidth());
      assertEquals(TEST_IMG_HEIGHT, lastImage.getHeight());
      assertEquals(TEST_IMG_WIDTH, lastResult.getMetaData().getWidth());
      assertEquals(TEST_IMG_HEIGHT, lastResult.getMetaData().getHeight());
      assertTrue(lastResult.getMetaData().isComplete());
      assertTrue(lastResult.getMetaData() instanceof JavaIIOMetaData);

      checkTestImagePixels(lastResult.getImage());
    }
    @Override
    public void verifyImageResult(long numberOfImages, ImageResult lastResult, AsyncReport report) {
      assertTrue("Unexpected report: " + report.toString(), report.isCanceled());
      assertTrue(
          report.getException() == null
              || report.getException() instanceof OperationCanceledException);

      if (lastResult != null) {
        ImageMetaData metaData = lastResult.getMetaData();
        assertNotNull("meta-data should not be null if image has been received.", metaData);
        assertFalse(
            "The last image should nto be complete on successful cancel",
            lastResult.getMetaData().isComplete());

        BufferedImage lastImage = lastResult.getImage();
        if (lastImage != null) {
          assertEquals(TEST_IMG_WIDTH, lastImage.getWidth());
          assertEquals(TEST_IMG_HEIGHT, lastImage.getHeight());
        }
        assertEquals(TEST_IMG_WIDTH, lastResult.getMetaData().getWidth());
        assertEquals(TEST_IMG_HEIGHT, lastResult.getMetaData().getHeight());
      }
    }