Package org.apache.commons.proxy.factory.cglib

Examples of org.apache.commons.proxy.factory.cglib.CglibProxyFactory


public class TestNullInvoker extends TestCase
{
    public void testReturnValues()
    {
        final Tester tester = ( Tester )ProxyUtils.createNullObject( new CglibProxyFactory(), new Class[] { Tester.class } );
        assertEquals( 0, tester.intMethod() );
        assertEquals( 0L, tester.longMethod() );
        assertEquals( ( short )0, tester.shortMethod() );
        assertEquals( ( byte )0, tester.byteMethod() );
        assertEquals( ( char )0, tester.charMethod() );
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();
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 testVoidMethod() throws Exception
    {
        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() );
    }
View Full Code Here

    public void testNonVoidMethod() throws Exception
    {
        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 } );
        try
        {
            proxy.echoBack( "hello" );
            fail();
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

    private Echo echo;

    protected void setUp() throws Exception
    {
        logMock = mock( Log.class );
        echo = ( Echo ) new CglibProxyFactory()
                .createInterceptorProxy( new EchoImpl(), new LoggingInterceptor( ( Log ) logMock.proxy() ),
                                         new Class[]{ Echo.class } );
    }
View Full Code Here

    }

    public void testWhenLoggingDisabled()
    {
        logMock = mock( Log.class );
        echo = ( Echo ) new CglibProxyFactory()
                .createInterceptorProxy( new EchoImpl(), new LoggingInterceptor( ( Log ) logMock.proxy() ),
                                         new Class[]{ Echo.class } );
        logMock.expects( once() ).method( "isDebugEnabled" ).will( returnValue( false ) );
        echo.echoBack( "Hello" );
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

TOP

Related Classes of org.apache.commons.proxy.factory.cglib.CglibProxyFactory

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.