public abstract class AbstractDataSetLoader extends Object implements DataSetLoader
DataSetLoader
strategy.
Provides a Template Method based approach for loading
data using a
Spring resource loader
.getResourceLoader(java.lang.Class<?>)
,
getResourceLocations(java.lang.Class<?>, java.lang.String)
,
createDataSet(Resource)
Constructor and Description |
---|
AbstractDataSetLoader() |
Modifier and Type | Method and Description |
---|---|
protected abstract org.dbunit.dataset.IDataSet |
createDataSet(org.springframework.core.io.Resource resource)
Factory method used to create the
dataset |
protected org.springframework.core.io.ResourceLoader |
getResourceLoader(Class<?> testClass)
Gets the
ResourceLoader that will be used to load the dataset Resource s. |
protected String[] |
getResourceLocations(Class<?> testClass,
String location)
Get the resource locations that should be considered when attempting to load a dataset from the specified
location.
|
org.dbunit.dataset.IDataSet |
loadDataSet(Class<?> testClass,
String location)
Loads a
dataset from Resource s obtained from the specified location. |
public org.dbunit.dataset.IDataSet loadDataSet(Class<?> testClass, String location) throws Exception
dataset
from Resource
s obtained from the specified location. Each
location can be mapped to a number of potential resources
, the first
resource that exists
will be used. Resource
s are loaded using the
ResourceLoader
returned from getResourceLoader(java.lang.Class<?>)
.
If no resource can be found then null will be returned.
loadDataSet
in interface DataSetLoader
testClass
- The class under testlocation
- The location to loaddataset
or nullException
- If the dataset
cannot be loadedcreateDataSet(Resource)
,
java.lang.String)
protected org.springframework.core.io.ResourceLoader getResourceLoader(Class<?> testClass)
ResourceLoader
that will be used to load the dataset Resource
s.testClass
- The class under testprotected String[] getResourceLocations(Class<?> testClass, String location)
testClass
- The class under testlocation
- The source locationprotected abstract org.dbunit.dataset.IDataSet createDataSet(org.springframework.core.io.Resource resource) throws Exception
dataset
resource
- an existing resource that contains the dataset dataException
- if the dataset could not be loadedCopyright © 2016. All rights reserved.