Package org.switchyard

Examples of org.switchyard.Message


                            + "_reasonTexts={}, _role=null, _string=Invalid name, _stringLocale=null, _subcodes=[], _detail=[detail: null]]";

        MockHandler handler = new MockHandler();
        Exchange ex = _consumerService11.operation("sayHello").createExchange(handler);

        Message requestMsg = ex.createMessage().setContent(input);
        ex.send(requestMsg);
        handler.waitForFaultMessage();
        Exchange exchange = handler.getFaults().iterator().next();
        Property faultInfoProperty = exchange.getContext().getProperty(SOAPComposition.SOAP_FAULT_INFO);
        Assert.assertNotNull(faultInfoProperty);
View Full Code Here


     * Create a mocked SwitchYard exchange
     * @return exchange
     */
    private org.switchyard.Exchange createSwitchYardExchange() {
        org.switchyard.Exchange switchYardExchange = mock(org.switchyard.Exchange.class);
        Message message = mock(org.switchyard.Message.class);
        when(message.getContext()).thenReturn(new DefaultContext(Scope.MESSAGE));
        when(message.getContent(Integer.class)).thenReturn(10);
        when(switchYardExchange.getMessage()).thenReturn(message);
        when(switchYardExchange.createMessage()).thenReturn(message);
        return switchYardExchange;
    }
View Full Code Here

                // Verify that the content was set on the request message by the invoker
                Assert.assertNotNull(exchange.getMessage().getContent());
                Assert.assertEquals("message-test-in", exchange.getMessage().getContent());
               
                // Set out content to be returned through invoker
                Message reply = exchange.createMessage();
                reply.setContent("message-test-out");
                exchange.send(reply);
            }
        });
        invokerService.operation("messageTest").sendInOut("messageTest");
    }
View Full Code Here

                        .getProperty(TEST_IN_PROPERTY, Scope.MESSAGE);
                Assert.assertNotNull(inProp);
                Assert.assertEquals(TEST_IN_PROPERTY, inProp.getValue());
               
                // Set an out property which will be verified in the test bean class
                Message reply = exchange.createMessage();
                exchange.getContext(reply)
                    .setProperty(TEST_OUT_PROPERTY, TEST_OUT_PROPERTY, Scope.MESSAGE);
                exchange.send(reply);
            }
        });
View Full Code Here

   
    @Test
    public void declaredException() {
        testKit.registerInOutService(REFERENCE_A, new BaseHandler() {
            public void handleMessage(Exchange exchange) throws HandlerException {
                Message reply = exchange.createMessage();
                reply.setContent(new DummyException(
                        exchange.getMessage().getContent(String.class)));
                exchange.sendFault(reply);
            }
        });
        invokerService.operation("declaredException").sendInOut("declaredException");
View Full Code Here

        final Exchange camelExchange = createCamelExchange();
        final ServiceReference serviceReference = createMockServiceRef();
        final org.switchyard.Exchange switchYardExchange = createMockExchangeWithBody(new MessageCreator() {
            @Override
            public Message create() {
                Message message = mock(Message.class);
                when(message.getContext()).thenReturn(new DefaultContext(Scope.MESSAGE));
                when(message.getContent(Integer.class)).thenReturn(10);
                return message;
            }
        });
        final CamelResponseHandler responseHandler = new CamelResponseHandler(camelExchange, serviceReference, _messageComposer);
View Full Code Here

        final Exchange camelExchange = createCamelExchange();
        final ServiceReference serviceReference = createMockServiceRef();
        final org.switchyard.Exchange switchYardExchange = createMockExchangeWithBody(new MessageCreator() {
            @Override
            public Message create() {
                Message message = mock(Message.class);
                when(message.getContext()).thenReturn(new DefaultContext(Scope.MESSAGE));
                when(message.getContent()).thenReturn(fault);
                return message;
            }
        });
        final CamelResponseHandler responseHandler = new CamelResponseHandler(camelExchange, serviceReference, _messageComposer);
View Full Code Here

    @Test
    public void testInject() {
        Invoker invoker = _testKit.newInvoker("InjectService.doSomething");
        SynchronousInOutHandler handler = new SynchronousInOutHandler();
        Exchange exchange = invoker.createExchange(handler);
        Message message = exchange.createMessage();
        Context context = exchange.getContext(message);
        context.setProperty("someProp", "somePropVal");
        message.setContent("blah");
        DataSource attach = new TestDataSource("someAttach", "text/plain", "someAttachData");
        message.addAttachment(attach.getName(), attach);
        exchange.send(message);
        Exchange outExchange = handler.waitForOut();
        Assert.assertEquals("true, true, true", outExchange.getMessage().getContent());
    }
View Full Code Here

        final Exchange camelExchange = createCamelExchange();
        final ServiceReference serviceReference = createMockServiceRef();
        final org.switchyard.Exchange switchYardExchange = createMockExchangeWithBody(new MessageCreator() {
            @Override
            public Message create() {
                Message message = mock(Message.class);
                when(message.getContent()).thenReturn(exception);
                return message;
            }
        });
        final CamelResponseHandler responseHandler = new CamelResponseHandler(camelExchange, serviceReference, _messageComposer);
View Full Code Here

        final ExchangeContract exchangeContract = mock(ExchangeContract.class);
        final ServiceOperation serviceOperation = mock(ServiceOperation.class);
        final ServiceOperation referenceOperation = mock(ServiceOperation.class);
        final Service provider = mock(Service.class);

        final Message message = creator.create();
        when(switchYardExchange.getMessage()).thenReturn(message);

        when(provider.getName()).thenReturn(SERVICE_QNAME);
        when(switchYardExchange.getProvider()).thenReturn(provider);
        when(switchYardExchange.getContext()).thenReturn(switchYardContext);
View Full Code Here

TOP

Related Classes of org.switchyard.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.