01: /*
02: * Copyright (C) 2006, 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 08. February 2006 by Joerg Schaible
10: */
11: package com.thoughtworks.xstream.converters.reflection;
12:
13: public class PureJavaReflectionProvider15Test extends
14: AbstractReflectionProviderTest {
15:
16: // inherits tests from superclass
17:
18: public ReflectionProvider createReflectionProvider() {
19: return new PureJavaReflectionProvider();
20: }
21:
22: // ---------------------------------------------------------
23:
24: public static class WithFinalField {
25: private final String s;
26:
27: private WithFinalField() {
28: this .s = "";
29: }
30:
31: String getFinal() {
32: return s;
33: }
34: }
35:
36: public void testCanCreateWithFinalFIeld() {
37: assertCanCreate(WithFinalField.class);
38: }
39:
40: public void testWriteToFinalField() {
41: Object result = reflectionProvider
42: .newInstance(WithFinalField.class);
43: reflectionProvider.writeField(result, "s", "foo",
44: WithFinalField.class);
45: WithFinalField withFinalField = (WithFinalField) result;
46: assertEquals("foo", withFinalField.getFinal());
47: }
48:
49: }
|