Package org.apache.commons.proxy.util

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


        }
    }

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


    }

    public void testChangingArguments()
    {
        final Echo proxy = ( Echo ) factory.createInterceptorProxy( new EchoImpl(), new ChangeArgumentInterceptor(), ECHO_ONLY );
        assertEquals( "something different", proxy.echoBack( "whatever" ) );
    }
View Full Code Here

        super( factory );
    }

    public void testWithAbstractSuperclass()
    {
        final Echo echo = ( Echo )factory.createDelegatorProxy( new ConstantProvider( new EchoImpl() )new Class[] { AbstractEcho.class } );
        assertEquals( "hello", echo.echoBack( "hello" ) );
        assertEquals( "helloworld", echo.echoBack( "hello", "world" ) );
    }
View Full Code Here

    }

    public void testDelegatorWithSuperclass()
    {
        final Echo echo = ( Echo ) factory
                .createDelegatorProxy( new ConstantProvider( new EchoImpl() )new Class[] { Echo.class, EchoImpl.class } );
        assertTrue( echo instanceof EchoImpl );
    }
View Full Code Here

    }

    public void testInterceptorWithSuperclass()
    {
        final Echo echo = ( Echo ) factory
                .createInterceptorProxy( new EchoImpl(), new NoOpMethodInterceptor()new Class[] { Echo.class, EchoImpl.class } );
        assertTrue( echo instanceof EchoImpl );
    }
View Full Code Here

    }

    public void testProxiesWithClashingFinalMethodInSuperclass()
    {
        final Class[] proxyClasses = new Class[]{Echo.class, FinalMethodEcho.class};
        Echo proxy = ( Echo )factory.createDelegatorProxy( new ConstantProvider( new EchoImpl() ), proxyClasses );
        assertEquals( "final", proxy.echoBack("echo") );

        proxy = ( Echo )factory.createInterceptorProxy( new EchoImpl(), new NoOpMethodInterceptor(), proxyClasses );
        assertEquals( "final", proxy.echoBack("echo") );

        proxy = ( Echo )factory.createInvokerProxy( new NullInvoker(), proxyClasses );
        assertEquals( "final", proxy.echoBack("echo") );
    }
View Full Code Here

    public void testDelegatorWithMultipleSuperclasses()
    {
        try
        {
            factory.createDelegatorProxy( new ConstantProvider( new EchoImpl() ),
                                           new Class[] { EchoImpl.class, String.class } );
            fail();
        }
        catch( ProxyFactoryException e )
        {
View Full Code Here

    public void testInterceptorWithMultipleSuperclasses()
    {
        try
        {
            factory.createInterceptorProxy( new EchoImpl(), new NoOpMethodInterceptor(),
                                             new Class[] { EchoImpl.class, String.class } );
            fail();
        }
        catch( ProxyFactoryException e )
        {
View Full Code Here

public class TestMethodInterceptorAdapter extends TestCase
{
    public void testMethodInterception()
    {
        final Echo proxy = ( Echo ) new JavassistProxyFactory().createInterceptorProxy( new EchoImpl(),
                                                                                         new MethodInterceptorAdapter( new SuffixMethodInterceptor(
                                                                                                 " suffix" ) ),
                                                                                         new Class[]{ Echo.class } );
        assertEquals( "message suffix", proxy.echoBack( "message" ) );
    }
View Full Code Here

    }

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

TOP

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

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.