public void testInvoke() throws Exception { MockInterceptor mi = new MockInterceptor("Hello"); Aspect aspect = new AspectImpl(mi); AopProxy aopProxy = new AopProxy(Hello.class, new Aspect[] {aspect}); Hello hello = (Hello) aopProxy.create(); assertEquals("1", "Hello", hello.greeting()); }
public void testInvoke3() throws Exception { MockInterceptor mi = new MockInterceptor(); mi.setReturnValue("greeting", "Hello"); mi.setReturnValue("echo", "Hello"); Aspect aspect = new AspectImpl(mi); AopProxy aopProxy = new AopProxy(Hello2.class, new Aspect[] {aspect}); Hello2 hello = (Hello2) aopProxy.create(); assertEquals("1", "Hello", hello.greeting()); assertEquals("2", "Hello", hello.echo("hoge")); }
public void testInvoke2() throws Exception { MockInterceptor mi = new MockInterceptor("Hello"); Aspect aspect = new AspectImpl(mi); AopProxy aopProxy = new AopProxy(Hello2.class, new Aspect[] {aspect}); Hello2 hello = (Hello2) aopProxy.create(); assertEquals("1", "Hello", hello.echo("hoge")); assertEquals("2", true, mi.isInvoked("echo")); assertEquals("3", false, mi.isInvoked("greeting")); assertEquals("4", "hoge", mi.getArgs("echo")[0]); }