Package org.apache.servicemix.tck

Examples of org.apache.servicemix.tck.Receiver


        sender.sendMessages(1);
        receiver.getMessageList().assertMessagesReceived(1);
    }
   
    public void testInterfaceConnection() throws Exception {
        Receiver receiver = new ReceiverComponent();
        ActivationSpec asReceiver = new ActivationSpec();
        asReceiver.setComponent(receiver);
        asReceiver.setService(new QName("service"));
        asReceiver.setEndpoint("endpoint");
       
        Sender sender = new SenderComponent();
        ActivationSpec asSender = new ActivationSpec();
        asSender.setComponent(sender);
        asSender.setDestinationInterface(new QName("interface"));
       
        container.activateComponent(asReceiver);
        container.activateComponent(asSender);
        container.getRegistry().registerInterfaceConnection(new QName("interface"), new QName("service"), "endpoint");
       
        sender.sendMessages(1);
        receiver.getMessageList().assertMessagesReceived(1);
    }
View Full Code Here


            SenderListener sender = new SenderListener();
            ActivationSpec senderActivationSpec = new ActivationSpec("sender", sender);
            senderActivationSpec.setFailIfNoDestinationEndpoint(false);
            container.activateComponent(senderActivationSpec);

            Receiver receiver1 = new ReceiverComponent();
            container.activateComponent(createReceiverAS("receiver1", receiver1));

            Receiver receiver2 = new ReceiverComponent();
            container.activateComponent(createReceiverAS("receiver2", receiver2));

            sender.sendMessages(1, sync);

            Thread.sleep(100);

            assertEquals(1, receiver1.getMessageList().getMessageCount());
            assertEquals(1, receiver2.getMessageList().getMessageCount());
            assertEquals(0, sender.responses.size());
        } finally {
            container.shutDown();
        }
    }
View Full Code Here

    protected abstract Flow createFlow();

    protected void runSimpleTest(final boolean syncSend, final boolean syncReceive) throws Exception {
        final SenderComponent sender = new SenderComponent();
        sender.setResolver(new ServiceNameEndpointResolver(ReceiverComponent.SERVICE));
        final Receiver receiver;
        if (syncReceive) {
            receiver = new ReceiverComponent();
        } else {
            receiver = new AsyncReceiverPojo();
        }

        senderContainer.activateComponent(new ActivationSpec("sender", sender));
        senderContainer.activateComponent(new ActivationSpec("receiver", receiver));

        tt.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus status) {
                try {
                    sender.sendMessages(NUM_MESSAGES, syncSend);
                } catch (JBIException e) {
                    throw new RuntimeJBIException(e);
                }
                return null;
            }
        });
        receiver.getMessageList().assertMessagesReceived(NUM_MESSAGES);
    }
View Full Code Here

    }

    protected void runClusteredTest(final boolean syncSend, final boolean syncReceive) throws Exception {
        final SenderComponent sender = new SenderComponent();
        sender.setResolver(new ServiceNameEndpointResolver(ReceiverComponent.SERVICE));
        final Receiver receiver;
        if (syncReceive) {
            receiver = new ReceiverComponent();
        } else {
            receiver = new AsyncReceiverPojo();
        }

        senderContainer.activateComponent(new ActivationSpec("sender", sender));
        receiverContainer.activateComponent(new ActivationSpec("receiver", receiver));
        Thread.sleep(1000);

        tt.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus status) {
                try {
                    sender.sendMessages(NUM_MESSAGES, syncSend);
                } catch (JBIException e) {
                    throw new RuntimeJBIException(e);
                }
                return null;
            }
        });
        receiver.getMessageList().assertMessagesReceived(NUM_MESSAGES);
    }
View Full Code Here

    protected void runSimpleTest(final boolean syncSend, final boolean syncReceive) throws Exception {
        // final int numMessages = 1;
        final int numMessages = NUM_MESSAGES;
        final SenderComponent sender = new SenderComponent();
        sender.setResolver(new ServiceNameEndpointResolver(ReceiverComponent.SERVICE));
        final Receiver receiver;
        final Map delivered = new ConcurrentHashMap();
        if (syncReceive) {
            receiver = new ReceiverComponent() {
                public void onMessageExchange(MessageExchange exchange) throws MessagingException {
                    try {
                        if (delivered.get(exchange.getExchangeId()) == null) {
                            log.info("Message delivery rolled back: " + exchange.getExchangeId());
                            delivered.put(exchange.getExchangeId(), Boolean.TRUE);
                            tm.setRollbackOnly();
                        } else {
                            log.info("Message delivery accepted: " + exchange.getExchangeId());
                            super.onMessageExchange(exchange);
                        }
                    } catch (Exception e) {
                        throw new MessagingException(e);
                    }
                }
            };
        } else {
            receiver = new AsyncReceiverPojo() {
                public void onMessageExchange(MessageExchange exchange) throws MessagingException {
                    try {
                        if (delivered.get(exchange.getExchangeId()) == null) {
                            log.info("Message delivery rolled back: " + exchange.getExchangeId());
                            delivered.put(exchange.getExchangeId(), Boolean.TRUE);
                            tm.setRollbackOnly();
                            exchange.setStatus(ExchangeStatus.DONE);
                            getContext().getDeliveryChannel().send(exchange);
                        } else {
                            log.info("Message delivery accepted: " + exchange.getExchangeId());
                            super.onMessageExchange(exchange);
                        }
                    } catch (Exception e) {
                        throw new MessagingException(e);
                    }
                }
            };
        }

        senderContainer.activateComponent(new ActivationSpec("sender", sender));
        senderContainer.activateComponent(new ActivationSpec("receiver", receiver));

        tt.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus status) {
                try {
                    sender.sendMessages(numMessages, syncSend);
                } catch (JBIException e) {
                    throw new RuntimeJBIException(e);
                }
                return null;
            }
        });
        //sender.sendMessages(NUM_MESSAGES, syncSend);
        receiver.getMessageList().assertMessagesReceived(numMessages);
    }
View Full Code Here

     * client.createEndpoint(destinationUri, messageList); return answer; }
     */

    protected MessageList createMessageList() throws Exception {
        SpringJBIContainer jbi = (SpringJBIContainer) getBean("jbi");
        Receiver receiver = (Receiver) jbi.getBean("receiver");
        assertNotNull("receiver not found in JBI container", receiver);
        return receiver.getMessageList();
    }
View Full Code Here

            message.setProperty(DefaultFileMarshaler.FILE_NAME_PROPERTY, "test" + i + ".xml");
            message.setContent(new StringSource("<hello>world</hello>"));
            client.sendSync(me);
        }

        Receiver receiver = (Receiver) getBean("receiver");
        receiver.getMessageList().assertMessagesReceived(NUMBER);
    }
View Full Code Here

     * client.createEndpoint(destinationUri, messageList); return answer; }
     */

    protected MessageList createMessageList() throws Exception {
        SpringJBIContainer jbi = (SpringJBIContainer) getBean("jbi");
        Receiver receiver = (Receiver) jbi.getBean("receiver");
        assertNotNull("receiver not found in JBI container", receiver);
        return receiver.getMessageList();
    }
View Full Code Here

        HttpComponent component = new HttpComponent();
        component.getConfiguration().setStreamingEnabled(streaming);
        container.activateComponent(component, "HttpProviderTest");

        // Add a receiver component
        Receiver receiver = new ReceiverComponent();
        ActivationSpec asReceiver = new ActivationSpec("receiver", receiver);
        asReceiver.setService(new QName("test", "receiver"));
        container.activateComponent(asReceiver);

        // Add the http receiver
        HttpConnector connector = new HttpConnector("localhost", 8192);
        connector.setDefaultInOut(false);
        ActivationSpec asConnector = new ActivationSpec("connector", connector);
        asConnector.setDestinationService(new QName("test", "receiver"));
        container.activateComponent(asConnector);

        // Start container
        container.start();

        // Deploy SU
        URL url = getClass().getClassLoader().getResource("provider/http.wsdl");
        File path = new File(new URI(url.toString()));
        path = path.getParentFile();
        component.getServiceUnitManager().deploy("provider",
                path.getAbsolutePath());
        component.getServiceUnitManager().start("provider");

        // Call it
        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
        RobustInOnly in = client.createRobustInOnlyExchange();
        in.setInterfaceName(new QName("http://http.servicemix.org/Test",
                "ProviderInterface"));
        in.getInMessage().setContent(
                new StreamSource(new ByteArrayInputStream(msg.getBytes())));

        long t0 = System.currentTimeMillis();
        client.sendSync(in);
        long t1 = System.currentTimeMillis();
        assertTrue(in.getStatus() == ExchangeStatus.DONE);

        // Check we received the message
        receiver.getMessageList().assertMessagesReceived(1);

        component.getServiceUnitManager().stop("provider");
        component.getServiceUnitManager().shutDown("provider");
        component.getServiceUnitManager().undeploy("provider",
                path.getAbsolutePath());
View Full Code Here

        HttpComponent component = new HttpComponent();
        component.getConfiguration().setStreamingEnabled(streaming);
        container.activateComponent(component, "HttpProviderTest");

        // Add a receiver component
        Receiver receiver = new ReceiverComponent();
        ActivationSpec asReceiver = new ActivationSpec("receiver", receiver);
        asReceiver.setService(new QName("test", "receiver"));
        container.activateComponent(asReceiver);

        // Add the http receiver
        HttpConnector connector = new HttpConnector("localhost", 9192);
        connector.setDefaultInOut(false);
        ActivationSpec asConnector = new ActivationSpec("connector", connector);
        asConnector.setDestinationService(new QName("test", "receiver"));
        container.activateComponent(asConnector);

        // Start container
        container.start();

        // Deploy SU
        URL url = getClass().getClassLoader().getResource("provider/http.wsdl");
        File path = new File(new URI(url.toString()));
        path = path.getParentFile();
        component.getServiceUnitManager().deploy("provider",
                path.getAbsolutePath());
        component.getServiceUnitManager().start("provider");

        // Call it
        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
        RobustInOnly in = client.createRobustInOnlyExchange();
        in.setInterfaceName(new QName("http://http.servicemix.org/Test",
                "ProviderInterface"));
        in.getInMessage().setContent(
                new StreamSource(new ByteArrayInputStream(msg.getBytes())));
        in.getInMessage().setProperty(JbiConstants.HTTP_DESTINATION_URI,
                "http://localhost:9192/CheckAvailability");

        long t0 = System.currentTimeMillis();
        client.sendSync(in);
        long t1 = System.currentTimeMillis();
        assertTrue(in.getStatus() == ExchangeStatus.DONE);

        // Check we received the message
        receiver.getMessageList().assertMessagesReceived(1);

        component.getServiceUnitManager().stop("provider");
        component.getServiceUnitManager().shutDown("provider");
        component.getServiceUnitManager().undeploy("provider",
                path.getAbsolutePath());
View Full Code Here

TOP

Related Classes of org.apache.servicemix.tck.Receiver

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.