1 7 8 package org.dom4j; 9 10 import junit.textui.TestRunner; 11 12 import java.util.List ; 13 14 import org.dom4j.io.SAXReader; 15 16 22 public class GetQNamesTest extends AbstractTestCase { 23 public static void main(String [] args) { 24 TestRunner.run(GetQNamesTest.class); 25 } 26 27 public void testQNames() throws Exception { 30 DocumentFactory factory = new DocumentFactory(); 31 32 SAXReader reader = new SAXReader(); 33 reader.setDocumentFactory(factory); 34 getDocument("/xml/test/soap2.xml", reader); 35 36 List qnames = factory.getQNames(); 37 assertEquals("Number of QNames not correct", 15, qnames.size()); 38 } 39 40 47 public void testRename() throws Exception { 48 Document doc = DocumentHelper.createDocument(); 49 Element root = doc.addElement("foo"); 50 51 assertEquals("named correctly", "foo", root.getName()); 52 53 root.setName("bar"); 54 55 assertEquals("named correctly", "bar", root.getName()); 56 57 QName xyz = root.getQName("xyz"); 58 59 root.setQName(xyz); 60 61 assertEquals("QNamed correctly", xyz, root.getQName()); 62 } 63 } 64 65 101 | Popular Tags |