01: /*
02: * Copyright (C) 2007 XStream Committers.
03: * All rights reserved.
04: *
05: * The software in this package is published under the terms of the BSD
06: * style license a copy of which has been included with this distribution in
07: * the LICENSE.txt file.
08: *
09: * Created on 23. November 2007 by Joerg Schaible
10: */
11: package com.thoughtworks.acceptance.annotations;
12:
13: import com.thoughtworks.acceptance.AbstractAcceptanceTest;
14: import com.thoughtworks.xstream.XStream;
15: import com.thoughtworks.xstream.annotations.XStreamAlias;
16: import com.thoughtworks.xstream.annotations.XStreamOmitField;
17:
18: /**
19: * Tests annotation to omit a field.
20: *
21: * @author Chung-Onn Cheong
22: * @author Mauro Talevi
23: * @author Guilherme Silveira
24: * @author Jörg Schaible
25: */
26: public class OmitFieldTest extends AbstractAcceptanceTest {
27:
28: @Override
29: protected XStream createXStream() {
30: XStream xstream = super .createXStream();
31: xstream.autodetectAnnotations(true);
32: return xstream;
33: }
34:
35: @XStreamAlias("apartment")
36: public static class Apartment {
37:
38: @XStreamOmitField
39: int size;
40:
41: protected Apartment(int size) {
42: this .size = size;
43: }
44: }
45:
46: public void testAnnotation() {
47: Apartment ap = new Apartment(5);
48: String expectedXml = "<apartment/>";
49: assertBothWays(ap, expectedXml);
50: }
51: }
|