Package org.apache.tuscany.spi.wire

Examples of org.apache.tuscany.spi.wire.Message


    /**
     * Verfies an exception thrown in the target is propagated to the client correctly
     */
    public void testThrowableTargetInvocation() throws Exception {
        Message response = invoker.invoke(message);
        assertTrue(response.isFault());
        Object body = response.getBody();
        if (!(body instanceof UndeclaredThrowableException)) {
            fail(); // EasyMock wraps the Throwable in an UndeclaredThrowableException
        }
        UndeclaredThrowableException e = (UndeclaredThrowableException) body;
        assertTrue(InsidiousException.class.equals(e.getUndeclaredThrowable().getClass()));
View Full Code Here


        Object targetAddress = new Object();
        message = new MessageImpl();
        message.setMessageId(id);
        message.setCorrelationId(corrId);
        message.setBody("foo");
        Message response = new MessageImpl();
        response.setBody("response");
        Operation<Type> operation = new Operation<Type>("echo", null, null, null);
        head = EasyMock.createMock(Interceptor.class);
        EasyMock.expect(head.invoke(EasyMock.isA(Message.class))).andStubAnswer(new IAnswer() {
            public Object answer() throws Throwable {
                throw new InsidiousException();   // andThrow() does not seem to work here
View Full Code Here

    /**
     * Verfies the normal execution path through a callback
     */
    public void testNormalPathMessageInvocation() throws Exception {
        Message response = invoker.invoke(message);
        assertEquals("response", response.getBody());
        EasyMock.verify(wire);
        EasyMock.verify(context);
        EasyMock.verify(chain);
        EasyMock.verify(head);
    }
View Full Code Here

        Object targetAddress = new Object();
        message = new MessageImpl();
        message.setMessageId(id);
        message.setCorrelationId(corrId);
        message.setBody("foo");
        Message response = new MessageImpl();
        response.setBody("response");
        Operation<Type> operation = new Operation<Type>("echo", null, null, null);
        head = EasyMock.createMock(Interceptor.class);
        EasyMock.expect(head.invoke(EasyMock.isA(Message.class))).andReturn(response);
        EasyMock.replay(head);
        chain = EasyMock.createMock(OutboundInvocationChain.class);
View Full Code Here

        reportMatcher(new IArgumentMatcher() {
            public boolean matches(Object object) {
                if (!(object instanceof Message)) {
                    return false;
                }
                final Message msg = (Message) object;
                Object[] body = (Object[]) msg.getBody();
                return "foo".equals(body[0]);
            }

            public void appendTo(StringBuffer stringBuffer) {
            }
View Full Code Here

                                EasyMock.eq(outputType2),
                                EasyMock.eq(outputType1),
                                EasyMock.isA(Map.class))).andReturn(source[0]);
        replay(mediator);
        interceptor.setMediator(mediator);
        Message msg = createMock(Message.class);
        msg.setBody(EasyMock.anyObject());
        expectLastCall().anyTimes();
        expect(msg.getBody()).andReturn(source).once().andReturn(target[0]).once().andReturn(source[0]);
        expect(msg.isFault()).andReturn(false).once();
        replay(msg);
        Interceptor next = createMock(Interceptor.class);
        expect(next.invoke(msg)).andReturn(msg);
        replay(next);
        interceptor.setNext(next);
        interceptor.invoke(msg);
        String result = (String)msg.getBody();
        Assert.assertEquals(source[0], result);
        EasyMock.verify(mediator, msg, next);
    }
View Full Code Here

        replay(bean);
        ApplicationContext context = createMock(ApplicationContext.class);
        expect(context.getBean("foo")).andReturn(bean);
        replay(context);
        SpringInvoker invoker = new SpringInvoker("foo", TestBean.class.getMethod("test", String.class), context);
        Message msg = new MessageImpl();
        msg.setBody(new String[]{"bar"});
        invoker.invoke(msg);
        verify(context);
        verify(bean);
    }
View Full Code Here

        List<Interceptor> interceptors = new ArrayList<Interceptor>();
        interceptors.add(interceptor);

        InboundInvocationChain inboundChain = setupInbound(interceptors);
        OutboundInvocationChain outboundChain = setupOutbound(null);
        Message msg = new MessageImpl();
        TargetInvoker invoker = createNiceMock(TargetInvoker.class);
        expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
        replay(invoker);
        assertEquals(0, interceptor.getCount());
        connector.connect(inboundChain, outboundChain);
        inboundChain.setTargetInvoker(invoker);
        inboundChain.prepare();
        msg.setTargetInvoker(inboundChain.getTargetInvoker());
        assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg));
        assertEquals(1, interceptor.getCount());
        verify(invoker);
    }
View Full Code Here

        List<Interceptor> interceptors = new ArrayList<Interceptor>();
        interceptors.add(interceptor);

        InboundInvocationChain inboundChain = setupInbound(interceptors);
        OutboundInvocationChain outboundChain = setupOutbound(null);
        Message msg = new MessageImpl();
        TargetInvoker invoker = createNiceMock(TargetInvoker.class);
        expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
        replay(invoker);
        assertEquals(0, interceptor.getCount());
        connector.connect(inboundChain, outboundChain);
        inboundChain.setTargetInvoker(invoker);
        inboundChain.prepare();
        msg.setTargetInvoker(inboundChain.getTargetInvoker());
        assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg));
        assertEquals(1, interceptor.getCount());
        verify(invoker);
    }
View Full Code Here

        List<Interceptor> targetInterceptors = new ArrayList<Interceptor>();
        targetInterceptors.add(targetInterceptor);

        OutboundInvocationChain outboundChain = setupOutbound(sourceInterceptors);
        InboundInvocationChain inboundChain = setupInbound(targetInterceptors);
        Message msg = new MessageImpl();
        TargetInvoker invoker = createNiceMock(TargetInvoker.class);
        expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
        replay(invoker);
        assertEquals(0, sourceInterceptor.getCount());
        assertEquals(0, targetInterceptor.getCount());
        connector.connect(inboundChain, outboundChain);
        inboundChain.setTargetInvoker(invoker);
        inboundChain.prepare();
        msg.setTargetInvoker(inboundChain.getTargetInvoker());
        assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg));
        assertEquals(1, sourceInterceptor.getCount());
        assertEquals(1, targetInterceptor.getCount());
        verify(invoker);
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.spi.wire.Message

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.