Class FileExtensionDataFileLoader
- All Implemented Interfaces:
DataFileLoader
DataFileLoader that dispatches to another DataFileLoader based on the
loaded file's extension: .xml to FlatXmlDataFileLoader, .json to
JsonDataFileLoader, .yaml/.yml to YamlDataFileLoader, and
.xls/.xlsx to XlsDataFileLoader.
.csv is deliberately not dispatched here: dbUnit's CSV format is
directory-based (CsvURLDataSet expects a directory
containing table-ordering.txt), so it cannot share this loader's
one-file-per-path convention. Use CsvDataFileLoader directly, pointed at a
directory, instead. Similarly, full (non-flat) XML has no extension of its own to
dispatch on; use FullXmlDataFileLoader directly.
The delegate loaders are used only for their loadDataSet(URL) method, so
this loader's own replacement objects and substrings - not any set on a delegate - are
the ones applied, exactly once, to every file regardless of format. Because that method
touches no delegate state, the delegates are shared static instances rather than
rebuilt for each FileExtensionDataFileLoader - one per test method, otherwise.
- Since:
- 3.6.0
- Author:
- Jeff Jensen
-
Constructor Summary
ConstructorsConstructorDescriptionCreate new instance.Create new instance with replacement objects.FileExtensionDataFileLoader(Map ro, Map rs) Create new instance with replacement objects and replacement substrings. -
Method Summary
Modifier and TypeMethodDescriptionloadDataSet(URL url) Load the specified URL file into a dbUnit dataset.Methods inherited from class org.dbunit.util.fileloader.AbstractDataFileLoader
addReplacementObjects, addReplacementSubstrings, load, processReplacementTokens, removeAllReplacementObjects, removeAllReplacementSubstrings
-
Constructor Details
-
FileExtensionDataFileLoader
public FileExtensionDataFileLoader()Create new instance. -
FileExtensionDataFileLoader
Create new instance with replacement objects.- Parameters:
ro- The replacement objects for use withReplacementDataSet.
-
FileExtensionDataFileLoader
Create new instance with replacement objects and replacement substrings.- Parameters:
ro- The replacement objects for use withReplacementDataSet.rs- The replacement substrings for use withReplacementDataSet.
-
-
Method Details
-
loadDataSet
Load the specified URL file into a dbUnit dataset. The type of dbUnit dataset created is delegated to the implementing subclass.- Parameters:
url- The dbUnit data file url.- Returns:
- dbUnit dataset of the corresponding input file type.
- Throws:
DataSetException- On data errors.IOException- On file errors.
-