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. May 2004 by Joe Walnes
11: */
12: package com.thoughtworks.acceptance;
13:
14: import com.thoughtworks.xstream.XStream;
15:
16: import java.util.ArrayList;
17: import java.util.List;
18:
19: public class RelativeXPathDuplicateReferenceTest extends
20: AbstractDuplicateReferenceTest {
21:
22: // tests inherited from superclass
23:
24: protected void setUp() throws Exception {
25: super .setUp();
26: xstream.setMode(XStream.XPATH_RELATIVE_REFERENCES);
27: }
28:
29: public void testXmlContainsReferencePaths() {
30:
31: Thing sameThing = new Thing("hello");
32: Thing anotherThing = new Thing("hello");
33:
34: List list = new ArrayList();
35: list.add(sameThing);
36: list.add(sameThing);
37: list.add(anotherThing);
38:
39: String expected = "" + "<list>\n" + " <thing>\n"
40: + " <field>hello</field>\n" + " </thing>\n"
41: + " <thing reference=\"../thing\"/>\n" + " <thing>\n"
42: + " <field>hello</field>\n" + " </thing>\n"
43: + "</list>";
44:
45: assertEquals(expected, xstream.toXML(list));
46: }
47:
48: }
|