* @return the List containing quers.
* @exception JDOMException if there is an error consuming the message.
*/
public List parseXMLQueryFile(String queryScenarioID, File queryFile, String querySetID) throws IOException, JDOMException {
List<QueryTest> queries = new LinkedList();
// HashMap queryMap = new HashMap();
SAXBuilder builder = SAXBuilderHelper.createSAXBuilder(false);
Document queryDocument = builder.build(queryFile);
List queryElements = queryDocument.getRootElement().getChildren(TagNames.Elements.QUERY);
Iterator iter = queryElements.iterator();
while ( iter.hasNext() ) {
Element queryElement = (Element) iter.next();
String queryName = queryElement.getAttributeValue(TagNames.Attributes.NAME);
if ( queryElement.getChild(TagNames.Elements.EXCEPTION) == null ) {
String uniqueID = querySetID + "_" + queryName;
List<Element> parmChildren = queryElement.getChildren(TagNames.Elements.SQL);
if (parmChildren == null || parmChildren.isEmpty()) {
TestLogger.logDebug("======= Single QueryTest ");
QuerySQL sql = createQuerySQL(queryElement);
QueryTest q = new QueryTest(queryScenarioID, uniqueID, querySetID, new QuerySQL[] {sql}, false);
queries.add(q);
} else {
TestLogger.logDebug("======= QueryTest has multiple sql statements");
QuerySQL[] querysql = new QuerySQL[parmChildren.size()];
int c = 0;
final Iterator<Element> sqliter = parmChildren.iterator();
while ( sqliter.hasNext() ) {
final Element sqlElement = (Element) sqliter.next();
QuerySQL sql = createQuerySQL(sqlElement);
querysql[c] = sql;
c++;
}
QueryTest q = new QueryTest(queryScenarioID, uniqueID, querySetID, querysql, false);
queries.add(q);
}
// queryMap.put(queryName, query);
} else {
Element exceptionElement = queryElement.getChild(TagNames.Elements.EXCEPTION);
String exceptionType = exceptionElement.getChild(TagNames.Elements.CLASS).getTextTrim();
String uniqueID = querySetID + "_" + queryName;
QuerySQL sql = new QuerySQL(exceptionType, null);
QueryTest q = new QueryTest(queryScenarioID, uniqueID, querySetID, new QuerySQL[] {sql}, true);
queries.add(q);
// queryMap.put(queryName, exceptionType);
}
}