Package org.dbunit.annotation.runtime
Class DataSetResourcePathResolver
java.lang.Object
org.dbunit.annotation.runtime.DataSetResourcePathResolver
Normalizes a dataset path from
org.dbunit.annotation's DbUnitPrep or
DbUnitExpected annotations into an absolute classpath resource path, the form
DataFileLoader.load(String) expects.
DataFileLoader.load(String) itself resolves a path without a leading /
relative to org/dbunit/util/fileloader/, not to the test class, so this
resolution has to happen before the loader is called at all.
Resolution order:
- A path already starting with
/- an absolute classpath path, used as-is. Always wins, so a shared file outside the base directory stays reachable. DbUnitConfig.dataSetBaseDir(), when set - prefixed to the path.- Otherwise - resolved relative to the test class's package.
- Since:
- 3.6.0
- Author:
- Jeff Jensen
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
DataSetResourcePathResolver
public DataSetResourcePathResolver()
-
-
Method Details
-
resolve
Resolvespathto an absolute classpath resource path.- Parameters:
path- The path to resolve, as written on@DbUnitPrepor@DbUnitExpected.testClass- The test class; used to resolve a path relative to its package.dataSetBaseDir- The configured base directory, ornull/empty when not set.- Returns:
- The absolute classpath resource path.
- Throws:
IllegalStateException- Ifpathisnull- e.g. aDataSetPathsProviderreturning an array containing anullelement.
-