Package de.gebit.integrity.runner.providers

## Class InMemoryTestResourceProvider

- java.lang.Object
- - de.gebit.integrity.runner.providers.InMemoryTestResourceProvider

- All Implemented Interfaces:
    `TestResourceProvider`

      public class InMemoryTestResourceProvider
      extends Object
      implements TestResourceProvider

  This test resource provider holds the entire resources in memory and returns them from memory on demand. It is intended to be used to create fully self-sufficient clones of other resource providers (that typically just enumerate resources from external sources and load them on demand) which can then be transferred over the remoting connection to forks.
  Author:
    Rene Schneider - initial API and implementation

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `InMemoryTestResourceProvider()` | Default constructor for serialization.
    `InMemoryTestResourceProvider​(TestResourceProvider aSourceProvider, String aNamePrefix)` | Creates a new instance that acts as an in-memory copy of the given resource provider.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `closeResource​(TestResource aResourceName, InputStream aResourceStream)` | Closes a specified resources' stream (and all the stuff opened for this stream in the background).
    `ClassLoader` | `getClassLoader()` | Returns the classloader to use for all dynamic class resolving needs.
    `TestResource[]` | `getResourceNames()` | Returns all known resource names.
    `InputStream` | `openResource​(TestResource aResourceName)` | Opens a specific named resource.
    `void` | `setClassLoader​(ClassLoader aClassLoader)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### InMemoryTestResourceProvider

          public InMemoryTestResourceProvider()

      Default constructor for serialization.

    - #### InMemoryTestResourceProvider

          public InMemoryTestResourceProvider​(TestResourceProvider aSourceProvider,
                                              String aNamePrefix)
                                       throws IOException

      Creates a new instance that acts as an in-memory copy of the given resource provider.
      Parameters:
        `aSourceProvider` - the provider that is to be copied
        `aNamePrefix` - a prefix to be added to all resource names on copy (if null, nothing is added)
      Throws:
        `IOException`

  - ### Method Detail

    - #### setClassLoader

          public void setClassLoader​(ClassLoader aClassLoader)

    - #### getClassLoader

          public ClassLoader getClassLoader()

      Description copied from interface: `TestResourceProvider`
      Returns the classloader to use for all dynamic class resolving needs.
      Specified by:
        `getClassLoader` in interface `TestResourceProvider`
      Returns:
        the classloader to use

    - #### getResourceNames

          public TestResource[] getResourceNames()

      Description copied from interface: `TestResourceProvider`
      Returns all known resource names.
      Specified by:
        `getResourceNames` in interface `TestResourceProvider`
      Returns:

    - #### openResource

          public InputStream openResource​(TestResource aResourceName)
                                   throws IOException

      Description copied from interface: `TestResourceProvider`
      Opens a specific named resource. This should return an `InputStream` at the start of the data of the respective resources, and it is only expected to work if the resource is one of those enumerated by a call to `TestResourceProvider.getResourceNames()`.
      Specified by:
        `openResource` in interface `TestResourceProvider`
      Parameters:
        `aResourceName` - the resource to be opened
      Returns:
        an `InputStream` to read the resource
      Throws:
        `IOException`

    - #### closeResource

          public void closeResource​(TestResource aResourceName,
                                    InputStream aResourceStream)
                             throws IOException

      Description copied from interface: `TestResourceProvider`
      Closes a specified resources' stream (and all the stuff opened for this stream in the background).
      Specified by:
        `closeResource` in interface `TestResourceProvider`
      Parameters:
        `aResourceName` - the resource to be closed
        `aResourceStream` - the resource stream to close
      Throws:
        `IOException`