1 package com.thoughtworks.acceptance; 2 3 import com.thoughtworks.xstream.XStream; 4 5 import java.util.ArrayList ; 6 import java.util.List ; 7 8 public class XPathDuplicateReferenceTest extends AbstractDuplicateReferenceTest { 9 10 12 protected void setUp() throws Exception { 13 super.setUp(); 14 xstream.setMode(XStream.XPATH_REFERENCES); 15 } 16 17 public void testXmlContainsReferencePaths() { 18 19 Thing sameThing = new Thing("hello"); 20 Thing anotherThing = new Thing("hello"); 21 22 List list = new ArrayList (); 23 list.add(sameThing); 24 list.add(sameThing); 25 list.add(anotherThing); 26 27 String expected = "" + 28 "<list>\n" + 29 " <thing>\n" + 30 " <field>hello</field>\n" + 31 " </thing>\n" + 32 " <thing reference=\"../thing\"/>\n" + 33 " <thing>\n" + 34 " <field>hello</field>\n" + 35 " </thing>\n" + 36 "</list>"; 37 38 assertEquals(expected, xstream.toXML(list)); 39 } 40 41 } 42 | Popular Tags |