Package java.lang.reflect

Examples of java.lang.reflect.InvocationHandler.invoke()


        child.publish(new RequestStart(this, id2));
        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        handler = (InvocationHandler) ctx.getHandler();
        Assert.assertEquals(1, mockInterceptor.getCount());
        response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("Hello foo", response);
        Assert.assertEquals(2, mockInterceptor.getCount());
        HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
        Assert.assertEquals(0, service1.count());
        child.publish(new RequestEnd(this, id));
View Full Code Here


        child.publish(new RequestStart(this, id));
        EntryPointContext ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        InvocationHandler handler = (InvocationHandler) ctx.getHandler();
        Assert.assertEquals(0, mockInterceptor.getCount());
        Object response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("Hello foo", response);
        Assert.assertEquals(1, mockInterceptor.getCount());

        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
View Full Code Here

        Assert.assertEquals(1, mockInterceptor.getCount());

        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        handler = (InvocationHandler) ctx.getHandler();
        response = handler.invoke(null, hello, new Object[]{"foo"});
        HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
        Assert.assertEquals(2, service1.count());

        child.publish(new RequestEnd(this, id));
View Full Code Here

        child.publish(new RequestStart(this, id2));
        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        handler = (InvocationHandler) ctx.getHandler();
        Assert.assertEquals(2, mockInterceptor.getCount());
        response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("Hello foo", response);
        Assert.assertEquals(3, mockInterceptor.getCount());
        HelloWorldService service2 = (HelloWorldService) child.getContext("target").getInstance(null);
        Assert.assertEquals(1, service2.count());
        child.publish(new RequestEnd(this, id2));
View Full Code Here

        child.publish(new RequestStart(this, id));
        EntryPointContext ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        InvocationHandler handler = (InvocationHandler) ctx.getHandler();
        Assert.assertEquals(0, mockInterceptor.getCount());
        Object response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("foo", response);
        Assert.assertEquals(1, mockInterceptor.getCount());

        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
View Full Code Here

        Assert.assertEquals(1, mockInterceptor.getCount());

        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        handler = (InvocationHandler) ctx.getHandler();
        response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("foo", response);
        child.publish(new RequestEnd(this, id));

        // second request
        Object id2 = new Object();
View Full Code Here

        child.publish(new RequestStart(this, id2));
        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        handler = (InvocationHandler) ctx.getHandler();
        Assert.assertEquals(2, mockInterceptor.getCount());
        response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("foo", response);
        Assert.assertEquals(3, mockInterceptor.getCount());
        child.publish(new RequestEnd(this, id2));

        child.publish(new ModuleStop(this));
View Full Code Here

    private Object createProxy() throws Exception {
        return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{type },
                new InvocationHandler() {
                    public Object invoke(Object p, Method method, Object[] args) throws Throwable {
                        InvocationHandler next = getJBIInvocationHandler();
                        return next.invoke(p, method, args);
                    }
                }
        );
    }
   
View Full Code Here

        for( MockResolver mockResolver : mockRepository.getAll() )
        {
            InvocationHandler handler = mockResolver.getInvocationHandler( proxy, method, args );
            if( handler != null )
            {
                return handler.invoke( mockResolver, method, args );
            }
        }
        throw new IllegalStateException( "There is no mock registered that can handle " + method );
    }
}
View Full Code Here

        throws Throwable
    {
        if( delegate instanceof InvocationHandler )
        {
            InvocationHandler handler = (InvocationHandler) delegate;
            return handler.invoke( object, method, args );
        }
        else
        {
            try
            {
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.