Package org.switchyard

Examples of org.switchyard.Exchange


    }

    private void sendMessage(final ServiceReference ref, final Object content) throws Exception {
        new Thread(new Runnable() {
            public void run() {
                Exchange exchange = ref.createExchange(new MockHandler());
                exchange.send(exchange.createMessage().setContent(content));
            }
        }).start();
    }
View Full Code Here


                throw RuntimeMessages.MESSAGES.operationDoesNotExistForService(operation,
                        _name.toString());
            }
        }

        Exchange ex = _dispatcher.createExchange(handler, op.getExchangePattern());
        ex.consumer(this, op);

        // propagate the security context
        _securityContextManager.propagateContext(ex);

        for (Policy policy : _metadata.getRequiredPolicies()) {
View Full Code Here

               
        final int NUM_SENDS = 5;
        for (int i = 0; i < NUM_SENDS; i++) {
            new Thread(new Runnable() {
                public void run() {
                    Exchange exchange = reference.createExchange();
                    Message message = exchange.createMessage();
                    exchange.send(message);
                }
            }).start();
        }
       
        Thread.sleep(4000);
View Full Code Here

        super();
    }

    @Test
    public void testSwitchyardLevelCollection() {
        Exchange ex = createMock();
        defaultExpectations(ex);

        _builder.notify(new ExchangeCompletionEvent(ex));

        assertEquals(1, _switchYard.getMessageMetrics().getSuccessCount());
View Full Code Here

        assertEquals(10.0, _switchYard.getMessageMetrics().getAverageProcessingTime(), 0);
    }

    @Test
    public void testOperationLevelCollection() {
        Exchange ex = createMock();
        defaultExpectations(ex);

        Mockito.when(ex.getContract().getProviderOperation().getName()).thenReturn(OPERATION_NAME);

        _builder.notify(new ExchangeCompletionEvent(ex));

        assertEquals(1, _switchYard.getMessageMetrics().getSuccessCount());
        assertEquals(10.0, _switchYard.getMessageMetrics().getAverageProcessingTime(), 0);
View Full Code Here

        _dispatch = _domain.getBus().createDispatcher(reference);
    }
   
    @Test
    public void testSendFaultOnNewExchange() {
        Exchange exchange = new ExchangeImpl(_domain, _dispatch);
        try {
            exchange.sendFault(exchange.createMessage());
            Assert.fail("Sending a fault on a new exchange is not allowed");
        } catch (IllegalStateException illEx) {
            return;
        }
    }
View Full Code Here

        // Allow for the JMS Message to be processed.
        Thread.sleep(3000);

        final LinkedBlockingQueue<Exchange> recievedMessages = greetingService.getMessages();
        assertThat(recievedMessages, is(notNullValue()));
        final Exchange recievedExchange = recievedMessages.iterator().next();
        assertThat(recievedExchange.getMessage().getContent(String.class), is(equalTo(payload)));
    }
View Full Code Here

        clientSocket.close();

        greetingService.waitForOKMessage();
        final LinkedBlockingQueue<Exchange> recievedMessages = greetingService.getMessages();
        assertThat(recievedMessages, is(notNullValue()));
        final Exchange recievedExchange = recievedMessages.iterator().next();
        assertThat(PAYLOAD, is(equalTo(recievedExchange.getMessage().getContent(String.class))));
    }
View Full Code Here

        clientSocket.close();

        greetingService.waitForOKMessage();
        final LinkedBlockingQueue<Exchange> recievedMessages = greetingService.getMessages();
        assertThat(recievedMessages, is(notNullValue()));
        final Exchange recievedExchange = recievedMessages.iterator().next();
        String content = recievedExchange.getMessage().getContent(String.class);
        // the receive content is trimmed because extra bytes appended to frame by receiver
        assertThat(PAYLOAD, is(equalTo(content.trim())));
    }
View Full Code Here

        // Allow for the JMS Message to be processed.
        Thread.sleep(3000);

        final LinkedBlockingQueue<Exchange> recievedMessages = greetingService.getMessages();
        assertThat(recievedMessages, is(notNullValue()));
        final Exchange recievedExchange = recievedMessages.iterator().next();
        assertThat(recievedExchange.getMessage().getContent(String.class), is(equalTo(payload)));
    }
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.