You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mk...@apache.org on 2005/06/08 15:25:35 UTC
cvs commit: xml-xalan/test/tests/api-gold/xalanj2 SecureProcessingTest.out
mkwan 2005/06/08 06:25:35
Modified: test/java/src/org/apache/qetest/xalanj2
FactoryFeatureTest.java
Added: test/tests/api/xalanj2 SecureProcessingTest.xml
SecureProcessingTest.xsl
test/tests/api-gold/xalanj2 SecureProcessingTest.out
Log:
Patch for XALANJ-2142
Add a new testcase to test the secure processing feature.
Revision Changes Path
1.6 +53 -3 xml-xalan/test/java/src/org/apache/qetest/xalanj2/FactoryFeatureTest.java
Index: FactoryFeatureTest.java
===================================================================
RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/xalanj2/FactoryFeatureTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FactoryFeatureTest.java 17 Feb 2004 17:31:48 -0000 1.5
+++ FactoryFeatureTest.java 8 Jun 2005 13:25:35 -0000 1.6
@@ -28,6 +28,7 @@
import java.util.Properties;
import java.util.Vector;
+import javax.xml.XMLConstants;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
@@ -37,6 +38,7 @@
import org.apache.qetest.OutputNameManager;
import org.apache.qetest.xsl.TraxDatalet;
import org.apache.xalan.processor.TransformerFactoryImpl;
+import org.apache.xml.utils.DefaultErrorHandler;
//-------------------------------------------------------------------------
@@ -58,7 +60,7 @@
/** Just initialize test name, comment, numTestCases. */
public FactoryFeatureTest()
{
- numTestCases = 3; // REPLACE_num
+ numTestCases = 4; // REPLACE_num
testName = "FactoryFeatureTest";
testComment = "Basic functionality test of various Factory configuration APIs";
}
@@ -298,6 +300,54 @@
reporter.testCaseClose();
return true;
}
+
+ /**
+ * Validate transforms with FEATURE_SECURE_PROCESSING on/off.
+ *
+ * @return false if we should abort the test; true otherwise
+ */
+ public boolean testCase4()
+ {
+ reporter.testCaseInit("Validate transforms with FEATURE_SECURE_PROCESSING on/off");
+
+ try
+ {
+ TransformerFactory factory = TransformerFactory.newInstance();
+
+ // The test xsl contains an extension function. The transformation is successful
+ // when FEATURE_SECURE_PROCESSING is set to false.
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
+
+ TraxDatalet datalet = new TraxDatalet();
+ datalet.setDescription("Test secure processing feature:");
+ datalet.setNames(inputDir + File.separator + "xalanj2", "SecureProcessingTest");
+ datalet.goldName = goldDir + File.separator + "xalanj2" + File.separator + "SecureProcessingTest.out";
+ datalet.outputName = outNames.nextName();
+ transformAndCheck(factory, datalet);
+
+ try
+ {
+ // TransformerException is thrown when FEATURE_SECURE_PROCESSING is set to true.
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ Transformer transformer = factory.newTransformer(datalet.getXSLSource());
+ transformer.setErrorListener(new DefaultErrorHandler());
+ transformer.transform(datalet.getXMLSource(), new StreamResult(datalet.outputName));
+ reporter.checkFail("Expected TransformerException not thrown when secure processing feature is set to true.");
+ }
+ catch (javax.xml.transform.TransformerException e)
+ {
+ reporter.checkPass("TransformerFactory with FEATURE_SECURE_PROCESSING set to true threw TransformerException: " + e.toString());
+ }
+ }
+ catch (Throwable t)
+ {
+ reporter.logThrowable(Logger.ERRORMSG, t, "Failed in secure processing feature test");
+ reporter.checkFail("Failed in secure processing feature test");
+ }
+
+ reporter.testCaseClose();
+ return true;
+ }
/**
1.1 xml-xalan/test/tests/api/xalanj2/SecureProcessingTest.xml
Index: SecureProcessingTest.xml
===================================================================
<?xml version="1.0"?>
<doc>
<num>2</num>
<num>4</num>
<num>6</num>
</doc>
1.1 xml-xalan/test/tests/api/xalanj2/SecureProcessingTest.xsl
Index: SecureProcessingTest.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:math="http://exslt.org/math">
<xsl:template match="/">
<xsl:value-of select="math:max(/doc/num)"/>
</xsl:template>
</xsl:stylesheet>
1.1 xml-xalan/test/tests/api-gold/xalanj2/SecureProcessingTest.out
Index: SecureProcessingTest.out
===================================================================
<?xml version="1.0" encoding="UTF-8"?>6
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org