Package org.switchyard

Examples of org.switchyard.Exchange.createMessage()


            if (operationName != null) {
                exchangeIn = serviceReference.createExchange(operationName, handler);
            } else {
                exchangeIn = serviceReference.createExchange(handler);
            }
            Message messageIn = exchangeIn.createMessage();
            Context contextIn = exchangeIn.getContext(messageIn);
            for (Map.Entry<String,Object> entry : request.getContext().entrySet()) {
                contextIn.setProperty(entry.getKey(), entry.getValue());
            }
            Object contentIn = request.getContent();
View Full Code Here


    @Test
    public void authenticationMissing() throws Exception {
        MockHandler handler = new MockHandler();
        Exchange ex = _proxyConsumerService2.operation(METHOD_NAME).createExchange(handler);
        Message requestMsg = ex.createMessage().setContent(INPUT);
        ex.send(requestMsg);
        handler.waitForFaultMessage();
        String response = ex.getMessage().getContent(String.class);
        Assert.assertTrue(response.contains("407 Proxy Authentication Required"));
    }
View Full Code Here

    @Test
    public void httpStatus() throws Exception {
        MockHandler handler = new MockHandler();
        Exchange ex = _consumerService.operation(METHOD_NAME).createExchange(handler);
        Message requestMsg = ex.createMessage().setContent(INPUT);
        requestMsg.getContext().setProperty("SomeRequestHeader", "BAR");
        ex.send(requestMsg);
        handler.waitForOKMessage();
        Assert.assertEquals(200, ex.getContext().getProperty(HttpContextMapper.HTTP_RESPONSE_STATUS).getValue());
    }
View Full Code Here

    @Test
    public void httpFault() throws Exception {
        MockHandler handler = new MockHandler();
        Exchange ex = _consumerService2.operation(METHOD_NAME).createExchange(handler);
        Message requestMsg = ex.createMessage().setContent(INPUT);
        ex.send(requestMsg);
        handler.waitForFaultMessage();
        Assert.assertEquals(404, ex.getContext().getProperty(HttpContextMapper.HTTP_RESPONSE_STATUS).getValue());
    }
View Full Code Here

            ServiceReference service = domain.getServiceReference(msg.getService());
            SynchronousInOutHandler replyHandler = new SynchronousInOutHandler();
            Exchange ex = msg.getOperation() == null
                    ? service.createExchange(replyHandler)
                    : service.createExchange(msg.getOperation(), replyHandler);
            Message m = ex.createMessage();
            if (msg.getContext() != null) {
                m.getContext().setProperties(msg.getContext().getProperties());
            }
            m.setContent(msg.getContent());
           
View Full Code Here

            _targetService.getServiceName(), new InOnlyService());
        Exchange exchange = _service.createExchange();

        MockEndpoint endpoint = getMockEndpoint("mock:result");
        endpoint.expectedBodiesReceived("foo");
        exchange.send(exchange.createMessage().setContent("foo"));
   
        assertThat(context.getRegistry().lookup(TransactionManagerFactory.TM), is(notNullValue()));
        _mixIn.uninitialize();
    }
View Full Code Here

        final String propertyKey = "testProp";
        final String propertyValue = "dummyValue";
        final Exchange exchange = _service.createExchange();
        exchange.getContext().setProperty(propertyKey, propertyValue, Scope.EXCHANGE);

        Message message = exchange.createMessage();
        message.getContext().setProperty(propertyValue, propertyKey);
        exchange.send(message);

        assertThat(camelEndpoint.getReceivedCounter(), is(1));
        org.apache.camel.Exchange ex = camelEndpoint.getReceivedExchanges().get(0);
View Full Code Here

            }
        }
        );
        _service = _serviceDomain.registerServiceReference(serviceName, new InOutService());
        Exchange exchange = _service.createExchange();
        exchange.send(exchange.createMessage().setContent("foo"));
        assertThat((Boolean)exchange.getContext().getProperty("decomposeInvoked").getValue(), is(true));
        assertThat((Boolean)exchange.getContext().getProperty("composeInvoked").getValue(), is(true));
    }

    @Override
View Full Code Here

                    responseQueue.offer(exchange);
                }
            });

            Exchange exchange = _serviceReference.createExchange(exchangeContract, responseExchangeHandler.get());
            Message message = exchange.createMessage().setContent(payload);

            exchange.send(message);
            Exchange exchangeOut = null;
            try {
                exchangeOut = responseQueue.take();
View Full Code Here

                    throw new SwitchYardException("Service invocation failure.  Service '" + _serviceReference.getName() + "', operation '" + operationName + "'.  Non Throwable failure message payload: " + failureObj);
                }
            }
        } else {
            Exchange exchange = _serviceReference.createExchange(exchangeContract);
            Message message = exchange.createMessage().setContent(payload);

            exchange.send(message);
        }

        return null;
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.