Revision: 218
http://xmlunit.svn.sourceforge.net/xmlunit/?rev=218&view=rev
Author: bodewig
Date: 2007-06-26 23:50:14 -0700 (Tue, 26 Jun 2007)
Log Message:
-----------
Test for Bug 1742826
Modified Paths:
--------------
trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Transform.java
Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Transform.java
===================================================================
--- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Transform.java 2007-05-29 12:44:41 UTC (rev 217)
+++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Transform.java 2007-06-27 06:50:14 UTC (rev 218)
@@ -39,7 +39,11 @@
import java.io.File;
import java.io.FileReader;
+import org.custommonkey.xmlunit.exceptions.ConfigurationException;
+
import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.URIResolver;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -116,6 +120,30 @@
assertEquals("<creepycrawly/>", transform.getResultString());
}
+ /**
+ * Issue 1742826
+ */
+ public void testURIResolverForStylesheet() throws Exception {
+ TestResolver tr = new TestResolver();
+ try {
+ XMLUnit.setURIResolver(tr);
+ String s = "<foo/>";
+ String xsl = test_Constants.XML_DECLARATION
+ + test_Constants.XSLT_START
+ + "<xsl:include href=\"urn:bar\"/>"
+ + test_Constants.XSLT_END;
+ try {
+ Transform transform = new Transform(s, xsl);
+ fail("should fail because of unknown include URI");
+ } catch (ConfigurationException tce) {
+ // expected exception
+ }
+ assertTrue("URIResolver has been called", tr.called);
+ } finally {
+ XMLUnit.setURIResolver(null);
+ }
+ }
+
private void assertNotEquals(Object expected, Object actual) {
if (expected.equals(actual)) {
fail("Expected " + expected + " different to actual!");
@@ -130,13 +158,6 @@
animal = new File(test_Constants.BASEDIR + "/tests/etc/animal.xsl");
}
- /**
- * Return the test suite containing this test
- */
- public static TestSuite suite(){
- return new TestSuite(test_Transform.class);
- }
-
private static String stripLineFeeds(String s) {
int index = s.indexOf(test_Constants.LINE_SEPARATOR);
while (index > -1) {
@@ -146,5 +167,14 @@
}
return s;
}
+
+ private static class TestResolver implements URIResolver {
+ private boolean called = false;
+
+ public Source resolve(String h, String b) {
+ called = true;
+ return null;
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|