1 package com.thoughtworks.xstream.xml.dom4j;
2
3 import com.thoughtworks.xstream.xml.AbstractXMLReaderTest;
4 import com.thoughtworks.xstream.xml.XMLReader;
5 import org.dom4j.Document;
6 import org.dom4j.DocumentException;
7 import org.dom4j.DocumentHelper;
8 import org.dom4j.Element;
9
10 public class Dom4JXMLReaderTest extends AbstractXMLReaderTest {
11
12 // factory method
13 protected XMLReader createReader(String xml) throws Exception {
14 return new Dom4JXMLReader(DocumentHelper.parseText(xml));
15 }
16
17 public void testCanReadFromElementOfLargerDocument() throws DocumentException {
18 Document document = DocumentHelper.parseText("" +
19 "<big>" +
20 " <small>" +
21 " <tiny/>" +
22 " </small>" +
23 " <small-two>" +
24 " </small-two>" +
25 "</big>");
26 Element small = document.getRootElement().element("small");
27
28 XMLReader xmlReader = new Dom4JXMLReader(small);
29 assertEquals("small", xmlReader.name());
30 xmlReader.child(0);
31 assertEquals("tiny", xmlReader.name());
32 }
33
34 }
This page was automatically generated by Maven