Class TestSupport

java.lang.Object
org.dellroad.stuff.test.TestSupport

public abstract class TestSupport extends Object
Base class for unit tests providing logging and random seed setup.
  • Field Details

    • log

      protected final Logger log
    • random

      protected Random random
  • Constructor Details

    • TestSupport

      public TestSupport()
  • Method Details

    • getValidator

      public jakarta.validation.Validator getValidator()
    • seedRandom

      @BeforeClass public void seedRandom(String randomSeed)
    • getRandom

      public static Random getRandom(String randomSeed)
    • checkValid

      protected <T> Set<jakarta.validation.ConstraintViolation<T>> checkValid(T object, boolean valid)
    • readResource

      protected String readResource(File file)
      Read some file in as a UTF-8 encoded string.
      Parameters:
      file - file to read from
      Returns:
      contents of file
    • readResource

      protected String readResource(String path)
      Read some classpath resource in as a UTF-8 encoded string.
      Parameters:
      path - classpath resource to read from
      Returns:
      contents of resource
    • readResource

      protected String readResource(URL url)
      Read some URL resource in as a UTF-8 encoded string.
      Parameters:
      url - resource to read from
      Returns:
      contents of resource
    • assertSameOrDiff

      protected void assertSameOrDiff(String expected, String actual)
    • diff

      protected String diff(String s1, String s2)
      Run diff(1) on two strings.
      Parameters:
      s1 - first string
      s2 - second string
      Returns:
      the diff, or null if strings are the same