+
+ @Test(expected = XMLException.class)
+ public void testReadNotWellFormed() throws Exception {
+ Document doc = DomUtils.read(getResource("testNotWellFormed.xml"));
+ }
+
+ @Test
+ public void testReadAndValidateOk() throws Exception {
+ Document doc = DomUtils.readAndValidate(getResource("test.xml"), getResource("test.xsd"));
+ Element element = doc.getDocumentElement();
+ assertEquals("http://wamblee.org/test", element.getNamespaceURI());
+ String val = DomUtils.serialize(doc);
+ // parse the written document
+ Document doc2 = DomUtils.read(new ByteArrayInputStream(val.getBytes()));
+ XmlUtils.assertEquals("", doc, doc2);
+ }
+
+ @Test(expected = XMLException.class)
+ public void testReadAndValidateNotOk() throws Exception {
+ Document doc = DomUtils.readAndValidate(getResource("testInvalid.xml"), getResource("test.xsd"));
+ }