diff options
author | Jesse Wilson <jessewilson@google.com> | 2010-02-02 11:18:33 -0800 |
---|---|---|
committer | Jesse Wilson <jessewilson@google.com> | 2010-02-02 11:41:54 -0800 |
commit | c36982772a413bb14eb6d865013aac03544441d1 (patch) | |
tree | 404175aedfd01998f127939e6f15ad9cd8856055 /xml/src/test/java | |
parent | b47282849bbff57d5ec226845e2cafb1c4acae7e (diff) | |
download | libcore-c36982772a413bb14eb6d865013aac03544441d1.zip libcore-c36982772a413bb14eb6d865013aac03544441d1.tar.gz libcore-c36982772a413bb14eb6d865013aac03544441d1.tar.bz2 |
Restore our ability to parse an XML Document given a File argument
directly, rather than via a stream.
When I updated DocumentBuilder but not its subclass DocumentBuilderImpl,
some of the assumptions by DocumentBuilderImpl were violated.
Diffstat (limited to 'xml/src/test/java')
-rw-r--r-- | xml/src/test/java/tests/api/javax/xml/parsers/DocumentBuilderTest.java | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/xml/src/test/java/tests/api/javax/xml/parsers/DocumentBuilderTest.java b/xml/src/test/java/tests/api/javax/xml/parsers/DocumentBuilderTest.java index 292c2f1..02b6d80 100644 --- a/xml/src/test/java/tests/api/javax/xml/parsers/DocumentBuilderTest.java +++ b/xml/src/test/java/tests/api/javax/xml/parsers/DocumentBuilderTest.java @@ -16,40 +16,35 @@ package tests.api.javax.xml.parsers; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.logging.Logger; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - +import dalvik.annotation.KnownFailure; +import dalvik.annotation.TestLevel; +import dalvik.annotation.TestTargetClass; +import dalvik.annotation.TestTargetNew; import junit.framework.TestCase; - import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.EntityReference; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; import org.w3c.dom.Text; import org.xml.sax.EntityResolver; import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; - import tests.api.org.xml.sax.support.MethodLogger; import tests.api.org.xml.sax.support.MockHandler; import tests.api.org.xml.sax.support.MockResolver; -import dalvik.annotation.KnownFailure; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; -import dalvik.annotation.TestTargetNew; +import tests.util.TestEnvironment; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; @TestTargetClass(DocumentBuilder.class) public class DocumentBuilderTest extends TestCase { @@ -133,6 +128,8 @@ public class DocumentBuilderTest extends TestCase { DocumentBuilder db; protected void setUp() throws Exception { + TestEnvironment.reset(); + dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringElementContentWhitespace(true); @@ -266,6 +263,21 @@ public class DocumentBuilderTest extends TestCase { } /** + * Tests that the Base URI for the document is populated with the file URI. + */ + @TestTargetNew( + level = TestLevel.COMPLETE, + notes = "", + method = "parse", + args = {java.io.File.class} + ) + public void testGetBaseURI() throws IOException, SAXException { + File f = resourceToTmpFile("/simple.xml"); + Document d = db.parse(f); + assertTrue(d.getDocumentElement().getBaseURI().startsWith("file://")); + } + + /** * @tests javax.xml.parsers.DocumentBuilder#parse(java.io.File) * Case 1: Try to parse correct xml document. * Case 2: Try to call parse() with null argument. @@ -567,7 +579,6 @@ public class DocumentBuilderTest extends TestCase { method = "parse", args = {java.lang.String.class} ) - @KnownFailure("Android DocumentBuilder should support File sources") public void test_parseLjava_lang_String() { // case 1: Trivial use. File f = new File(getClass().getResource("/simple.xml").getFile()); |