1 16 package org.apache.cocoon.xml.dom; 17 18 import junit.framework.TestCase; 19 20 import org.w3c.dom.Document ; 21 import org.xml.sax.Attributes ; 22 import org.xml.sax.SAXException ; 23 import org.xml.sax.helpers.AttributesImpl ; 24 25 26 31 public class DOMBuilderTestCase extends TestCase { 32 33 37 public DOMBuilderTestCase(String name) { 38 super(name); 39 } 40 41 48 public void testMultipleCharactersEvents() throws SAXException { 49 DOMBuilder builder = new DOMBuilder(); 50 Attributes attrs = new AttributesImpl (); 51 char c1[] = "ABC".toCharArray(); 52 char c2[] = "DEF".toCharArray(); 53 builder.startDocument(); 54 builder.startElement("", "test", "test", attrs); 55 builder.characters(c1, 0, 3); 56 builder.characters(c2, 0, 3); 57 builder.endElement("", "test", "test"); 58 builder.endDocument(); 59 Document dom = builder.getDocument(); 60 StringBuffer value = new StringBuffer (); 61 for (int i = 0 ; i < dom.getDocumentElement().getChildNodes().getLength() ; ++i) { 62 value.append(dom.getDocumentElement().getChildNodes().item(i).getNodeValue()); 63 } 64 assertEquals("Content of root element not what expected", 65 "ABCDEF", value.toString()); 66 } 67 } 68 | Popular Tags |