KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thoughtworks > xstream > io > xml > XppDomReaderTest


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 JavaDoc;
8
9 public class XppDomReaderTest extends AbstractXMLReaderTest {
10     protected HierarchicalStreamReader createReader(String JavaDoc xml) throws Exception JavaDoc {
11         return new XppDomDriver().createReader(new StringReader JavaDoc(xml));
12     }
13
14     public void testCanReadFromElementOfLargerDocument()
15             throws Exception JavaDoc {
16         String JavaDoc 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 JavaDoc(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