Package org.dellroad.stuff.test
Class TestSupport
java.lang.Object
org.dellroad.stuff.test.TestSupport
Base class for unit tests providing logging and random seed setup.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
assertSameOrDiff
(String expected, String actual) protected <T> Set<jakarta.validation.ConstraintViolation<T>>
checkValid
(T object, boolean valid) protected String
Rundiff(1)
on two strings.static Random
jakarta.validation.Validator
protected String
readResource
(File file) Read some file in as a UTF-8 encoded string.protected String
readResource
(String path) Read some classpath resource in as a UTF-8 encoded string.protected String
readResource
(URL url) Read some URL resource in as a UTF-8 encoded string.void
seedRandom
(String randomSeed)
-
Field Details
-
log
-
random
-
-
Constructor Details
-
TestSupport
public TestSupport()
-
-
Method Details
-
getValidator
public jakarta.validation.Validator getValidator() -
seedRandom
-
getRandom
-
checkValid
-
readResource
Read some file in as a UTF-8 encoded string.- Parameters:
file
- file to read from- Returns:
- contents of file
-
readResource
Read some classpath resource in as a UTF-8 encoded string.- Parameters:
path
- classpath resource to read from- Returns:
- contents of resource
-
readResource
Read some URL resource in as a UTF-8 encoded string.- Parameters:
url
- resource to read from- Returns:
- contents of resource
-
assertSameOrDiff
-
diff
Rundiff(1)
on two strings.- Parameters:
s1
- first strings2
- second string- Returns:
- the diff, or null if strings are the same
-