Class InMemoryTestResourceProvider
- java.lang.Object
-
- de.gebit.integrity.runner.providers.InMemoryTestResourceProvider
-
- All Implemented Interfaces:
TestResourceProvider
public class InMemoryTestResourceProvider extends java.lang.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, java.lang.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, java.io.InputStream aResourceStream)
Closes a specified resources' stream (and all the stuff opened for this stream in the background).java.lang.ClassLoader
getClassLoader()
Returns the classloader to use for all dynamic class resolving needs.TestResource[]
getResourceNames()
Returns all known resource names.java.io.InputStream
openResource(TestResource aResourceName)
Opens a specific named resource.void
setClassLoader(java.lang.ClassLoader aClassLoader)
-
-
-
Constructor Detail
-
InMemoryTestResourceProvider
public InMemoryTestResourceProvider()
Default constructor for serialization.
-
InMemoryTestResourceProvider
public InMemoryTestResourceProvider(TestResourceProvider aSourceProvider, java.lang.String aNamePrefix) throws java.io.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 copiedaNamePrefix
- a prefix to be added to all resource names on copy (if null, nothing is added)- Throws:
java.io.IOException
-
-
Method Detail
-
setClassLoader
public void setClassLoader(java.lang.ClassLoader aClassLoader)
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Description copied from interface:TestResourceProvider
Returns the classloader to use for all dynamic class resolving needs.- Specified by:
getClassLoader
in interfaceTestResourceProvider
- Returns:
- the classloader to use
-
getResourceNames
public TestResource[] getResourceNames()
Description copied from interface:TestResourceProvider
Returns all known resource names.- Specified by:
getResourceNames
in interfaceTestResourceProvider
- Returns:
-
openResource
public java.io.InputStream openResource(TestResource aResourceName) throws java.io.IOException
Description copied from interface:TestResourceProvider
Opens a specific named resource. This should return anInputStream
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 toTestResourceProvider.getResourceNames()
.- Specified by:
openResource
in interfaceTestResourceProvider
- Parameters:
aResourceName
- the resource to be opened- Returns:
- an
InputStream
to read the resource - Throws:
java.io.IOException
-
closeResource
public void closeResource(TestResource aResourceName, java.io.InputStream aResourceStream) throws java.io.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 interfaceTestResourceProvider
- Parameters:
aResourceName
- the resource to be closedaResourceStream
- the resource stream to close- Throws:
java.io.IOException
-
-