1 package com.thoughtworks.xstream.io.xml; 2 3 import com.thoughtworks.xstream.io.HierarchicalStreamReader; 4 import com.thoughtworks.xstream.io.xml.xppdom.Xpp3Dom; 5 import com.thoughtworks.xstream.io.xml.xppdom.Xpp3DomBuilder; 6 7 import java.io.StringReader ; 8 9 public class XppDomReaderTest extends AbstractXMLReaderTest { 10 protected HierarchicalStreamReader createReader(String xml) throws Exception { 11 return new XppDomDriver().createReader(new StringReader (xml)); 12 } 13 14 public void testCanReadFromElementOfLargerDocument() 15 throws Exception { 16 String xml = 17 "<big>" + 18 " <small>" + 19 " <tiny/>" + 20 " </small>" + 21 " <small-two>" + 22 " </small-two>" + 23 "</big>"; 24 25 Xpp3Dom document = Xpp3DomBuilder.build(new StringReader (xml)); 26 27 Xpp3Dom small = document.getChild("small"); 28 29 HierarchicalStreamReader xmlReader = new XppDomReader(small); 30 31 assertEquals("small", xmlReader.getNodeName()); 32 33 xmlReader.moveDown(); 34 35 assertEquals("tiny", xmlReader.getNodeName()); 36 } 37 } 38 | Popular Tags |