Annotation Type LoadWith

    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      String value
      The name of the factory method within the test class or in an external class to use to load the contents of the resource into an object.
    • Element Detail

      • value

        String value
        The name of the factory method within the test class or in an external class to use to load the contents of the resource into an object. The method must take a single InputStream or Reader argument, and an optional InjectionTarget or Class argument that represents the injection target or the target type respectively.

        If no arguments are specified in the factory method name, the following parameter types are tried:

        1. Reader and InjectionTarget
        2. Reader and Class
        3. Reader
        4. InputStream and InjectionTarget
        5. InputStream and Class
        6. InputStream

        A factory method within the test class must be static when used for static field or constructor parameter injection. It may be non-static when used for instance field or method parameter injection.

        A factory method in an external class must always be static, and must be referenced by fully qualified method name.

        Examples:

        • loadResource for a method in the test class; the same as loadResource(java.io.Reader, com.github.robtimus.junit.support.extension.InjectionTarget) if it exists, otherwise loadResource(java.io.Reader, java.lang.Class) if it exists, otherwise loadResource(java.io.Reader) if it exists, otherwise loadResource(java.io.InputStream, com.github.robtimus.junit.support.extension.InjectionTarget) if it exists, otherwise loadResource(java.io.InputStream, java.lang.Class) if it exists, otherwise loadResource(java.io.InputStream)
        • loadResource(java.io.Reader, com.github.robtimus.junit.support.extension.InjectionTarget) for a method in the test class that takes Reader and InjectionTarget arguments
        • loadResource(java.io.Reader, java.lang.Class) for a method in the test class that takes Reader and Class arguments
        • loadResource(java.io.Reader) for a method in the test class that takes a single Reader argument
        • loadResource(java.io.InputStream) for a method in the test class that takes a single Reader argument
        • com.github.robtimus.junit.support.extension.testresource.TestResourceLoaders#toString(java.io.Reader) for a method in an external class that takes a single Reader class
        • com.github.robtimus.junit.support.extension.testresource.TestResourceLoaders#toBytes(java.io.InputStream) for a method in an external class that takes a single InputStream class