KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thoughtworks > xstream > core > TreeMarshallerTest


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 JavaDoc {
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             // good
28
}
29     }
30 }
31
Popular Tags