Package org.openrefine.util
Class TestUtils
- java.lang.Object
-
- org.openrefine.util.TestUtils
-
public class TestUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description TestUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertEqualsAsJson(String actual, String expected)Assert that two JSON strings are equal as JSON objects.static FilecreateTempDirectory(String name)Create a temporary directory.static FilecreateTempFile(String filename, String contents)Creates a temporary file with the given contents.static booleanequalAsJson(String a, String b)static voidisSerializedTo(Object o, String targetJson, com.fasterxml.jackson.databind.ObjectWriter writer)static voidjsonDiff(String a, String b)static <T> Set<T>set(T... values)
-
-
-
Method Detail
-
createTempDirectory
public static File createTempDirectory(String name) throws IOException
Create a temporary directory. NOTE: This is a quick and dirty implementation suitable for tests, not production code.- Parameters:
name-- Returns:
- Throws:
IOException
-
createTempFile
public static File createTempFile(String filename, String contents) throws IOException
Creates a temporary file with the given contents. This is useful in the case where Java's resource mechanism is not applicable, for instance when importing from files with Spark (as they need to be located by path, not using an InputStream).- Parameters:
filename- the filename of the temporary file to createcontents- the contents to write in the file- Returns:
- a {%class java.io.File} object, use
File.getAbsolutePath()to obtain its path. - Throws:
IOException
-
assertEqualsAsJson
public static void assertEqualsAsJson(String actual, String expected)
Assert that two JSON strings are equal as JSON objects.
-
isSerializedTo
public static void isSerializedTo(Object o, String targetJson, com.fasterxml.jackson.databind.ObjectWriter writer)
-
jsonDiff
public static void jsonDiff(String a, String b) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException
- Throws:
com.fasterxml.jackson.core.JsonParseExceptioncom.fasterxml.jackson.databind.JsonMappingException
-
set
@SafeVarargs public static <T> Set<T> set(T... values)
-
-