Package org.apache.commons.proxy.util

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


        System.setProperties( prevProperties );
    }

    public void testCreateNullObject() throws Exception
    {
        final Echo nullEcho = ( Echo ) ProxyUtils
                .createNullObject( new JavassistProxyFactory(), new Class[]{ Echo.class } );
        assertNull( nullEcho.echoBack( "hello" ) );
        assertNull( nullEcho.echoBack( "hello", "world" ) );
        assertEquals( ( int ) 0, nullEcho.echoBack( 12345 ) );
    }
View Full Code Here


        assertEquals( ( int ) 0, nullEcho.echoBack( 12345 ) );
    }

    public void testCreateNullObjectWithClassLoader() throws Exception
    {
        final Echo nullEcho = ( Echo ) ProxyUtils.createNullObject( new JavassistProxyFactory(),
                                                                    Echo.class.getClassLoader(),
                                                                    new Class[]{ Echo.class } );
        assertNull( nullEcho.echoBack( "hello" ) );
        assertNull( nullEcho.echoBack( "hello", "world" ) );
        assertEquals( ( int ) 0, nullEcho.echoBack( 12345 ) );
    }
View Full Code Here

    }

    public void testInvalidHandlerName()
    {
        final XmlRpcInvoker handler = new XmlRpcInvoker( client, "invalid" );
        final Echo echo = ( Echo ) new CglibProxyFactory()
                .createInvokerProxy( handler, new Class[]{ Echo.class } );
        try
        {
            echo.echoBack( "Hello" );
            fail();
        }
        catch( InvokerException e )
        {
        }
View Full Code Here

    }

    public void testValidInvocation() throws Exception
    {
        final XmlRpcInvoker handler = new XmlRpcInvoker( client, "echo" );
        final Echo echo = ( Echo ) new CglibProxyFactory()
                .createInvokerProxy( handler, new Class[]{ Echo.class } );
        assertEquals( "Hello", echo.echoBack( "Hello" ) );

    }
View Full Code Here

    }

    public void testInvokerProxy() throws Exception
    {
        final InvokerTester tester = new InvokerTester();
        final Echo echo = ( Echo )factory.createInvokerProxy( tester, ECHO_ONLY );
        echo.echoBack( "hello" );
        assertEquals( Echo.class.getMethod( "echoBack", new Class[] { String.class } ), tester.method );
        assertSame( echo, tester.proxy );
        assertNotNull( tester.args );
        assertEquals( 1, tester.args.length );
        assertEquals( "hello", tester.args[0] );
View Full Code Here

        assertEquals( "hello", tester.args[0] );
    }

    public void testDelegatingProxyInterfaceOrder()
    {
        final Echo echo = ( Echo ) factory.createDelegatorProxy( createSingletonEcho(), new Class[] { Echo.class, DuplicateEcho.class } );
        final List expected = new LinkedList( Arrays.asList( new Class[] { Echo.class, DuplicateEcho.class } ) );
        final List actual = new LinkedList( Arrays.asList( echo.getClass().getInterfaces() ) );
        actual.retainAll( expected )// Doesn't alter order!
        assertEquals( expected, actual );
    }
View Full Code Here

        assertEquals( expected, actual );
    }

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

        assertEquals( "ab", echo.echoBack( "a", "b" ) );
    }

    public void testBooleanInterceptorParameter()
    {
        final Echo echo = ( Echo ) factory.createInterceptorProxy( new EchoImpl(), new  InterceptorTester(), ECHO_ONLY );
        assertFalse( echo.echoBack( false ) );
        assertTrue( echo.echoBack( true ) );

    }
View Full Code Here

        assertTrue( echo.echoBack( true ) );

    }
    public void testPrimitiveParameter()
    {
        final Echo echo = ( Echo ) factory.createDelegatorProxy( createSingletonEcho(), ECHO_ONLY );
        assertEquals( 1, echo.echoBack( 1 ) );
    }
View Full Code Here

        assertEquals( 1, echo.echoBack( 1 ) );
    }

    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" ) );
    }
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.