KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > cglib > transform > impl > TestInterceptFieldsSubclass


1 /*
2  * Copyright 2003 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.transform.impl;
17
18 import junit.framework.Test;
19 import junit.framework.TestSuite;
20
21 /**
22  * @author Juozas
23  *
24  */

25 public class TestInterceptFieldsSubclass extends TestInterceptFields {
26
27     private boolean readTest = false;
28     private boolean writeTest = false;
29     
30     public TestInterceptFieldsSubclass() {
31         super();
32         
33     }
34     public TestInterceptFieldsSubclass(String JavaDoc name) {
35         super(name);
36       
37     }
38     public void testSubClass(){
39         super.test();
40         assertTrue( "super class read field", readTest );
41         assertTrue( "super class write field", readTest );
42     }
43     public Object JavaDoc readObject(Object JavaDoc _this, String JavaDoc name, Object JavaDoc oldValue) {
44        if(name.equals("field")){
45            readTest = true;
46        }
47        return super.readObject(_this, name, oldValue);
48     }
49     
50     public Object JavaDoc writeObject(Object JavaDoc _this, String JavaDoc name, Object JavaDoc oldValue,
51             Object JavaDoc newValue) {
52       
53         if(name.equals("field")){
54             writeTest = true;
55         }
56        
57         return super.writeObject(_this, name, oldValue, newValue);
58     }
59     
60     public static void main(String JavaDoc[] args) throws Exception JavaDoc{
61         junit.textui.TestRunner.run(suite());
62     }
63     
64     public static Test suite() throws Exception JavaDoc{
65         return new TestSuite( new TestInterceptFieldsSubclass( ).transform() );
66     }
67 }
68
69
Popular Tags