public void testThrowable() throws Exception { MockInterceptor mi = new MockInterceptor(); mi.setThrowable(new NullPointerException()); Hello hello = (Hello) mi.createProxy(Hello.class); try { hello.greeting(); fail("1"); } catch (NullPointerException ignore) { } }
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]); }
public void testCreateProxy() throws Exception { MockInterceptor mi = new MockInterceptor("Hello"); Hello hello = (Hello) mi.createProxy(Hello.class); assertEquals("1", "Hello", hello.greeting()); }