1 package info.jtrac.util; 2 3 import info.jtrac.util.XmlUtils; 4 import junit.framework.TestCase; 5 import org.dom4j.Document; 6 7 public class XmlUtilsTest extends TestCase { 8 9 public void testXmlStringParse() { 10 String s = "<test/>"; 11 Document d = XmlUtils.parse(s); 12 assertTrue(d.getRootElement().getName().equals("test")); 13 } 14 15 public void testBadXmlParseFails() { 16 String s = "foo"; 17 try { 18 Document d = XmlUtils.parse(s); 19 fail("How did we parse invalid XML?"); 20 } catch (Exception e) { 21 } 23 } 24 25 public void testGetAsPrettyXml() { 26 String s = "<root><node1><node2>data</node2></node1></root>"; 27 String result = XmlUtils.getAsPrettyXml(s); 28 assertTrue(result.equals("<root>\n <node1>\n <node2>data</node2>\n </node1>\n</root>")); 29 } 30 31 } 32 | Popular Tags |