Package org.apache.commons.proxy

Examples of org.apache.commons.proxy.ProxyFactory$InvokerInvocationHandler


    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


    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();
            fail( "No matching method should be found." );
        }
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
        {
            parameterizedDuck.sayQuack("Elmer");
            fail( "No matching method should be found." );
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
        {
            voidDuck.sayQuack();
            fail( "No matching method should be found." );
View Full Code Here

{
    public void testWithSerializableParametersAndReturn()
    {
        final ObjectEchoImpl target = new ObjectEchoImpl();
        ObjectEcho echo =
                (ObjectEcho) new ProxyFactory().createInterceptorProxy(target,
                        new SerializingInterceptor(),
                        new Class[]{ObjectEcho.class});
        final Object originalParameter = "Hello, World!";
        final Object returnValue = echo.echoBack(originalParameter);
        assertNotSame(originalParameter, target.parameter);
View Full Code Here

    {
        try
        {
            final ObjectEchoImpl target = new ObjectEchoImpl();
            ObjectEcho echo =
                    (ObjectEcho) new ProxyFactory().createInterceptorProxy(target,
                            new SerializingInterceptor(),
                            new Class[]{ObjectEcho.class});
            final Object originalParameter = new ByteArrayOutputStream();
            echo.echoBack(originalParameter);
            fail("Should not be able to call method with non-serializable parameter type.");
View Full Code Here

// Constructors
//**********************************************************************************************************************

    public SyringePlugin(Application application, DependencyProvider dependencyProvider)
    {
        this(application, dependencyProvider, new ProxyFactory());
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.proxy.ProxyFactory$InvokerInvocationHandler

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.