01: /*
02: * Copyright (C) 2004 Joe Walnes.
03: * Copyright (C) 2006, 2007 XStream Committers.
04: * All rights reserved.
05: *
06: * The software in this package is published under the terms of the BSD
07: * style license a copy of which has been included with this distribution in
08: * the LICENSE.txt file.
09: *
10: * Created on 07. March 2004 by Joe Walnes
11: */
12: package com.thoughtworks.xstream.io.xml;
13:
14: import com.thoughtworks.xstream.io.HierarchicalStreamReader;
15:
16: import org.dom4j.Document;
17: import org.dom4j.DocumentException;
18: import org.dom4j.DocumentHelper;
19: import org.dom4j.Element;
20:
21: public class Dom4JReaderTest extends AbstractXMLReaderTest {
22:
23: // factory method
24: protected HierarchicalStreamReader createReader(String xml)
25: throws Exception {
26: return new Dom4JReader(DocumentHelper.parseText(xml));
27: }
28:
29: public void testCanReadFromElementOfLargerDocument()
30: throws DocumentException {
31: Document document = DocumentHelper.parseText("" + "<big>"
32: + " <small>" + " <tiny/>" + " </small>"
33: + " <small-two>" + " </small-two>" + "</big>");
34: Element small = document.getRootElement().element("small");
35:
36: HierarchicalStreamReader xmlReader = new Dom4JReader(small);
37: assertEquals("small", xmlReader.getNodeName());
38: xmlReader.moveDown();
39: assertEquals("tiny", xmlReader.getNodeName());
40: }
41:
42: }
|