1 16 package net.sf.cglib.transform.impl; 17 18 import net.sf.cglib.transform.*; 19 import junit.framework.*; 20 24 public class TestAddDelegate extends AbstractTransformTest { 25 26 27 public TestAddDelegate(String name) { 28 super(name); 29 } 30 31 public interface Interface { 32 33 Object getDelegte(); 34 35 Object getTarget(); 36 37 } 38 39 public void test(){ 40 41 Interface i = (Interface)this; 42 assertEquals(i.getTarget(),this); 43 44 } 45 46 public static class ImplExclude implements Interface { 47 48 private Object target; 49 50 public ImplExclude(Object target){ 51 this.target = target; 52 } 53 54 public Object getDelegte() { 55 return this; 56 } 57 58 public Object getTarget(){ 59 return target; 60 } 61 } 62 63 public TestAddDelegate() { 64 super(null); 65 } 66 67 68 protected ClassTransformerFactory getTransformer() throws Exception { 69 70 return new ClassTransformerFactory(){ 71 72 public ClassTransformer newInstance(){ 73 74 return new AddDelegateTransformer(new Class []{Interface.class} , ImplExclude.class ); 75 76 } 77 78 }; 79 80 81 } 82 83 84 public static void main(String [] args) throws Exception { 85 junit.textui.TestRunner.run(suite()); 86 } 87 88 public static Test suite() throws Exception { 89 90 return new TestSuite( new TestAddDelegate().transform() ); 91 92 } 93 94 } 95 | Popular Tags |