1 package com.thoughtworks.xstream.core; 2 3 import com.thoughtworks.acceptance.AbstractAcceptanceTest; 4 import com.thoughtworks.xstream.XStream; 5 6 public class TreeMarshallerTest extends AbstractAcceptanceTest { 7 8 class Thing { 9 Thing thing; 10 } 11 12 protected void setUp() throws Exception { 13 super.setUp(); 14 xstream.setMode(XStream.NO_REFERENCES); 15 } 16 17 public void testThrowsExceptionWhenDetectingCircularReferences() { 18 Thing a = new Thing(); 19 Thing b = new Thing(); 20 a.thing = b; 21 b.thing = a; 22 23 try { 24 xstream.toXML(a); 25 fail("expected exception"); 26 } catch (TreeMarshaller.CircularReferenceException expected) { 27 } 29 } 30 } 31 | Popular Tags |