public void testMethodInvocationImplementation() throws Exception
{
final InterceptorTester tester = new InterceptorTester();
final EchoImpl target = new EchoImpl();
final Echo proxy = ( Echo ) new JavassistProxyFactory().createInterceptorProxy( target, new MethodInterceptorAdapter( tester ), new Class[] { Echo.class } );
proxy.echo();
assertNotNull( tester.invocation.getArguments() );
assertEquals( 0, tester.invocation.getArguments().length );
assertEquals( Echo.class.getMethod( "echo", new Class[] {} ), tester.invocation.getMethod() );
assertEquals( Echo.class.getMethod( "echo", new Class[] {} ), tester.invocation.getStaticPart() );
assertEquals( target, tester.invocation.getThis() );
proxy.echoBack( "Hello" );
assertNotNull( tester.invocation.getArguments() );
assertEquals( 1, tester.invocation.getArguments().length );
assertEquals( "Hello", tester.invocation.getArguments()[0] );
assertEquals( Echo.class.getMethod( "echoBack", new Class[] { String.class } ), tester.invocation.getMethod() );
assertEquals( Echo.class.getMethod( "echoBack", new Class[] { String.class } ), tester.invocation.getStaticPart() );
proxy.echoBack( "Hello", "World" );
assertNotNull( tester.invocation.getArguments() );
assertEquals( 2, tester.invocation.getArguments().length );
assertEquals( "Hello", tester.invocation.getArguments()[0] );
assertEquals( "World", tester.invocation.getArguments()[1] );
assertEquals( Echo.class.getMethod( "echoBack", new Class[] { String.class, String.class } ), tester.invocation.getMethod() );