KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.thoughtworks.xstream.io.xml;
2
3 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
4 import org.dom4j.Document;
5 import org.dom4j.DocumentException;
6 import org.dom4j.DocumentHelper;
7 import org.dom4j.Element;
8
9 public class Dom4JReaderTest extends AbstractXMLReaderTest {
10
11     // factory method
12
protected HierarchicalStreamReader createReader(String JavaDoc xml) throws Exception JavaDoc {
13         return new Dom4JReader(DocumentHelper.parseText(xml));
14     }
15
16     public void testCanReadFromElementOfLargerDocument() throws DocumentException {
17         Document document = DocumentHelper.parseText("" +
18                 "<big>" +
19                 " <small>" +
20                 " <tiny/>" +
21                 " </small>" +
22                 " <small-two>" +
23                 " </small-two>" +
24                 "</big>");
25         Element small = document.getRootElement().element("small");
26
27         HierarchicalStreamReader xmlReader = new Dom4JReader(small);
28         assertEquals("small", xmlReader.getNodeName());
29         xmlReader.moveDown();
30         assertEquals("tiny", xmlReader.getNodeName());
31     }
32
33 }
34
Popular Tags