in java/src/org/apache/qetest/xsl/StylesheetTestletDriver.java [585:673]
public Vector buildDatalets(Vector files, File testLocation,
File outLocation, File goldLocation,
Hashtable goldFiles)
{
// Validate arguments
if ((null == files) || (files.size() < 1))
{
// Bad arguments, report it as an error
// Note: normally, this should never happen, since
// this class normally validates these arguments
// before calling us
reporter.logWarningMsg("buildDatalets null or empty file vector");
return null;
}
Vector v = new Vector(files.size());
// For every file in the vector, construct the matching
// out, gold, and xml/xsl files
for (Enumeration elements = files.elements();
elements.hasMoreElements(); /* no increment portion */ )
{
String file = null;
try
{
file = (String)elements.nextElement();
}
catch (ClassCastException cce)
{
// Just skip this entry
reporter.logWarningMsg("Bad file element found, skipping: " + cce.toString());
continue;
}
// Check if it's a normal .xsl file, or a .xml file
// (we assume .xml files are embedded tests!)
StylesheetDatalet d = new StylesheetDatalet();
if (file.endsWith(XML_EXTENSION))
{
d.xmlName = testLocation.getPath() + File.separator + file;
String fileNameRoot = file.substring(0, file.indexOf(XML_EXTENSION));
d.inputName = null;
d.outputName = outLocation.getPath() + File.separator + fileNameRoot + OUT_EXTENSION;
if (goldFiles != null && goldFiles.get(fileNameRoot) != null) {
d.goldName = goldLocation.getPath() + File.separator + goldFiles.get(fileNameRoot);
} else {
d.goldName = goldLocation.getPath() + File.separator + fileNameRoot + OUT_EXTENSION;
}
}
else if (file.endsWith(XSL_EXTENSION))
{
d.inputName = testLocation.getPath() + File.separator + file;
String fileNameRoot = file.substring(0, file.indexOf(XSL_EXTENSION));
d.paramName = testLocation.getPath() + File.separator + fileNameRoot + PARAM_EXTENSION;
d.xmlName = testLocation.getPath() + File.separator + fileNameRoot + XML_EXTENSION;
d.outputName = outLocation.getPath() + File.separator + fileNameRoot + OUT_EXTENSION;
d.goldName = goldLocation.getPath() + File.separator + fileNameRoot + OUT_EXTENSION;
if (goldFiles != null && goldFiles.get(fileNameRoot) != null) {
d.goldName = goldLocation.getPath() + File.separator + goldFiles.get(fileNameRoot);
} else {
d.goldName = goldLocation.getPath() + File.separator + fileNameRoot + OUT_EXTENSION;
}
}
else
{
// Hmmm - I'm not sure what we should do here
reporter.logWarningMsg("Unexpected test file found, skipping: " + file);
continue;
}
d.setDescription(file);
d.flavor = flavor;
// Also copy over our own testProps as it's
// options: this allows for future expansion
// of values in the datalet
d.options = new Properties(testProps);
// Optimization: put in a copy of our fileChecker, so
// that each testlet doesn't have to create it's own
// fileCheckers should not store state, so this
// shouldn't affect the testing at all
d.options.put("fileCheckerImpl", fileChecker);
if (traceMode != null) {
d.options.put(TransformWrapper.SET_PROCESSOR_ATTRIBUTES + "setTraceListener", d.outputName + LOG_EXTENSION);
}
v.addElement(d);
}
return v;
}