Package org.apache.commons.proxy.util

Examples of org.apache.commons.proxy.util.Echo.echo()


    }

    public void testCreateDelegatingProxy()
    {
        final Echo echo = ( Echo ) factory.createDelegatorProxy( createSingletonEcho(), ECHO_ONLY );
        echo.echo();
        assertEquals( "message", echo.echoBack( "message" ) );
        assertEquals( "ab", echo.echoBack( "a", "b" ) );
    }

    public void testBooleanInterceptorParameter()
View Full Code Here


    public void testCreateInterceptorProxy()
    {
        final Echo target = ( Echo ) factory.createDelegatorProxy( createSingletonEcho(), ECHO_ONLY );
        final Echo proxy = ( Echo ) factory.createInterceptorProxy( target, new SuffixInterceptor( " suffix" ), ECHO_ONLY );
        proxy.echo();
        assertEquals( "message suffix", proxy.echoBack( "message" ) );
    }

    private ObjectProvider createSingletonEcho()
    {
View Full Code Here

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

    }

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

    }

    public void testChangingArguments()
    {
View Full Code Here

    {
        final ExecutedEcho impl = new ExecutedEcho();
        final OneShotExecutor executor = new OneShotExecutor();
        final Echo proxy = ( Echo ) new CglibProxyFactory()
                .createInterceptorProxy( impl, new ExecutorInterceptor( executor ), new Class[] { Echo.class } );
        proxy.echo();
        executor.getLatch().acquire();
        assertEquals( executor.getThread(), impl.getExecutionThread() );
    }

    public void testNonVoidMethod() throws Exception
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() );
        assertEquals( Echo.class.getMethod( "echo", new Class[] {} ), tester.invocation.getStaticPart() );
        assertEquals( target, tester.invocation.getThis() );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.