summaryrefslogtreecommitdiffstats
path: root/luni/src/test/java/tests/xml/DomTest.java
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2010-11-29 16:01:57 -0800
committerJesse Wilson <jessewilson@google.com>2010-11-29 16:03:53 -0800
commit086fd0244a54fa5ecf13ea66d49b22b36d7d456e (patch)
tree243689dc9a328f2113075f004383a858a38844fa /luni/src/test/java/tests/xml/DomTest.java
parent1a3dfbe49a3dcd7c855972dadccb9226468359d5 (diff)
downloadlibcore-086fd0244a54fa5ecf13ea66d49b22b36d7d456e.zip
libcore-086fd0244a54fa5ecf13ea66d49b22b36d7d456e.tar.gz
libcore-086fd0244a54fa5ecf13ea66d49b22b36d7d456e.tar.bz2
Fix XML DOM test failures and close guard warnings.
Fix KxmlParser to capture the DTD's root element name, system ID and public ID. This is more robust than capturing the same in the pull-to-DOM adapter. Fix close guard warnings in XML tests. Close input streams of resource files. Don't catch exceptions only to call fail(). http://b/3090550 Change-Id: I7cfafde58cc28af79c48386a4d124803c8791328
Diffstat (limited to 'luni/src/test/java/tests/xml/DomTest.java')
-rw-r--r--luni/src/test/java/tests/xml/DomTest.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/luni/src/test/java/tests/xml/DomTest.java b/luni/src/test/java/tests/xml/DomTest.java
index eb3a842..0966c5d 100644
--- a/luni/src/test/java/tests/xml/DomTest.java
+++ b/luni/src/test/java/tests/xml/DomTest.java
@@ -1385,6 +1385,38 @@ public class DomTest extends TestCase {
assertEquals(root.getChildNodes().item(0), current);
}
+ public void testPublicIdAndSystemId() throws Exception {
+ document = builder.parse(new InputSource(new StringReader(
+ " <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\""
+ + " \"http://www.w3.org/TR/html4/strict.dtd\">"
+ + "<html></html>")));
+ doctype = document.getDoctype();
+ assertEquals("html", doctype.getName());
+ assertEquals("-//W3C//DTD HTML 4.01//EN", doctype.getPublicId());
+ assertEquals("http://www.w3.org/TR/html4/strict.dtd", doctype.getSystemId());
+ }
+
+ public void testSystemIdOnly() throws Exception {
+ document = builder.parse(new InputSource(new StringReader(
+ " <!DOCTYPE html SYSTEM \"http://www.w3.org/TR/html4/strict.dtd\">"
+ + "<html></html>")));
+ doctype = document.getDoctype();
+ assertEquals("html", doctype.getName());
+ assertNull(doctype.getPublicId());
+ assertEquals("http://www.w3.org/TR/html4/strict.dtd", doctype.getSystemId());
+ }
+
+ public void testSingleQuotedPublicIdAndSystemId() throws Exception {
+ document = builder.parse(new InputSource(new StringReader(
+ " <!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN'"
+ + " 'http://www.w3.org/TR/html4/strict.dtd'>"
+ + "<html></html>")));
+ doctype = document.getDoctype();
+ assertEquals("html", doctype.getName());
+ assertEquals("-//W3C//DTD HTML 4.01//EN", doctype.getPublicId());
+ assertEquals("http://www.w3.org/TR/html4/strict.dtd", doctype.getSystemId());
+ }
+
private class RecordingHandler implements UserDataHandler {
final Set<String> calls = new HashSet<String>();
public void handle(short operation, String key, Object data, Node src, Node dst) {