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 ) factory.createInterceptorProxy( target, tester, ECHO_ONLY );
        proxy.echo();
        assertNotNull( tester.arguments );
        assertEquals( 0, tester.arguments.length );
        assertEquals( Echo.class.getMethod( "echo", new Class[] {} ), tester.method );
        assertEquals( target, tester.proxy );
        proxy.echoBack( "Hello" );
        assertNotNull( tester.arguments );
        assertEquals( 1, tester.arguments.length );
        assertEquals( "Hello", tester.arguments[0] );
        assertEquals( Echo.class.getMethod( "echoBack", new Class[] { String.class } ), tester.method );
        proxy.echoBack( "Hello", "World" );
        assertNotNull( tester.arguments );
        assertEquals( 2, tester.arguments.length );
        assertEquals( "Hello", tester.arguments[0] );
        assertEquals( "World", tester.arguments[1] );
        assertEquals( Echo.class.getMethod( "echoBack", new Class[] { String.class, String.class } ), tester.method );
View Full Code Here


    public void testMethodInvocationDuplicateMethods() throws Exception
    {
        final InterceptorTester tester = new InterceptorTester();
        final EchoImpl target = new EchoImpl();
        final Echo proxy = ( Echo ) factory.createInterceptorProxy( target, tester, new Class[] { Echo.class, DuplicateEcho.class } );
        proxy.echoBack( "hello" );
        assertEquals( Echo.class.getMethod( "echoBack", new Class[] { String.class } ), tester.method );
    }
View Full Code Here

    public void testMethodInvocationClassCaching() throws Exception
    {
        final InterceptorTester tester = new InterceptorTester();
        final EchoImpl target = new EchoImpl();
        final Echo proxy1 = ( Echo ) factory.createInterceptorProxy( target, tester, ECHO_ONLY );
        final Echo proxy2 = ( Echo ) factory.createInterceptorProxy( target, tester, new Class[] { Echo.class, DuplicateEcho.class } );
        proxy1.echoBack( "hello1" );
        final Class invocationClass1 = tester.invocationClass;
        proxy2.echoBack( "hello2" );
        assertEquals( invocationClass1, tester.invocationClass );
    }
View Full Code Here

        assertEquals( invocationClass1, tester.invocationClass );
    }

    public void testDelegatingProxyClassCaching() throws Exception
    {
        final Echo proxy1 = ( Echo ) factory.createDelegatorProxy( new ConstantProvider( new EchoImpl() ), ECHO_ONLY );
        final Echo proxy2 = ( Echo ) factory.createDelegatorProxy( new ConstantProvider( new EchoImpl() ), ECHO_ONLY );
        assertEquals( proxy1.getClass(), proxy2.getClass() );
    }
View Full Code Here

        assertEquals( proxy1.getClass(), proxy2.getClass() );
    }

    public void testInterceptingProxyClassCaching() throws Exception
    {
        final Echo proxy1 = ( Echo ) factory.createInterceptorProxy( new EchoImpl(), new NoOpMethodInterceptor(), ECHO_ONLY );
        final Echo proxy2 = ( Echo ) factory.createInterceptorProxy( new EchoImpl(), new NoOpMethodInterceptor(), ECHO_ONLY );
        assertEquals( proxy1.getClass(), proxy2.getClass() );
    }
View Full Code Here

        assertEquals( proxy1.getClass(), proxy2.getClass() );
    }

    public void testProxyWithCheckedException() throws Exception
    {
        final Echo proxy = ( Echo ) factory.createDelegatorProxy( new ConstantProvider( new EchoImpl() ), ECHO_ONLY );
        try
        {
            proxy.ioException();
            fail();
        }
        catch( IOException e )
        {
        }
View Full Code Here

        }
    }

    public void testProxyWithUncheckedException() throws Exception
    {
        final Echo proxy = ( Echo ) factory.createDelegatorProxy( new ConstantProvider( new EchoImpl() ), ECHO_ONLY );
        try
        {
            proxy.illegalArgument();
            fail();
        }
        catch( IllegalArgumentException e )
        {
        }
View Full Code Here

        }
    }

    public void testInterceptorProxyWithUncheckedException() throws Exception
    {
        final Echo proxy = ( Echo ) factory.createInterceptorProxy( new EchoImpl(), new NoOpMethodInterceptor(),  ECHO_ONLY );
        try
        {
            proxy.illegalArgument();
            fail();
        }
        catch( IllegalArgumentException e )
        {
        }
View Full Code Here

        }
    }

    public void testInterceptorProxyWithCheckedException() throws Exception
    {
        final Echo proxy = ( Echo ) factory.createInterceptorProxy( new EchoImpl(), new NoOpMethodInterceptor(), ECHO_ONLY );
        try
        {
            proxy.ioException();
            fail();
        }
        catch( IOException e )
        {
        }
View Full Code Here

        }
    }

    public void testWithNonAccessibleTargetType()
    {
        final Echo proxy = ( Echo ) factory.createInterceptorProxy( new PrivateEcho(), new NoOpMethodInterceptor(), ECHO_ONLY );
        proxy.echo();

    }
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.