01: /*
02: * Copyright (C) 2004, 2005 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 25. March 2004 by Joe Walnes
11: */
12: package com.thoughtworks.xstream.core;
13:
14: import com.thoughtworks.acceptance.AbstractAcceptanceTest;
15: import com.thoughtworks.xstream.XStream;
16:
17: public class TreeMarshallerTest extends AbstractAcceptanceTest {
18:
19: static class Thing {
20: Thing thing;
21: }
22:
23: protected void setUp() throws Exception {
24: super .setUp();
25: xstream.setMode(XStream.NO_REFERENCES);
26: }
27:
28: public void testThrowsExceptionWhenDetectingCircularReferences() {
29: Thing a = new Thing();
30: Thing b = new Thing();
31: a.thing = b;
32: b.thing = a;
33:
34: try {
35: xstream.toXML(a);
36: fail("expected exception");
37: } catch (TreeMarshaller.CircularReferenceException expected) {
38: // good
39: }
40: }
41: }
|