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 IDDuplicateReferenceTest extends
20: AbstractDuplicateReferenceTest {
21:
22: // tests inherited from superclass
23:
24: protected void setUp() throws Exception {
25: super .setUp();
26: xstream.setMode(XStream.ID_REFERENCES);
27: }
28:
29: public void testXmlContainsReferenceIds() {
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 id=\"1\">\n"
40: + " <thing id=\"2\">\n" + " <field>hello</field>\n"
41: + " </thing>\n" + " <thing reference=\"2\"/>\n"
42: + " <thing id=\"3\">\n" + " <field>hello</field>\n"
43: + " </thing>\n" + "</list>";
44:
45: assertEquals(expected, xstream.toXML(list));
46: }
47:
48: }
|