Package org.openjdk.jmc.test
Class TestToolkit
java.lang.Object
org.openjdk.jmc.test.TestToolkit
Toolkit containing utility function for finding test files and comparing them with each other. I
could use the FileLocator class, but I don't want to add a dependency on Eclipse.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertEquals(IOResource expected, IOResource actual) Asserts that two resource have the same textual content.static IOResourcegetNamedResource(Class<?> clazz, String directory, String fileName) static FilegetProjectDirectory(Class<?> clazz, String directoryName) Note: Only use this method in stand-alone programs, not in test cases.static IOResourceSetgetResourcesInDirectory(Class<?> clazz, String directory, String indexFile) static Filematerialize(Class<?> clazz, String directoryName, String fileName) Materializes a file from bundle into a temporary directory.
-
Method Details
-
getResourcesInDirectory
public static IOResourceSet getResourcesInDirectory(Class<?> clazz, String directory, String indexFile) throws IOException - Parameters:
clazz- use the class loader of this class to find and load resourcesdirectory- resource directoryindexFile- Resource file (relative to the directory) containing names of the resources (also relative to the directory) to be loaded. One resource name per line, leading and trailing whitespace will be trimmed. Empty lines and lines starting with '#' will be ignored.- Returns:
- a resource set
- Throws:
IOException
-
getNamedResource
public static IOResource getNamedResource(Class<?> clazz, String directory, String fileName) throws IOException - Throws:
IOException
-
assertEquals
Asserts that two resource have the same textual content. The resource are compared line by line and if the differ an Assert.fail is triggered.- Parameters:
expected- Expected resultactual- Actual result- Throws:
IOException- if the files could not be opened or located.
-
getProjectDirectory
Note: Only use this method in stand-alone programs, not in test cases.- Throws:
IOException
-
materialize
public static File materialize(Class<?> clazz, String directoryName, String fileName) throws IOException Materializes a file from bundle into a temporary directory.- Parameters:
clazz- use the class loader of this class to find resourcesdirectoryName- directory to materializefileName- name of resource to materialize- Returns:
- materialized directory
- Throws:
IOException
-