Class TestToolkit

java.lang.Object
org.openjdk.jmc.test.TestToolkit

public final class TestToolkit extends Object
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 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 resources
      directory - resource directory
      indexFile - 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

      public static void assertEquals(IOResource expected, IOResource actual) throws IOException
      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 result
      actual - Actual result
      Throws:
      IOException - if the files could not be opened or located.
    • getProjectDirectory

      public static File getProjectDirectory(Class<?> clazz, String directoryName) throws IOException
      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 resources
      directoryName - directory to materialize
      fileName - name of resource to materialize
      Returns:
      materialized directory
      Throws:
      IOException