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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertEquals(double[] a1, double[] a2, String message) static voidassertEquals(float[] a1, float[] a2, String message) protected voidassertSameOrDiff(String expected, String actual) static Liststatic Mapstatic Setstatic SortedMapbuildSortedMap(Object... kv) static SortedSetbuildSortedSet(Object... items) static voidstatic voidprotected <T> Set<jakarta.validation.ConstraintViolation<T>>checkValid(T object, boolean valid) protected Fileprotected voiddeleteDirectoryHierarchy(File root) protected StringRundiff(1)on two strings.static Randomprotected StringreadResource(File file) Read some file in as a UTF-8 encoded string.protected StringreadResource(String path) Read some classpath resource in as a UTF-8 encoded string.protected StringreadResource(URL url) Read some URL resource in as a UTF-8 encoded string.voidseedRandom(String randomSeed) voidprotected 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
-
assertSameOrDiff
-
diff
Rundiff(1)on two strings.- Parameters:
s1- first strings2- second string- Returns:
- the diff, or null if strings are the same
-