//collect test case information
String folder = "";
String scenario = "";
String script = "";
//DateTimeValue scriptDateTime = null;
NodeListImpl inputFiles = new NodeListImpl();
NodeListImpl outputFiles = new NodeListImpl();
ElementImpl contextItem = null;
NodeListImpl modules = new NodeListImpl();
String expectedError = "";
String name = null;
NodeList childNodes = TC.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
switch (child.getNodeType()) {
case Node.ATTRIBUTE_NODE:
name = ((Attr)child).getName();
if (name.equals("FilePath"))
folder = ((Attr)child).getValue();
else if (name.equals("scenario"))
scenario = ((Attr)child).getValue();
break;
case Node.ELEMENT_NODE:
name = ((ElementImpl) child).getLocalName();
if (name.equals("query")) {
ElementImpl el = ((ElementImpl) child);
script = el.getAttribute("name");
//scriptDateTime = new DateTimeValue(el.getAttribute("date"));
}
else if (name.equals("input-file"))
inputFiles.add(child);
else if (name.equals("output-file"))
outputFiles.add(child);
else if (name.equals("contextItem"))
contextItem = (ElementImpl)child;
else if (name.equals("module"))
modules.add(child);
else if (name.equals("expected-error"))
expectedError = ((ElementImpl) child).getNodeValue();
break;
default :
;
}
}
Sequence result = null;
//compile & evaluate
File caseScript = new File(XQTS_folder+"Queries/XQuery/"+folder, script+".xq");
try {
XQueryContext context;
context = xquery.newContext(AccessContext.TEST);
//map modules' namespaces to location
Map<String, String> moduleMap = (Map<String, String>)broker.getConfiguration().getProperty(XQueryContext.PROPERTY_STATIC_MODULE_MAP);
for (int i = 0; i < modules.getLength(); i++) {
ElementImpl module = (ElementImpl)modules.item(i);
String id = module.getNodeValue();
moduleMap.put(module.getAttribute("namespace"), moduleSources.get(id));
}
broker.getConfiguration().setProperty(XQueryContext.PROPERTY_STATIC_MODULE_MAP, moduleMap);