01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /**
19: * @author Evgueni V. Brevnov
20: * @version $Revision$
21: */package java.lang.reflect;
22:
23: import java.lang.reflect.Field;
24:
25: import junit.framework.TestCase;
26:
27: public class FieldTestSet extends TestCase {
28:
29: private boolean bool = false;
30:
31: private Integer integer = null;
32:
33: public void test1() {
34: try {
35: final boolean value = true;
36: Field field = getClass().getDeclaredField("bool");
37: field.set(this , new Boolean(value));
38: assertEquals(value, bool);
39: } catch (Exception e) {
40: fail(e.toString());
41: }
42: }
43:
44: public void testBug533() {
45: try {
46: final int value = 2005;
47: Field field = getClass().getDeclaredField("integer");
48: field.setAccessible(true);
49: Integer integerObject = new Integer(value);
50: field.set(this , integerObject);
51: assertEquals(value, integer.intValue());
52: } catch (Exception e) {
53: fail(e.toString());
54: }
55: }
56: }
|