String targetFileName = getExportFileName(dataSetExport);
URL tablesDataSestUrl = JuUrl.resource().relativeTo(this.getTestClass()).get(dataSetExport.tablesDataSet());
if (tablesDataSestUrl == null) tablesDataSestUrl = JuUrl.resource(dataSetExport.tablesDataSet());
XmlOutputConverter xmlOutput = this.getDbDataUtil(emUtil).buildExport()
.addTablesByDataSet(tablesDataSestUrl, true)
.writeToXml();
doc = xmlOutput.getDocument();
if (dataSetExport.exportType() == ExportType.PHYSICAL) {
if (JuUtils.getJuPropertyChain().get("ju-testing.export.compareToResource", Boolean.class, true)) {
// Perform export in-memory and compare to resource
String resourcePrefix = this.dataSetConfigInfo.getResourcePrefix();
String resourcePath = resourcePrefix + "/" + targetFileName;
URL resourceUrl = JuUrl.singleResource(resourcePath);
String resourceString = new IOUtil().loadTextFromUrl(resourceUrl);
String xmlString = xmlOutput.getXmlString();
logger.debug("Comparing DB export to resource {}", resourceUrl);
Assert.assertEquals(resourceString, xmlString);
} else {
// Perform export to file
String targetDirName = this.dataSetConfigInfo.getResourceDirectoryFull();
// Create target directory
Path targetDirPath = Paths.get(this.getLocalRoot(), targetDirName);
Files.createDirectories(targetDirPath);
// Build file path
Path targetFilePath = targetDirPath.resolve(targetFileName);
xmlOutput.writeToXmlFile(targetFilePath);
}
} else if (dataSetExport.exportType() == ExportType.MEMORY) {
// Log XML
if (logger.isInfoEnabled()) {
XString xs = new XString(targetFileName);