summaryrefslogtreecommitdiffstats
path: root/xml
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2010-03-29 13:52:17 -0700
committerJesse Wilson <jessewilson@google.com>2010-03-29 13:52:17 -0700
commit6e94ca64944375a1496f752c64503baeafca2bc4 (patch)
tree83afe0431af5772221e899376e5706388f370744 /xml
parent66a66f700738c07c7977cb023f8a7aa2b331af90 (diff)
parent63422f870ea0946e51eda3edfc3ff549eefb30c4 (diff)
downloadlibcore-6e94ca64944375a1496f752c64503baeafca2bc4.zip
libcore-6e94ca64944375a1496f752c64503baeafca2bc4.tar.gz
libcore-6e94ca64944375a1496f752c64503baeafca2bc4.tar.bz2
Merge commit '8812fdd7' into manualmerge
Conflicts: libcore/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserFactoryTest.java
Diffstat (limited to 'xml')
-rw-r--r--xml/src/test/java/tests/api/javax/xml/parsers/DocumentBuilderTest.java9
-rw-r--r--xml/src/test/java/tests/api/javax/xml/parsers/SAXParserFactoryTest.java53
-rw-r--r--xml/src/test/java/tests/api/javax/xml/parsers/SAXParserTest.java1
-rw-r--r--xml/src/test/java/tests/org/w3c/dom/CreateAttributeNS.java7
-rw-r--r--xml/src/test/java/tests/org/w3c/dom/CreateDocument.java8
-rw-r--r--xml/src/test/java/tests/org/w3c/dom/CreateElementNS.java7
-rw-r--r--xml/src/test/java/tests/org/w3c/dom/DocumentCreateAttributeNS.java8
-rw-r--r--xml/src/test/java/tests/org/w3c/dom/SetAttributeNS.java14
-rw-r--r--xml/src/test/java/tests/xml/DeclarationTest.java4
-rw-r--r--xml/src/test/java/tests/xml/DomTest.java11
-rw-r--r--xml/src/test/java/tests/xml/NodeTest.java11
-rw-r--r--xml/src/test/java/tests/xml/NormalizeTest.java2
-rw-r--r--xml/src/test/java/tests/xml/SaxTest.java2
13 files changed, 65 insertions, 72 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 ea77a65..2818460 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
@@ -44,6 +44,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
@TestTargetClass(DocumentBuilder.class)
public class DocumentBuilderTest extends TestCase {
@@ -563,8 +564,8 @@ public class DocumentBuilderTest extends TestCase {
)
public void test_parseLjava_lang_String() throws Exception {
// case 1: Trivial use.
- File f = new File(getClass().getResource("/simple.xml").getFile());
- Document d = db.parse(f.getAbsolutePath());
+ URL resource = getClass().getResource("/simple.xml");
+ Document d = db.parse(resource.toString());
assertNotNull(d);
// TBD getXmlEncoding() is not supported
// assertEquals("ISO-8859-1", d.getXmlEncoding());
@@ -592,8 +593,8 @@ public class DocumentBuilderTest extends TestCase {
// case 4: Try to parse incorrect xml file
try {
- f = new File(getClass().getResource("/wrong.xml").getFile());
- db.parse(f.getAbsolutePath());
+ resource = getClass().getResource("/wrong.xml");
+ db.parse(resource.toString());
fail("Expected SAXException was not thrown");
} catch (SAXException sax) {
// expected
diff --git a/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserFactoryTest.java b/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserFactoryTest.java
index b573dbd..d5bf289 100644
--- a/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserFactoryTest.java
+++ b/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserFactoryTest.java
@@ -176,6 +176,7 @@ public class SAXParserFactoryTest extends TestCase {
method = "newInstance",
args = {}
)
+ @KnownFailure("Dalvik doesn't honor system properties when choosing a SAX implementation")
public void test_newInstance() {
try {
SAXParserFactory dtf = SAXParserFactory.newInstance();
@@ -315,56 +316,18 @@ public class SAXParserFactoryTest extends TestCase {
method = "setNamespaceAware",
args = {boolean.class}
)
- public void test_setNamespaceAwareZ() {
+ public void test_setNamespaceAwareZ() throws Exception {
+ MyHandler mh = new MyHandler();
spf.setNamespaceAware(true);
- MyHandler mh = new MyHandler();
InputStream is = getClass().getResourceAsStream("/simple_ns.xml");
- try {
- spf.newSAXParser().parse(is, mh);
- } catch(javax.xml.parsers.ParserConfigurationException pce) {
- fail("ParserConfigurationException was thrown during parsing");
- } catch(org.xml.sax.SAXException se) {
- fail("SAXException was thrown during parsing");
- } catch(IOException ioe) {
- fail("IOException was thrown during parsing");
- } finally {
- try {
- is.close();
- } catch(Exception e) {}
- }
+ spf.newSAXParser().parse(is, mh);
+ is.close();
+
spf.setNamespaceAware(false);
is = getClass().getResourceAsStream("/simple_ns.xml");
- try {
- is = getClass().getResourceAsStream("/simple_ns.xml");
- spf.newSAXParser().parse(is, mh);
- } catch(javax.xml.parsers.ParserConfigurationException pce) {
- fail("ParserConfigurationException was thrown during parsing");
- } catch(org.xml.sax.SAXException se) {
- se.printStackTrace();
- fail("SAXException was thrown during parsing");
- } catch(IOException ioe) {
- fail("IOException was thrown during parsing");
- } finally {
- try {
- is.close();
- } catch(Exception ioee) {}
- }
- is = getClass().getResourceAsStream("/simple_ns.xml");
- try {
- spf.setNamespaceAware(true);
- spf.newSAXParser().parse(is, mh);
- } catch(javax.xml.parsers.ParserConfigurationException pce) {
- fail("ParserConfigurationException was thrown during parsing");
- } catch(org.xml.sax.SAXException se) {
- fail("SAXException was thrown during parsing");
- } catch(IOException ioe) {
- fail("IOException was thrown during parsing");
- } finally {
- try {
- is.close();
- } catch(Exception ioee) {}
- }
+ spf.newSAXParser().parse(is, mh);
+ is.close();
}
/* public void test_setSchemaLjavax_xml_validation_Schema() {
diff --git a/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserTest.java b/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserTest.java
index d44107b..a80c4e3 100644
--- a/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserTest.java
+++ b/xml/src/test/java/tests/api/javax/xml/parsers/SAXParserTest.java
@@ -668,6 +668,7 @@ public class SAXParserTest extends TestCase {
method = "parse",
args = {java.io.InputStream.class, org.xml.sax.helpers.DefaultHandler.class, java.lang.String.class}
)
+ @KnownFailure("We supply optional qnames, but this test doesn't expect them")
public void test_parseLjava_io_InputStreamLorg_xml_sax_helpers_DefaultHandlerLjava_lang_String() {
for(int i = 0; i < list_wf.length; i++) {
try {
diff --git a/xml/src/test/java/tests/org/w3c/dom/CreateAttributeNS.java b/xml/src/test/java/tests/org/w3c/dom/CreateAttributeNS.java
index c7e0d34..3cd0da6 100644
--- a/xml/src/test/java/tests/org/w3c/dom/CreateAttributeNS.java
+++ b/xml/src/test/java/tests/org/w3c/dom/CreateAttributeNS.java
@@ -218,12 +218,13 @@ public final class CreateAttributeNS extends DOMTestCase {
doc = (Document) load("hc_staff", builder);
- boolean success = false;
+ // BEGIN android-changed
+ // Our exception priorities differ from the spec
try {
doc.createAttributeNS(namespaceURI, "");
+ fail();
} catch (DOMException ex) {
- success = (ex.code == DOMException.NAMESPACE_ERR);
}
- assertTrue("throw_INVALID_CHARACTER_ERR", success);
+ // END android-changed
}
}
diff --git a/xml/src/test/java/tests/org/w3c/dom/CreateDocument.java b/xml/src/test/java/tests/org/w3c/dom/CreateDocument.java
index 157b394..8e1b175 100644
--- a/xml/src/test/java/tests/org/w3c/dom/CreateDocument.java
+++ b/xml/src/test/java/tests/org/w3c/dom/CreateDocument.java
@@ -305,13 +305,13 @@ public final class CreateDocument extends DOMTestCase {
domImpl = builder.getDOMImplementation();
- boolean success = false;
+ // BEGIN android-changed
+ // Our exception priorities differ from the spec
try {
domImpl.createDocument(namespaceURI, "", docType);
+ fail();
} catch (DOMException ex) {
- success = (ex.code == DOMException.NAMESPACE_ERR);
}
- assertTrue("throw_NAMESPACE_ERR", success);
-
+ // END android-changed
}
}
diff --git a/xml/src/test/java/tests/org/w3c/dom/CreateElementNS.java b/xml/src/test/java/tests/org/w3c/dom/CreateElementNS.java
index 8d8bb4d..6258936 100644
--- a/xml/src/test/java/tests/org/w3c/dom/CreateElementNS.java
+++ b/xml/src/test/java/tests/org/w3c/dom/CreateElementNS.java
@@ -239,13 +239,14 @@ public final class CreateElementNS extends DOMTestCase {
doc = (Document) load("hc_staff", builder);
{
- boolean success = false;
+ // BEGIN android-changed
+ // Our exception priorities differ from the spec
try {
doc.createElementNS(namespaceURI, "");
+ fail();
} catch (DOMException ex) {
- success = (ex.code == DOMException.NAMESPACE_ERR);
}
- assertTrue("throw_NAMESPACE_ERR", success);
+ // END android-changed
}
}
}
diff --git a/xml/src/test/java/tests/org/w3c/dom/DocumentCreateAttributeNS.java b/xml/src/test/java/tests/org/w3c/dom/DocumentCreateAttributeNS.java
index e46f3b3..87c8661 100644
--- a/xml/src/test/java/tests/org/w3c/dom/DocumentCreateAttributeNS.java
+++ b/xml/src/test/java/tests/org/w3c/dom/DocumentCreateAttributeNS.java
@@ -216,13 +216,15 @@ public final class DocumentCreateAttributeNS extends DOMTestCase {
qualifiedName = (String) qualifiedNames.get(indexN1004E);
{
- boolean success = false;
+
+ // BEGIN android-changed
+ // Our exception priorities differ from the spec
try {
doc.createAttributeNS(namespaceURI, qualifiedName);
+ fail();
} catch (DOMException ex) {
- success = (ex.code == DOMException.NAMESPACE_ERR);
}
- assertTrue("documentcreateattributeNS04", success);
+ // END android-changed
}
}
}
diff --git a/xml/src/test/java/tests/org/w3c/dom/SetAttributeNS.java b/xml/src/test/java/tests/org/w3c/dom/SetAttributeNS.java
index 58c146f..b1f24e9 100644
--- a/xml/src/test/java/tests/org/w3c/dom/SetAttributeNS.java
+++ b/xml/src/test/java/tests/org/w3c/dom/SetAttributeNS.java
@@ -126,14 +126,15 @@ public final class SetAttributeNS extends DOMTestCase {
testAddr = elementList.item(0);
{
- boolean success = false;
+ // BEGIN android-changed
+ // Our exception priorities differ from the spec
try {
((Element) /* Node */testAddr).setAttributeNS(namespaceURI,
qualifiedName, "newValue");
+ fail();
} catch (DOMException ex) {
- success = (ex.code == DOMException.NAMESPACE_ERR);
}
- assertTrue("throw_NAMESPACE_ERR", success);
+ // END android-changed
}
}
@@ -340,14 +341,15 @@ public final class SetAttributeNS extends DOMTestCase {
testAddr = elementList.item(0);
{
- boolean success = false;
+ // BEGIN android-changed
+ // Our exception priorities differ from the spec
try {
((Element) /* Node */testAddr).setAttributeNS(namespaceURI, "",
"newValue");
+ fail();
} catch (DOMException ex) {
- success = (ex.code == DOMException.NAMESPACE_ERR);
}
- assertTrue("throw_NAMESPACE_ERR", success);
+ // END android-changed
}
}
}
diff --git a/xml/src/test/java/tests/xml/DeclarationTest.java b/xml/src/test/java/tests/xml/DeclarationTest.java
index 8fea844..9fc42fe 100644
--- a/xml/src/test/java/tests/xml/DeclarationTest.java
+++ b/xml/src/test/java/tests/xml/DeclarationTest.java
@@ -16,6 +16,7 @@
package tests.xml;
+import dalvik.annotation.KnownFailure;
import junit.framework.TestCase;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
@@ -78,18 +79,21 @@ public class DeclarationTest extends TestCase {
assertEquals("ISO-8859-1", documentB.getInputEncoding());
}
+ @KnownFailure("Dalvik doesn't parse the XML declaration")
public void testGetXmlEncoding() throws Exception {
String message = "This implementation doesn't parse the encoding from the XML declaration";
assertEquals(message, "ISO-8859-1", documentA.getXmlEncoding());
assertEquals(message, "US-ASCII", documentB.getXmlEncoding());
}
+ @KnownFailure("Dalvik doesn't parse the XML declaration")
public void testGetXmlVersion() throws Exception {
String message = "This implementation doesn't parse the version from the XML declaration";
assertEquals(message, "1.0", documentA.getXmlVersion());
assertEquals(message, "1.1", documentB.getXmlVersion());
}
+ @KnownFailure("Dalvik doesn't parse the XML declaration")
public void testGetXmlStandalone() throws Exception {
String message = "This implementation doesn't parse standalone from the XML declaration";
assertEquals(message, false, documentA.getXmlStandalone());
diff --git a/xml/src/test/java/tests/xml/DomTest.java b/xml/src/test/java/tests/xml/DomTest.java
index 5f088c1..1f723f7 100644
--- a/xml/src/test/java/tests/xml/DomTest.java
+++ b/xml/src/test/java/tests/xml/DomTest.java
@@ -16,6 +16,7 @@
package tests.xml;
+import dalvik.annotation.KnownFailure;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import org.w3c.dom.Attr;
@@ -185,6 +186,7 @@ public class DomTest extends TestCase {
* Android's parsed DOM doesn't include entity declarations. These nodes will
* only be tested for implementations that support them.
*/
+ @KnownFailure("Dalvik doesn't parse entity declarations")
public void testEntityDeclarations() {
assertNotNull("This implementation does not parse entity declarations", sp);
}
@@ -193,6 +195,7 @@ public class DomTest extends TestCase {
* Android's parsed DOM doesn't include notations. These nodes will only be
* tested for implementations that support them.
*/
+ @KnownFailure("Dalvik doesn't parse notations")
public void testNotations() {
assertNotNull("This implementation does not parse notations", png);
}
@@ -552,10 +555,12 @@ public class DomTest extends TestCase {
assertNoFeature("XMLVersion", "2.0");
}
- public void testLsFeature() {
+ @KnownFailure("Dalvik doesn't support load/save")
+ public void testLoadSaveFeature() {
assertFeature("LS", "3.0");
}
+ @KnownFailure("Dalvik doesn't support the element traversal feature")
public void testElementTraversalFeature() {
assertFeature("ElementTraversal", "1.0");
}
@@ -652,6 +657,7 @@ public class DomTest extends TestCase {
assertFalse(text.isElementContentWhitespace());
}
+ @KnownFailure("Dalvik doesn't recognize element content whitespace")
public void testIsElementContentWhitespaceWithDeclaration() throws Exception {
String xml = "<!DOCTYPE menu [\n"
+ " <!ELEMENT menu (item)*>\n"
@@ -685,6 +691,7 @@ public class DomTest extends TestCase {
assertEquals("60%", vitamincText.getWholeText());
}
+ @KnownFailure("Dalvik doesn't resolve entity references")
public void testGetWholeTextWithEntityReference() {
EntityReference spReference = document.createEntityReference("sp");
description.insertBefore(spReference, descriptionText2);
@@ -1180,6 +1187,7 @@ public class DomTest extends TestCase {
assertNull(document.getElementById("g"));
}
+ @KnownFailure("Dalvik treats id attributes as identifiers")
public void testAttributeNamedIdIsNotAnIdByDefault() {
String message = "This implementation incorrectly interprets the "
+ "\"id\" attribute as an identifier by default.";
@@ -1323,6 +1331,7 @@ public class DomTest extends TestCase {
1, document.getChildNodes().getLength());
}
+ @KnownFailure("Dalvik document nodes accept arbitrary child nodes")
public void testDocumentAddChild()
throws IOException, SAXException {
try {
diff --git a/xml/src/test/java/tests/xml/NodeTest.java b/xml/src/test/java/tests/xml/NodeTest.java
index dc3a333..d1d99c1 100644
--- a/xml/src/test/java/tests/xml/NodeTest.java
+++ b/xml/src/test/java/tests/xml/NodeTest.java
@@ -51,14 +51,13 @@ public class NodeTest extends TestCase {
File file = Support_Resources.resourceToTempFile("/simple.xml");
Document document = builder.parse(file);
- String baseUri = "file:" + file.getPath();
- assertEquals(baseUri, document.getBaseURI());
+ assertFileUriEquals(file, document.getBaseURI());
Element documentElement = document.getDocumentElement();
for (Node node : flattenSubtree(documentElement)) {
if (node.getNodeType() == Node.ELEMENT_NODE
|| node.getNodeType() == Node.DOCUMENT_NODE) {
- assertEquals("Unexpected base URI for " + node, baseUri, node.getBaseURI());
+ assertFileUriEquals(file, node.getBaseURI());
} else {
assertNull("Unexpected base URI for " + node, node.getBaseURI());
}
@@ -69,6 +68,12 @@ public class NodeTest extends TestCase {
// TODO: test URI santization
}
+ private void assertFileUriEquals(File expectedFile, String actual) {
+ assertTrue("Expected URI for: " + expectedFile + " but was " + actual + ". ",
+ actual.equals("file:" + expectedFile)
+ || actual.equals("file://" + expectedFile));
+ }
+
private List<Node> flattenSubtree(Node subtree) {
List<Node> result = new ArrayList<Node>();
traverse(subtree, result);
diff --git a/xml/src/test/java/tests/xml/NormalizeTest.java b/xml/src/test/java/tests/xml/NormalizeTest.java
index f35ca10..5d2bb0be 100644
--- a/xml/src/test/java/tests/xml/NormalizeTest.java
+++ b/xml/src/test/java/tests/xml/NormalizeTest.java
@@ -16,6 +16,7 @@
package tests.xml;
+import dalvik.annotation.KnownFailure;
import junit.framework.TestCase;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Comment;
@@ -204,6 +205,7 @@ public class NormalizeTest extends TestCase {
* This fails under the RI because setParameter() succeeds even though
* canSetParameter() returns false.
*/
+ @KnownFailure("Dalvik doesn't honor the schema-type parameter")
public void testSchemaTypeDtd() {
assertUnsupported("schema-type", "http://www.w3.org/TR/REC-xml"); // supported in RI v6
}
diff --git a/xml/src/test/java/tests/xml/SaxTest.java b/xml/src/test/java/tests/xml/SaxTest.java
index 2c75a73..dc59b2d 100644
--- a/xml/src/test/java/tests/xml/SaxTest.java
+++ b/xml/src/test/java/tests/xml/SaxTest.java
@@ -16,6 +16,7 @@
package tests.xml;
+import dalvik.annotation.KnownFailure;
import junit.framework.TestCase;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
@@ -94,6 +95,7 @@ public class SaxTest extends TestCase {
* Android's Expat-based SAX parser fails this test because Expat doesn't
* supply us with our much desired {@code xmlns="http://..."} attributes.
*/
+ @KnownFailure("No xmlns attributes from Expat")
public void testYesPrefixesYesNamespaces() throws Exception {
parse(true, true, "<foo bar=\"baz\"/>", new DefaultHandler() {
@Override public void startElement(String uri, String localName,