[Proxool-cvs] proxool/src/java-test/org/logicalcobwebs/cglib EnhancerTest.java,NONE,1.1 MyConcreteCl
UNMAINTAINED!
Brought to you by:
billhorsman
From: <bil...@us...> - 2004-06-02 20:55:06
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/cglib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21087/src/java-test/org/logicalcobwebs/cglib Added Files: EnhancerTest.java MyConcreteClass.java MyInterfaceIF.java MyProxy.java Log Message: Learning test class for Enhancer. It fails (or would if the assert was uncommented). Left in for knowledge. --- NEW FILE: EnhancerTest.java --- /* * This software is released under a licence similar to the Apache Software Licence. * See org.logicalcobwebs.proxool.package.html for details. * The latest version is available at http://proxool.sourceforge.net */ package org.logicalcobwebs.cglib; import org.logicalcobwebs.proxool.AbstractProxoolTest; import org.logicalcobwebs.cglib.proxy.Enhancer; /** * A test test class (!) to help me understand the Enhancer. It fails. Or at least, * it would do if I uncommented the assert. But that fines. It's a learning process. * @version $Revision: 1.1 $, $Date: 2004/06/02 20:54:57 $ * @author billhorsman * @author $Author: billhorsman $ (current maintainer) */ public class EnhancerTest extends AbstractProxoolTest { public EnhancerTest(String alias) { super(alias); } public void testConcreteClassEnhancer() { MyInterfaceIF mi = (MyInterfaceIF) Enhancer.create( null, new Class[] {MyInterfaceIF.class}, new MyProxy(new MyConcreteClass())); mi.bar(); MyConcreteClass mcc = (MyConcreteClass) mi; // This fails // assertEquals("foo()", "proxiedFoo", mcc.foo()); } } /* Revision history: $Log: EnhancerTest.java,v $ Revision 1.1 2004/06/02 20:54:57 billhorsman Learning test class for Enhancer. It fails (or would if the assert was uncommented). Left in for knowledge. */ --- NEW FILE: MyConcreteClass.java --- /* * This software is released under a licence similar to the Apache Software Licence. * See org.logicalcobwebs.proxool.package.html for details. * The latest version is available at http://proxool.sourceforge.net */ package org.logicalcobwebs.cglib; import org.logicalcobwebs.logging.Log; import org.logicalcobwebs.logging.LogFactory; import org.logicalcobwebs.proxool.WrappedConnection; /** * See {@link EnhancerTest} * @version $Revision: 1.1 $, $Date: 2004/06/02 20:54:57 $ * @author billhorsman * @author $Author: billhorsman $ (current maintainer) */ public class MyConcreteClass implements MyInterfaceIF { private static final Log LOG = LogFactory.getLog(MyConcreteClass.class); MyConcreteClass() { LOG.error("MyConcreteClass.init"); } public String foo() { return "foo"; } public void bar() {} } /* Revision history: $Log: MyConcreteClass.java,v $ Revision 1.1 2004/06/02 20:54:57 billhorsman Learning test class for Enhancer. It fails (or would if the assert was uncommented). Left in for knowledge. */ --- NEW FILE: MyInterfaceIF.java --- /* * This software is released under a licence similar to the Apache Software Licence. * See org.logicalcobwebs.proxool.package.html for details. * The latest version is available at http://proxool.sourceforge.net */ package org.logicalcobwebs.cglib; /** * See {@link EnhancerTest} * @version $Revision: 1.1 $, $Date: 2004/06/02 20:54:57 $ * @author billhorsman * @author $Author: billhorsman $ (current maintainer) */ public interface MyInterfaceIF { public void bar(); } /* Revision history: $Log: MyInterfaceIF.java,v $ Revision 1.1 2004/06/02 20:54:57 billhorsman Learning test class for Enhancer. It fails (or would if the assert was uncommented). Left in for knowledge. */ --- NEW FILE: MyProxy.java --- /* * This software is released under a licence similar to the Apache Software Licence. * See org.logicalcobwebs.proxool.package.html for details. * The latest version is available at http://proxool.sourceforge.net */ package org.logicalcobwebs.cglib; import org.logicalcobwebs.cglib.proxy.MethodInterceptor; import org.logicalcobwebs.cglib.proxy.MethodProxy; import java.lang.reflect.Method; /** * See {@link EnhancerTest} * @version $Revision: 1.1 $, $Date: 2004/06/02 20:54:57 $ * @author billhorsman * @author $Author: billhorsman $ (current maintainer) */ public class MyProxy implements MethodInterceptor { private MyConcreteClass myConcreteClass; public MyProxy(MyConcreteClass myConcreteClass) { this.myConcreteClass = myConcreteClass; } public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable { if (method.getName().equals("foo")) { return "proxiedFoo"; } else { return method.invoke(myConcreteClass, args); } } } /* Revision history: $Log: MyProxy.java,v $ Revision 1.1 2004/06/02 20:54:57 billhorsman Learning test class for Enhancer. It fails (or would if the assert was uncommented). Left in for knowledge. */ |