Package org.apache.commons.proxy.util

Examples of org.apache.commons.proxy.util.Echo


    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() );
View Full Code Here


*/
public class TestInterceptorChain extends TestCase
{
    public void testWithSingleInterceptor()
    {
        Echo echo = ( Echo ) new InterceptorChain( new Interceptor[] { new SuffixInterceptor( "a" ) } ).createProxyProvider( new CglibProxyFactory(), new EchoImpl()new Class[] { Echo.class } ).getObject();
        assertEquals( "messagea", echo.echoBack( "message" ) );
    }
View Full Code Here

        assertEquals( "messagea", echo.echoBack( "message" ) );
    }

    public void testWithMultipleInterceptors()
    {
        Echo echo = ( Echo ) new InterceptorChain( new Interceptor[] { new SuffixInterceptor( "a" ), new SuffixInterceptor( "b" ) } ).createProxyProvider( new CglibProxyFactory(), new EchoImpl()new Class[] { Echo.class } ).getObject();
        assertEquals( "messageba", echo.echoBack( "message" ) );
    }
View Full Code Here

*/
public class TestFilteredInterceptor extends TestCase
{
    public void testFilterAccepts()
    {
        Echo echo = ( Echo ) new InterceptorChain( new Interceptor[] { new FilteredInterceptor( new SuffixInterceptor( "a" ), new SimpleFilter( new String[] { "echoBack" } ) ) } ).createProxyProvider( new CglibProxyFactory(), new EchoImpl() ).getObject();
        assertEquals( "messagea", echo.echoBack( "message" ) );
    }
View Full Code Here

        assertEquals( "messagea", echo.echoBack( "message" ) );
    }

    public void testFilterDenies()
    {
        Echo echo = ( Echo ) new InterceptorChain( new Interceptor[] { new FilteredInterceptor( new SuffixInterceptor( "a" ), new SimpleFilter() ) } ).createProxyProvider( new CglibProxyFactory(), new EchoImpl() ).getObject();
        assertEquals( "message", echo.echoBack( "message" ) );
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.proxy.util.Echo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.