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 voidcloseResource(TestResource aResourceName, InputStream aResourceStream)Closes a specified resources' stream (and all the stuff opened for this stream in the background).ClassLoadergetClassLoader()Returns the classloader to use for all dynamic class resolving needs.TestResource[]getResourceNames()Returns all known resource names.InputStreamopenResource(TestResource aResourceName)Opens a specific named resource.voidsetClassLoader(ClassLoader aClassLoader)
-
-
-
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 copiedaNamePrefix- 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:TestResourceProviderReturns the classloader to use for all dynamic class resolving needs.- Specified by:
getClassLoaderin interfaceTestResourceProvider- Returns:
- the classloader to use
-
getResourceNames
public TestResource[] getResourceNames()
Description copied from interface:TestResourceProviderReturns all known resource names.- Specified by:
getResourceNamesin interfaceTestResourceProvider- Returns:
-
openResource
public InputStream openResource(TestResource aResourceName) throws IOException
Description copied from interface:TestResourceProviderOpens a specific named resource. This should return anInputStreamat 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:
openResourcein interfaceTestResourceProvider- Parameters:
aResourceName- the resource to be opened- Returns:
- an
InputStreamto read the resource - Throws:
IOException
-
closeResource
public void closeResource(TestResource aResourceName, InputStream aResourceStream) throws IOException
Description copied from interface:TestResourceProviderCloses a specified resources' stream (and all the stuff opened for this stream in the background).- Specified by:
closeResourcein interfaceTestResourceProvider- Parameters:
aResourceName- the resource to be closedaResourceStream- the resource stream to close- Throws:
IOException
-
-