Class ImageCompareTest

java.lang.Object
org.apache.batik.test.AbstractTest
org.apache.batik.test.svg.ImageCompareTest
All Implemented Interfaces:
Test

public class ImageCompareTest extends AbstractTest
This test does a pixel comparison of two images and passes if the two images are identical. It fails otherwise, producing a report describing why the two images are different.
Version:
$Id: ImageCompareTest.java 1808001 2017-09-11 09:51:29Z ssteiner $
  • Field Details

  • Constructor Details

    • ImageCompareTest

      public ImageCompareTest(String urlA, String urlB)
      This test makes a binary comparison of the two images (and not a pixel comparison). If the images are different, the test generates a report containing the two images and a delta images to help the user visualize the difference.
      Parameters:
      urlA - first image
      urlB - second image
  • Method Details

    • resolveURL

      protected URL resolveURL(String url)
      Resolves the input string as follows. + First, the string is interpreted as a file description. If the file exists, then the file name is turned into a URL. + Otherwise, the string is supposed to be a URL. If it is an invalid URL, an IllegalArgumentException is thrown.
    • initURLs

      protected void initURLs()
    • rumImpl

      public TestReport rumImpl() throws Exception
      Throws:
      Exception
    • buildCompareImage

      protected BufferedImage buildCompareImage(BufferedImage ref, BufferedImage gen)
    • imageToFile

      protected File imageToFile(BufferedImage img, String imageType) throws IOException
      Creates a temporary File into which the input image is saved.
      Throws:
      IOException
    • makeRandomFileName

      protected File makeRandomFileName(String imageType) throws IOException
      Creates a temporary File into which the input image is saved.
      Throws:
      IOException
    • buildDiffImage

      public static BufferedImage buildDiffImage(BufferedImage ref, BufferedImage gen)
      Builds a new BufferedImage that is the difference between the two input images
    • compare

      public static boolean compare(InputStream refStream, InputStream newStream) throws IOException
      Compare the two input streams
      Throws:
      IOException
    • getImage

      protected BufferedImage getImage(URL url)
      Loads an image from a URL