in java/src/org/apache/qetest/trax/SystemIdImpInclTest.java [187:348]
public boolean testCase1()
{
reporter.testCaseInit("Simple StreamSources with different setSystemIds");
TransformerFactory factory = null;
try
{
factory = TransformerFactory.newInstance();
}
catch (Throwable t)
{
reporter.checkFail("Problem creating factory; can't continue testcase");
reporter.logThrowable(reporter.ERRORMSG, t,
"Problem creating factory; can't continue testcase");
return true;
}
try
{
// Verify we can do basic transforms with readers/streams,
// with the 'normal' systemId
reporter.logInfoMsg("StreamSource.setSystemId(level1)");
InputStream xslStream1 = new FileInputStream(testFileInfo.inputName);
Source xslSource1 = new StreamSource(xslStream1);
xslSource1.setSystemId(QetestUtils.filenameToURL(testFileInfo.inputName));
InputStream xmlStream1 = new FileInputStream(testFileInfo.xmlName);
Source xmlSource1 = new StreamSource(xmlStream1);
xmlSource1.setSystemId(QetestUtils.filenameToURL(testFileInfo.xmlName));
reporter.logTraceMsg("Create FileOutputStream to " + outNames.nextName());
FileOutputStream fos1 = new FileOutputStream(outNames.currentName());
Result result1 = new StreamResult(fos1);
Templates templates1 = factory.newTemplates(xslSource1);
Transformer transformer1 = templates1.newTransformer();
reporter.logInfoMsg("About to transform, systemId(level1)");
transformer1.transform(xmlSource1, result1);
fos1.close(); // must close ostreams we own
if (Logger.PASS_RESULT
!= fileChecker.check(reporter,
new File(outNames.currentName()),
new File(goldFileLevel1),
"transform after setSystemId(level1) into " + outNames.currentName())
)
reporter.logInfoMsg("transform after setSystemId(level1)... failure reason:" + fileChecker.getExtendedInfo());
}
catch (Throwable t)
{
reporter.checkFail("Problem with setSystemId(level1)");
reporter.logThrowable(reporter.ERRORMSG, t, "Problem with after setSystemId(level1)");
}
try
{
// Verify we can do basic transforms with readers/streams,
// systemId set up one level
reporter.logInfoMsg("StreamSource.setSystemId(level0)");
InputStream xslStream1 = new FileInputStream(testFileInfo.inputName);
Source xslSource1 = new StreamSource(xslStream1);
xslSource1.setSystemId(QetestUtils.filenameToURL(inputDir + File.separator + knownGoodBaseName + ".xsl"));
InputStream xmlStream1 = new FileInputStream(testFileInfo.xmlName);
Source xmlSource1 = new StreamSource(xmlStream1);
xmlSource1.setSystemId(QetestUtils.filenameToURL(inputDir + File.separator + knownGoodBaseName + ".xml"));
reporter.logTraceMsg("Create FileOutputStream to " + outNames.nextName());
FileOutputStream fos1 = new FileOutputStream(outNames.currentName());
Result result1 = new StreamResult(fos1);
Templates templates1 = factory.newTemplates(xslSource1);
Transformer transformer1 = templates1.newTransformer();
reporter.logInfoMsg("About to transform, systemId(level0)");
transformer1.transform(xmlSource1, result1);
fos1.close(); // must close ostreams we own
if (Logger.PASS_RESULT
!= fileChecker.check(reporter,
new File(outNames.currentName()),
new File(goldFileLevel0),
"transform after setSystemId(level0) into " + outNames.currentName())
)
reporter.logInfoMsg("transform after setSystemId(level0)... failure reason:" + fileChecker.getExtendedInfo());
}
catch (Throwable t)
{
reporter.checkFail("Problem with setSystemId(level0)");
reporter.logThrowable(reporter.ERRORMSG, t, "Problem with setSystemId(level0)");
}
try
{
// Verify we can do basic transforms with readers/streams,
// with the systemId down one level
reporter.logInfoMsg("StreamSource.setSystemId(level2)");
InputStream xslStream1 = new FileInputStream(testFileInfo.inputName);
Source xslSource1 = new StreamSource(xslStream1);
xslSource1.setSystemId(QetestUtils.filenameToURL(inputDir + "/trax/systemid/" + knownGoodBaseName + ".xsl"));
InputStream xmlStream1 = new FileInputStream(testFileInfo.xmlName);
Source xmlSource1 = new StreamSource(xmlStream1);
xmlSource1.setSystemId(QetestUtils.filenameToURL(inputDir + "/trax/systemid/" + knownGoodBaseName + ".xml"));
reporter.logTraceMsg("Create FileOutputStream to " + outNames.nextName());
FileOutputStream fos1 = new FileOutputStream(outNames.currentName());
Result result1 = new StreamResult(fos1);
Templates templates1 = factory.newTemplates(xslSource1);
Transformer transformer1 = templates1.newTransformer();
reporter.logInfoMsg("About to transform, systemId(level2)");
transformer1.transform(xmlSource1, result1);
fos1.close(); // must close ostreams we own
if (Logger.PASS_RESULT
!= fileChecker.check(reporter,
new File(outNames.currentName()),
new File(goldFileLevel2),
"transform after setSystemId(level2) into " + outNames.currentName())
)
reporter.logInfoMsg("transform after setSystemId(level2)... failure reason:" + fileChecker.getExtendedInfo());
}
catch (Throwable t)
{
reporter.checkFail("Problem with setSystemId(level2)");
reporter.logThrowable(reporter.ERRORMSG, t, "Problem with setSystemId(level2)");
}
try
{
// Verify we can do basic transforms with readers/streams,
// with the systemId down one level
reporter.logInfoMsg("StreamSource.setSystemId(xslonly level2)");
InputStream xslStream1 = new FileInputStream(testFileInfo.inputName);
Source xslSource1 = new StreamSource(xslStream1);
xslSource1.setSystemId(QetestUtils.filenameToURL(inputDir + "/trax/systemid/" + knownGoodBaseName + ".xsl"));
InputStream xmlStream1 = new FileInputStream(testFileInfo.xmlName);
Source xmlSource1 = new StreamSource(xmlStream1);
// Explicitly don't set the xmlId - shouldn't be needed
reporter.logTraceMsg("Create FileOutputStream to " + outNames.nextName());
FileOutputStream fos1 = new FileOutputStream(outNames.currentName());
Result result1 = new StreamResult(fos1);
Templates templates1 = factory.newTemplates(xslSource1);
Transformer transformer1 = templates1.newTransformer();
reporter.logInfoMsg("About to transform, systemId(xslonly level2)");
transformer1.transform(xmlSource1, result1);
fos1.close(); // must close ostreams we own
if (Logger.PASS_RESULT
!= fileChecker.check(reporter,
new File(outNames.currentName()),
new File(goldFileLevel2),
"transform after setSystemId(xslonly level2) into " + outNames.currentName())
)
reporter.logInfoMsg("transform after setSystemId(xslonly level2)... failure reason:" + fileChecker.getExtendedInfo());
}
catch (Throwable t)
{
reporter.checkFail("Problem with setSystemId(xslonly level2)");
reporter.logThrowable(reporter.ERRORMSG, t, "Problem with setSystemId(xslonly level2)");
}
reporter.testCaseClose();
return true;
}