01: /*
02: * Copyright 2003 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package net.sf.cglib.beans;
17:
18: import java.lang.reflect.Method;
19: import junit.framework.*;
20:
21: /**
22: *
23: * @author baliuka
24: */
25: public class TestImmutableBean extends TestCase {
26:
27: public void testSimple() {
28: MA bean = new MA();
29: assertTrue(bean.getIntP() == 0);
30: bean.setIntP(42);
31: assertTrue(bean.getIntP() == 42);
32: bean = (MA) ImmutableBean.create(bean);
33: assertTrue(bean.getIntP() == 42);
34: try {
35: bean.setIntP(43);
36: fail("expecting illegal state exception");
37: } catch (IllegalStateException ignore) {
38: }
39: }
40:
41: public TestImmutableBean(java.lang.String testName) {
42: super (testName);
43: }
44:
45: public static void main(java.lang.String[] args) {
46: junit.textui.TestRunner.run(suite());
47: }
48:
49: public static Test suite() {
50: return new TestSuite(TestImmutableBean.class);
51: }
52: }
|