Package org.switchyard

Examples of org.switchyard.Exchange


            // Provide the service
            MockHandler provider = new MockHandler();
            ServiceReference service = _domain.createInOnlyService(serviceName, provider);

            // Create the exchange and invoke the service
            Exchange exchange = service.createExchange();

            // Set the message name.  NOTE: setting to the to message
            // name will not be necessary once the service definition is available
            // at runtime
            Message msg = exchange.createMessage().setContent(input);
            msg.getContext().setProperty(Exchange.CONTENT_TYPE, typeName);

            msg.setContent(input);
            exchange.send(msg);

            // wait for message and verify validation
            provider.waitForOKMessage();
            Assert.assertEquals(provider.getMessages().poll().getMessage().getContent(), input);
        } finally {
View Full Code Here


        MockHandler provider = new MockHandler();
        ServiceReference service = _domain.createInOnlyService(serviceName, provider);
       
        // Create the exchange and invoke the service
        MockHandler invokerHandler = new MockHandler();
        Exchange exchange = service.createExchange(invokerHandler);

        // Set the message name.  NOTE: setting to the to message
        // name will not be necessary once the service definition is available
        // at runtime
        Message msg = exchange.createMessage().setContent(input);
        msg.getContext().setProperty(Exchange.CONTENT_TYPE, typeName);

        msg.setContent(input);

        exchange.send(msg);

        invokerHandler.waitForFaultMessage();
        Object content = invokerHandler.getFaults().poll().getMessage().getContent();
        Assert.assertTrue(content instanceof HandlerException);
       
View Full Code Here

            TestTransformHandler serviceHandler = new TestTransformHandler();
            ServiceReference service = _domain.createInOnlyService(serviceName, serviceHandler);
       
            // Create the exchange and invoke the service
            MockHandler invokerHandler = new MockHandler();
            Exchange exchange = service.createExchange(invokerHandler);
       
            // Set the from and to message names.  NOTE: setting to the to message
            // name will not be necessary once the service definition is available
            // at runtime
            Message msg = exchange.createMessage().setContent(input);
            TransformSequence.
                    from(inType).
                    to(finalDestOutType).
                    associateWith(msg);
       
            msg.setContent(input);
           
            exchange.send(msg);

            Assert.assertTrue(serviceHandler.isSuccess());
        } finally {
            // Must remove this transformer, otherwise it's there for the following test... will be
            // fixed once we get rid of the static service domain.
View Full Code Here

     * Basic dispatcher test which verifies erroneous response from service.
     */
    @Test
    public void testServiceFault() {
        ServiceReference ref = registerInOutService("inOut", new ErrorExchangeHandler());
        Exchange exchange = sendMessage(ref, TEST_CONTENT);

        assertNoCause("Service is not implemented", exchange);
    }
View Full Code Here

     */
    @Test
    public void testFaultReportedOnInOnly() {
        ServiceReference ref = registerInOnlyService("inOut", new ErrorExchangeHandler());
        MockHandler consumer = new MockHandler();
        Exchange exchange = ref.createExchange(consumer);
        exchange.send(exchange.createMessage().setContent("test"));
       
        Assert.assertEquals(1, consumer.waitForFaultMessage().getFaults().size());
    }
View Full Code Here

    public void testBeforeProviderErrorInOut() {
        ErrorInterceptor interceptor = new ErrorInterceptor(false, ExchangeInterceptor.PROVIDER);
        _camelContext.getWritebleRegistry().put("interceptor", interceptor);

        ServiceReference ref = registerInOutService("inOut");
        Exchange exchange = sendMessage(ref, TEST_CONTENT);

        assertNoCause("Error before on target Provider", exchange);
        Assert.assertEquals(2, interceptor.getCount());
    }
View Full Code Here

    public void testAfterProviderErrorInOut() {
        ErrorInterceptor interceptor = new ErrorInterceptor(true, ExchangeInterceptor.PROVIDER);
        _camelContext.getWritebleRegistry().put("interceptor", interceptor);
       
        ServiceReference ref = registerInOutService("inOut");
        Exchange exchange = sendMessage(ref, TEST_CONTENT);

        assertNoCause("Error after on target Provider", exchange);
        Assert.assertEquals(2, interceptor.getCount());
    }
View Full Code Here

    public void testBeforeProviderErrorInOnly() {
        ErrorInterceptor interceptor = new ErrorInterceptor(false, ExchangeInterceptor.PROVIDER);
        _camelContext.getWritebleRegistry().put("interceptor", interceptor);

        ServiceReference ref = registerInOnlyService("inOnly", new MockHandler());
        Exchange exchange = sendMessage(ref, TEST_CONTENT);

        assertNoCause("Error before on target Provider", exchange);
        Assert.assertEquals(2, interceptor.getCount());
    }
View Full Code Here

    public void testAfterProviderErrorInOnly() {
        ErrorInterceptor interceptor = new ErrorInterceptor(true, ExchangeInterceptor.PROVIDER);
        _camelContext.getWritebleRegistry().put("interceptor", interceptor);

        ServiceReference ref = registerInOnlyService("inOnly", new MockHandler());
        Exchange exchange = sendMessage(ref, TEST_CONTENT);

        assertNoCause("Error after on target Provider", exchange);
        Assert.assertEquals(2, interceptor.getCount());
    }
View Full Code Here

        RuntimeErrorInterceptor interceptor = new RuntimeErrorInterceptor(
                false, ExchangeInterceptor.PROVIDER);
        _camelContext.getWritebleRegistry().put("interceptor", interceptor);

        ServiceReference ref = registerInOutService("inOut");
        Exchange exchange = sendMessage(ref, TEST_CONTENT);

        assertCause("RuntimeException before on target Provider", exchange);
        Assert.assertEquals(2, interceptor.getCount());
    }
View Full Code Here

TOP

Related Classes of org.switchyard.Exchange

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.