Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 7 8 package org.dom4j; 9 10 import junit.textui.TestRunner; 11 12 17 public class AddNodeTest extends AbstractTestCase { 18 public static void main(String [] args) { 19 TestRunner.run(AddNodeTest.class); 20 } 21 22 public void testDom4jAddNodeClone() { 25 Document maindoc = DocumentHelper.createDocument(); 26 Element docroot = maindoc.addElement("document"); 27 Element header = docroot.addElement("header").addText("Some Text"); 28 29 Document subdoc = DocumentHelper.createDocument(); 30 Element docroot2 = subdoc.addElement("document"); 31 32 docroot2.add((Element) maindoc.selectSingleNode("/document/header") 33 .clone()); 34 assertEquals(subdoc.asXML(), maindoc.asXML()); 35 } 36 37 public void testDom4jAddNodeCreateCopy() { 38 Document maindoc = DocumentHelper.createDocument(); 39 Element docroot = maindoc.addElement("document"); 40 Element header = docroot.addElement("header").addText("Some Text"); 41 42 Document subdoc = DocumentHelper.createDocument(); 43 Element docroot2 = subdoc.addElement("document"); 44 45 docroot2.add(((Element) maindoc.selectSingleNode("/document/header")) 46 .createCopy()); 47 assertEquals(subdoc.asXML(), maindoc.asXML()); 48 } 49 50 public void testDom4jAddNodeBug() { 51 Document maindoc = DocumentHelper.createDocument(); 52 Element docroot = maindoc.addElement("document"); 53 Element header = docroot.addElement("header").addText("Some Text"); 54 55 Document subdoc = DocumentHelper.createDocument(); 56 Element subroot = subdoc.addElement("document"); 57 58 try { 59 subroot.add((Element) maindoc.selectSingleNode("/document/header")); 61 fail(); 62 } catch (IllegalAddException e) { 63 } 65 } 66 } 67 68 104
| Popular Tags
|