summaryrefslogtreecommitdiffstats
path: root/xml/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'xml/src/test')
-rw-r--r--xml/src/test/java/tests/xml/DomTest.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/xml/src/test/java/tests/xml/DomTest.java b/xml/src/test/java/tests/xml/DomTest.java
index 2f364d0..5f088c1 100644
--- a/xml/src/test/java/tests/xml/DomTest.java
+++ b/xml/src/test/java/tests/xml/DomTest.java
@@ -37,6 +37,7 @@ import org.w3c.dom.Text;
import org.w3c.dom.TypeInfo;
import org.w3c.dom.UserDataHandler;
import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -48,6 +49,7 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.File;
import java.io.FileWriter;
+import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
@@ -1311,6 +1313,25 @@ public class DomTest extends TestCase {
}
}
+ public void testDocumentDoesNotHaveWhitespaceChildren()
+ throws IOException, SAXException {
+ String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n"
+ + " <foo/>\n"
+ + " \n";
+ document = builder.parse(new InputSource(new StringReader(xml)));
+ assertEquals("Document nodes shouldn't have text children",
+ 1, document.getChildNodes().getLength());
+ }
+
+ public void testDocumentAddChild()
+ throws IOException, SAXException {
+ try {
+ document.appendChild(document.createTextNode(" "));
+ fail("Document nodes shouldn't accept child nodes");
+ } catch (DOMException e) {
+ }
+ }
+
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) {