try {
XMLQueryVisitationStrategy jstrat = new XMLQueryVisitationStrategy();
// Create root JDOM element
Element rootElement = new Element(TagNames.Elements.ROOT_ELEMENT);
// create a JDOM element for the results
Element resultElement = new Element(TagNames.Elements.QUERY_RESULTS);
// set the queryIDAttr on the exception element
resultElement.setAttribute(new Attribute(TagNames.Attributes.NAME,
queryID));
// set the querySQLAttr on the exception element
resultElement.setAttribute(new Attribute(TagNames.Attributes.VALUE,
sql));
// ---------------------
// Actual Exception
// ---------------------
// create a JDOM element from the actual exception object
// produce xml for the actualException and this to the
// exceptionElement
if (ex != null) {
Element actualExceptionElement = new Element(
TagNames.Elements.ACTUAL_EXCEPTION);
actualExceptionElement = XMLQueryVisitationStrategy
.jdomException(ex, actualExceptionElement);
resultElement.addContent(actualExceptionElement);
}
if (actualResult != null) {
// ------------------------------
// Got a ResultSet from server
// error was in comparing results
// ------------------------------
// --------------------------
// Actual Result - ResultSet
// --------------------------
// produce a JDOM element from the actual results object
Element actualResultsElement = new Element(
TagNames.Elements.ACTUAL_QUERY_RESULTS);
actualResultsElement = jstrat.produceMsg(actualResult,
actualResultsElement);
// add the results elements to the root element
resultElement.addContent(actualResultsElement);
// ---------------------
// Expected Results - ...
// ---------------------
// produce xml for the expected results
// Get expected results
Element expectedResult = new Element("bogus"); //$NON-NLS-1$
expectedResult = jstrat.parseXMLResultsFile(expectedResultFile,
expectedResult);
if (expectedResult.getChild(TagNames.Elements.SELECT) != null) {
//----------------------------------------------------------
// -
// Expected result was a ResultSet set element name to
// reflect
//----------------------------------------------------------
// -
expectedResult
.setName(TagNames.Elements.EXPECTED_QUERY_RESULTS);
} else {
//----------------------------------------------------------
// --
// Expected result was an exception set element name to
// reflect
//----------------------------------------------------------
// --
expectedResult
.setName(TagNames.Elements.EXPECTED_EXCEPTION);
}
resultElement.addContent(expectedResult);
} else {
// ---------------------
// Expected Results - ...
// ---------------------
// produce xml for the expected results
// Get expected results
Element expectedResult = new Element("bogus"); //$NON-NLS-1$
expectedResult = jstrat.parseXMLResultsFile(expectedResultFile,
expectedResult);
if (expectedResult.getChild(TagNames.Elements.SELECT) != null) {
//----------------------------------------------------------
// -
// Expected result was a ResultSet set element name to
// reflect
//----------------------------------------------------------
// -
expectedResult
.setName(TagNames.Elements.EXPECTED_QUERY_RESULTS);
} else {
//----------------------------------------------------------
// --
// Expected result was an exception set element name to
// reflect
//----------------------------------------------------------
// --
expectedResult
.setName(TagNames.Elements.EXPECTED_EXCEPTION);
}
resultElement.addContent(expectedResult);
}