01: /*
02: * Copyright (C) 2006, 2007 XStream Committers.
03: * All rights reserved.
04: *
05: * The software in this package is published under the terms of the BSD
06: * style license a copy of which has been included with this distribution in
07: * the LICENSE.txt file.
08: *
09: * Created on 17. March 2006 by Joerg Schaible
10: */
11: package com.thoughtworks.acceptance;
12:
13: import com.thoughtworks.xstream.XStream;
14:
15: import java.util.ArrayList;
16: import java.util.List;
17:
18: public class AbsoluteXPathDuplicateReferenceTest extends
19: AbstractDuplicateReferenceTest {
20:
21: // tests inherited from superclass
22:
23: protected void setUp() throws Exception {
24: super .setUp();
25: xstream.setMode(XStream.XPATH_ABSOLUTE_REFERENCES);
26: }
27:
28: public void testXmlContainsReferencePaths() {
29:
30: Thing sameThing = new Thing("hello");
31: Thing anotherThing = new Thing("hello");
32:
33: List list = new ArrayList();
34: list.add(sameThing);
35: list.add(sameThing);
36: list.add(anotherThing);
37:
38: String expected = "" + "<list>\n" + " <thing>\n"
39: + " <field>hello</field>\n" + " </thing>\n"
40: + " <thing reference=\"/list/thing\"/>\n"
41: + " <thing>\n" + " <field>hello</field>\n"
42: + " </thing>\n" + "</list>";
43:
44: assertEquals(expected, xstream.toXML(list));
45: }
46:
47: }
|