use of org.dbunit.dataset.stream.StreamingDataSet in project openmrs-core by openmrs.
the class BaseContextSensitiveTest method executeLargeDataSet.
/**
* Runs the large flat xml dataset. It does not cache the file as opposed to
* {@link #executeDataSet(String)}.
*
* @param datasetFilename
* @throws Exception
* @since 1.10
*/
public void executeLargeDataSet(String datasetFilename) throws Exception {
InputStream inputStream = null;
try {
final File file = new File(datasetFilename);
if (file.exists()) {
inputStream = new FileInputStream(datasetFilename);
} else {
inputStream = getClass().getClassLoader().getResourceAsStream(datasetFilename);
if (inputStream == null)
throw new FileNotFoundException("Unable to find '" + datasetFilename + "' in the classpath");
}
final FlatXmlProducer flatXmlProducer = new FlatXmlProducer(new InputSource(inputStream));
final StreamingDataSet streamingDataSet = new StreamingDataSet(flatXmlProducer);
final ReplacementDataSet replacementDataSet = new ReplacementDataSet(streamingDataSet);
replacementDataSet.addReplacementObject("[NULL]", null);
executeDataSet(replacementDataSet);
inputStream.close();
} finally {
IOUtils.closeQuietly(inputStream);
}
}
Aggregations