Package org.apache.commons.proxy

Examples of org.apache.commons.proxy.ObjectProvider


// Other Methods
//----------------------------------------------------------------------------------------------------------------------

    public void testExactSignatureMatch()
    {
        final ObjectProvider targetProvider = new ConstantProvider( new LegacyDuck() );
        final DuckTypingInvoker invoker = new DuckTypingInvoker( targetProvider );
        final Duck duck = ( Duck ) new ProxyFactory().createInvokerProxy( invoker, new Class[]{ Duck.class } );
        assertEquals( "Quack!", duck.sayQuack() );
    }
View Full Code Here


        assertEquals( "Quack!", duck.sayQuack() );
    }

    public void testNoMatchingMethod()
    {
        final ObjectProvider targetProvider = new ConstantProvider( new LegacyDuck() );
        final DuckTypingInvoker invoker = new DuckTypingInvoker( targetProvider );
        final Goose goose = ( Goose ) new ProxyFactory().createInvokerProxy( invoker, new Class[]{ Goose.class } );
        try
        {
            goose.sayHonk();
View Full Code Here

        }
    }

    public void testMismatchingParameterType()
    {
        final ObjectProvider targetProvider = new ConstantProvider( new LegacyDuck() );
        final DuckTypingInvoker invoker = new DuckTypingInvoker( targetProvider );
        final ParameterizedDuck parameterizedDuck = ( ParameterizedDuck ) new ProxyFactory()
                .createInvokerProxy( invoker, new Class[]{ ParameterizedDuck.class } );
        try
        {
View Full Code Here

        }
    }

    public void testTargetHasCompatibleReturnType()
    {
        final ObjectProvider targetProvider = new ConstantProvider( new LegacyDuck() );
        final DuckTypingInvoker invoker = new DuckTypingInvoker( targetProvider );
        final SerializableDuck duck = ( SerializableDuck ) new ProxyFactory().createInvokerProxy( invoker, new Class[]{
                SerializableDuck.class } );
        assertEquals("Quack!", duck.sayQuack() );
View Full Code Here

    }

    public void testMismatchingReturnType()
    {
        final ObjectProvider targetProvider = new ConstantProvider( new LegacyDuck() );
        final DuckTypingInvoker invoker = new DuckTypingInvoker( targetProvider );
        final VoidReturnDuck voidDuck = ( VoidReturnDuck ) new ProxyFactory().createInvokerProxy( invoker, new Class[]{
                VoidReturnDuck.class } );
        try
        {
View Full Code Here

TOP

Related Classes of org.apache.commons.proxy.ObjectProvider

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.