Package io.permazen.test
Class TestSupport
java.lang.Object
io.permazen.test.TestSupport
- Direct Known Subclasses:
KVTestSupport
Base class for unit tests providing logging and random seed setup.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertEquals
(double[] a1, double[] a2, String message) static void
assertEquals
(float[] a1, float[] a2, String message) protected void
assertSameOrDiff
(String expected, String actual) protected static byte[]
protected static byte[][]
static List
static Map
static Set
static SortedMap
buildSortedMap
(Object... kv) static SortedSet
buildSortedSet
(Object... items) static void
static void
protected <T> Set<jakarta.validation.ConstraintViolation<T>>
checkValid
(T object, boolean valid) protected File
protected void
deleteDirectoryHierarchy
(File root) protected String
Rundiff(1)
on two strings.static Random
protected byte[]
randomBytes
(boolean allowNull) protected byte[]
randomBytes
(int minLength, int maxLength, boolean allowNull) 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.protected static String
s
(byte[] b) void
seedRandom
(String randomSeed) void
protected String
-
Field Details
-
log
-
validator
protected jakarta.validation.Validator validator -
random
-
-
Constructor Details
-
TestSupport
public TestSupport()
-
-
Method Details
-
setUpValidator
@BeforeClass public void setUpValidator() -
seedRandom
-
createTempDirectory
- Throws:
IOException
-
deleteDirectoryHierarchy
- Throws:
IOException
-
getRandom
-
checkValid
-
readResource
Read some file in as a UTF-8 encoded string.- Parameters:
file
- file to read- Returns:
- file content
-
readResource
Read some classpath resource in as a UTF-8 encoded string.- Parameters:
path
- classpath resource- Returns:
- file content
-
readResource
Read some URL resource in as a UTF-8 encoded string.- Parameters:
url
- resource URL- Returns:
- resource content
-
checkSet
-
checkMap
-
assertEquals
-
assertEquals
-
buildSet
-
buildSortedSet
-
buildList
-
buildMap
-
buildSortedMap
-
show
-
randomBytes
protected byte[] randomBytes(boolean allowNull) -
randomBytes
protected byte[] randomBytes(int minLength, int maxLength, boolean allowNull) -
ba
-
b
-
s
-
assertSameOrDiff
-
diff
Rundiff(1)
on two strings.- Parameters:
s1
- first strings2
- second string- Returns:
- the diff, or null if strings are the same
-