in java/src/org/apache/qetest/trax/SystemIdTest.java [201:451]
public boolean testCase1()
{
reporter.testCaseInit("Test various forms of XSL and XML systemIds to see what happens");
// The path the user gave us in inputDir:
// inputDir + "/" + TRAX_SUBDIR + "/" filename
String inputDirPath = inputDir.replace('\\', '/')
+ "/" + TRAX_SUBDIR + "/" + knownGoodBaseName;
//@todo: determine what type of path inputDir itself is:
// downwards relative, upwards relative, or absolute
// Assumed correct user.dir path (should be in xml-xalan\test):
// System.getProperty("user.dir") + "/tests/api/" + TRAX_SUBDIR
// user.dir in theory should always be absolute
String userDirPath = System.getProperty("user.dir").replace('\\', '/')
+ "/tests/api/" + TRAX_SUBDIR + "/" + knownGoodBaseName;
// Verify that user.dir is in the right place relative to
// the checked-in known-good files
String userDirExpected = EXPECTED_RESULT_UNKNOWN;
File f1 = new File(userDirPath + ".xsl");
File f2 = new File(userDirPath + ".xml");
if (f1.exists() && f2.exists())
{
// The known-good files are there, so expect we can use it
userDirExpected = EXPECTED_RESULT_DOTRANSFORM;
}
else
{
reporter.logWarningMsg("Known good files does not appear to exist at: "
+ userDirPath + ".xml/.xsl");
}
String xslTestIds[][] =
{
// { systemId to test,
// description of the test,
// expected XSL behavior or exception,
// expected XSL inner exception,
// expected XML behavior or exception,
// expected XML inner exception
// }
// Test variations on the inputDir specified by the
// user, to be able to do some adhoc testing
{ "file:///" + inputDirPath,
"file:///, user-specified inputDir, /blah1[1a]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
{ "file://localhost/" + inputDirPath,
"file://localhost/, user-specified inputDir, /blah[1b]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
{ inputDirPath,
"Just user-specified inputDir, /blah (works normally, if relative)[1c]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
// Test variations on the System user.dir; validation
// depends on if it's set correctly
{ "file:///" + userDirPath,
"file:///, System(user.dir), /blah (works normally)[2a]",
userDirExpected,
null,
userDirExpected,
null },
{ "file://localhost/" + userDirPath,
"file://localhost/, System(user.dir), /blah (works normally)[2b]",
userDirExpected,
null,
userDirExpected,
null },
{ userDirPath,
"Just System(user.dir), /blah[2c]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
// Absolute path with blank . step
{ "file:///" + System.getProperty("user.dir").replace('\\', '/')
+ "/tests/./api/" + TRAX_SUBDIR + "/" + knownGoodBaseName,
"file:///, System(user.dir), /./blah (???)[2d]",
userDirExpected,
null,
userDirExpected,
null },
// Absolute path with up/down steps
{ "file:///" + System.getProperty("user.dir").replace('\\', '/')
+ "/tests/../tests/api/" + TRAX_SUBDIR + "/" + knownGoodBaseName,
"file:///, System(user.dir), /updir/../downdir/blah (???)[2e]",
userDirExpected,
null,
userDirExpected,
null },
// Just relative paths, should work if user.dir correct
// Arguable: comment out for 2.0
{ "file:tests/api/" + TRAX_SUBDIR + "/" + knownGoodBaseName,
"Just file:/blah relative path[3a]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
{ "tests/api/" + TRAX_SUBDIR + "/" + knownGoodBaseName,
"Just /blah relative path[3b]",
userDirExpected,
null,
userDirExpected,
null },
// file://blah should be interperted as a hostname,
// not as a filename, and should fail
{ "file://" + userDirPath,
"file://, System(user.dir), /blah (causes hostname error)[4a]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
// Comment out for 2.0 due to SPR SCUU4SUQXU
/*
"javax.xml.transform.TransformerConfigurationException",
"java.net.UnknownHostException",
"javax.xml.transform.TransformerException",
"java.net.UnknownHostException" },
*/
{ "file://" + inputDirPath,
"file://, user-specified inputDir, /blah (causes hostname error)[4b]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
// Comment out for 2.0 due to SPR SCUU4SUQXU
/*
"javax.xml.transform.TransformerConfigurationException",
"java.net.UnknownHostException",
"javax.xml.transform.TransformerException",
"java.net.UnknownHostException" },
*/
// file://host.does.not.exist/blah should fail, here we
// can also validate the error message completely
{ "file://this.host.does.not.exist/" + userDirPath,
"file://this.host.does.not.exist/userDir/blah (causes hostname error)[4c]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
// Comment out for 2.0 due to SPR SCUU4SUQXU
/*
"javax.xml.transform.TransformerConfigurationException: this.host.does.not.exist",
"java.net.UnknownHostException: this.host.does.not.exist",
"javax.xml.transform.TransformerException: this.host.does.not.exist",
"java.net.UnknownHostException" },
*/
{ "file://this.host.does.not.exist/" + inputDirPath,
"file://this.host.does.not.exist/inputDir/blah (causes hostname error)[4d]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
// Comment out for 2.0 due to SPR SCUU4SUQXU
/*
"javax.xml.transform.TransformerConfigurationException: this.host.does.not.exist",
"java.net.UnknownHostException: this.host.does.not.exist",
"javax.xml.transform.TransformerException: this.host.does.not.exist",
"java.net.UnknownHostException" },
*/
// Too few leading slashes for the file: spec, probably error
{ "file:/" + userDirPath,
"file:/, System(user.dir), /blah (probable error)[5a]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
{ "file:/" + inputDirPath,
"file:/, user-specified inputDir, /blah (probable error)[5b]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
// No leading slashes for the file: spec, behavior is?
{ "file:" + userDirPath,
"file:, System(user.dir), /blah (probable error)[6a]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
{ "file:" + inputDirPath,
"file:, user-specified inputDir, /blah (probable error)[6b]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
// Using backslashes in the path portion is explicitly
// forbidden in the RFC, should give error
{ "file:///" + userDirPath.replace('/', '\\'),
"file:///, System(user.dir) \\blah, (backslashes are illegal)[7a]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null },
{ "file:///" + inputDirPath.replace('/', '\\'),
"file:///, user-specified inputDir \\blah (backslashes are illegal)[7b]",
EXPECTED_RESULT_UNKNOWN,
null,
EXPECTED_RESULT_UNKNOWN,
null }
};
for (int i = 0; i < xslTestIds.length; i++)
{
// Loop and attempt to do newTemplates() with each
testNewTemplatesWithSystemId(xslTestIds[i][0] + ".xsl", xslTestIds[i][1],
xslTestIds[i][2], xslTestIds[i][3]);
// Loop and attempt to do newTransformer() with each
// as well, since they have slightly different codepaths
testNewTransformerWithSystemId(xslTestIds[i][0] + ".xsl", xslTestIds[i][1],
xslTestIds[i][2], xslTestIds[i][3]);
// Loop and attempt to do a transform of an xml
// document with each, using known-good stylesheet
testTransformWithSystemId(xslTestIds[i][0] + ".xml", xslTestIds[i][1],
xslTestIds[i][4], xslTestIds[i][5]);
}
reporter.testCaseClose();
return true;
}