1 16 package net.sf.cglib.transform.impl; 17 18 import junit.framework.Test; 19 import junit.framework.TestSuite; 20 21 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 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 readObject(Object _this, String name, Object oldValue) { 44 if(name.equals("field")){ 45 readTest = true; 46 } 47 return super.readObject(_this, name, oldValue); 48 } 49 50 public Object writeObject(Object _this, String name, Object oldValue, 51 Object 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 [] args) throws Exception { 61 junit.textui.TestRunner.run(suite()); 62 } 63 64 public static Test suite() throws Exception { 65 return new TestSuite( new TestInterceptFieldsSubclass( ).transform() ); 66 } 67 } 68 69 | Popular Tags |