summaryrefslogtreecommitdiffstats
path: root/xml/src/test/java
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2009-09-23 17:01:24 -0700
committerElliott Hughes <enh@google.com>2009-09-25 11:03:05 -0700
commitab3721103266c7c9f58d5a9d32521a00a2c478d7 (patch)
tree1ee78ab44cdc790c0bca442182057c9f3242f4b4 /xml/src/test/java
parent0c071868fcbf5e61daeb5ee1ab55c6c2319cdf4a (diff)
downloadlibcore-ab3721103266c7c9f58d5a9d32521a00a2c478d7.zip
libcore-ab3721103266c7c9f58d5a9d32521a00a2c478d7.tar.gz
libcore-ab3721103266c7c9f58d5a9d32521a00a2c478d7.tar.bz2
Fix Node.getNextSibling bounds checking.
Obvious copy & paste error in InnerNodeImpl compared to LeafNodeImpl, plus new test. I've also fixed a typo that annoys me whenever I look at the XML test results, and removed a KnownFailure for a test that passes (and has been passing for some time). Bug: 779
Diffstat (limited to 'xml/src/test/java')
-rw-r--r--xml/src/test/java/tests/api/javax/xml/parsers/DocumentBuilderTest.java1
-rw-r--r--xml/src/test/java/tests/api/javax/xml/parsers/SAXParserTestSupport.java2
-rw-r--r--xml/src/test/java/tests/xml/AllTests.java1
-rw-r--r--xml/src/test/java/tests/xml/NodeTests.java47
4 files changed, 49 insertions, 2 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 c515d20..292c2f1 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
@@ -278,7 +278,6 @@ public class DocumentBuilderTest extends TestCase {
method = "parse",
args = {java.io.File.class}
)
- @KnownFailure("d.getChildNodes returns an unexpected/strange #Text node")
public void test_parseLjava_io_File() throws IOException {
File f = resourceToTmpFile("/simple.xml");
diff --git a/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserTestSupport.java b/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserTestSupport.java
index bc5e6a1..a1627ba 100644
--- a/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserTestSupport.java
+++ b/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserTestSupport.java
@@ -54,7 +54,7 @@ class SAXParserTestSupport {
public static final String KEY_ERROR = "error";
public static final String KEY_FATAL_ERROR = "fatalError";
public static final String KEY_WARNING = "warning";
- public static final String KEY_END_ELEMENT = "endEement";
+ public static final String KEY_END_ELEMENT = "endElement";
public static final String KEY_END_PREFIX_MAPPING = "endPrefixMapping";
public static final String KEY_IGNORABLE_WHITE_SPACE =
"ignorableWhitespace";
diff --git a/xml/src/test/java/tests/xml/AllTests.java b/xml/src/test/java/tests/xml/AllTests.java
index eefae50..8c089e3 100644
--- a/xml/src/test/java/tests/xml/AllTests.java
+++ b/xml/src/test/java/tests/xml/AllTests.java
@@ -26,6 +26,7 @@ public class AllTests {
suite.addTestSuite(SimpleParserTest.class);
suite.addTestSuite(SimpleBuilderTest.class);
+ suite.addTestSuite(NodeTests.class);
//suite.addTest(tests.org.w3c.dom.AllTests.suite());
suite.addTest(tests.api.javax.xml.parsers.AllTests.suite());
diff --git a/xml/src/test/java/tests/xml/NodeTests.java b/xml/src/test/java/tests/xml/NodeTests.java
new file mode 100644
index 0000000..e46e216
--- /dev/null
+++ b/xml/src/test/java/tests/xml/NodeTests.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.xml;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargetClass;
+
+import junit.framework.TestCase;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import java.io.ByteArrayInputStream;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+@TestTargetClass(Node.class)
+public class NodeTests extends TestCase {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL,
+ notes = "Issue #779: org.w3c.dom.Node#getNextSibling throws IndexOutOfBoundsException.",
+ method = "getNextSibling",
+ args = {}
+ )
+ public void test_getNextSibling() throws Exception {
+ // Calling getNextSibling when there is no next sibling should return null.
+ // From http://code.google.com/p/android/issues/detail?id=779.
+ ByteArrayInputStream bis = new ByteArrayInputStream("<root/>".getBytes());
+ Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bis);
+ Node root = document.getDocumentElement();
+ assertNull(root.getNextSibling());
+ }
+}