Package org.apache.servicemix.tck

Examples of org.apache.servicemix.tck.Receiver


     * 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


    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

    ((HttpLifeCycle) component.getLifeCycle()).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();
        ((HttpLifeCycle) component.getLifeCycle()).getConfiguration().setStreamingEnabled(streaming);
        container.activateComponent(component, "HTTPComponent");
       
        // Add a receiver component
        Receiver receiver = new ReceiverComponent();
        ActivationSpec asReceiver = new ActivationSpec("receiver", receiver);
        asReceiver.setService(new QName("http://http.servicemix.org/Test", "ConsumerInOnly"));
        container.activateComponent(asReceiver);
       
        // Add the http invoker
        HttpInvoker invoker = new HttpInvoker();
        invoker.setDefaultInOut(false);
        invoker.setUrl("http://localhost:8192/InOnly/");
        invoker.setMarshaler(new HttpSoapClientMarshaler(true));
        ActivationSpec asInvoker = new ActivationSpec("invoker", invoker);
        asInvoker.setService(new QName("urn:test", "invoker"));
        container.activateComponent(asInvoker);
       
        // Start container
        container.start();

        // Deploy SU
        URL url = getClass().getClassLoader().getResource("consumer/http.wsdl");
        File path = new File(new URI(url.toString()));
        path = path.getParentFile();
        component.getServiceUnitManager().deploy("consumer", path.getAbsolutePath());
        component.getServiceUnitManager().start("consumer");
       
        // Call it
        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
        RobustInOnly in = client.createRobustInOnlyExchange();
        in.setService(new QName("urn:test", "invoker"));
        in.getInMessage().setContent(new StreamSource(new ByteArrayInputStream(msg.getBytes())));
       
        long t0 = System.currentTimeMillis();
        client.sendSync(in);
        long t1 = System.currentTimeMillis();
        assertEquals(ExchangeStatus.DONE, in.getStatus());
       
        // Check we received the message
        receiver.getMessageList().assertMessagesReceived(1);
       
        return t1 - t0;
    }
View Full Code Here

        wsnComponent.getServiceUnitManager().deploy("subscription", path.getAbsolutePath());

        ActivationSpec consumer = new ActivationSpec();
        consumer.setService(new QName("http://www.consumer.org", "service"));
        consumer.setEndpoint("endpoint");
        Receiver receiver = new ReceiverComponent();
        consumer.setComponent(receiver);
        jbi.activateComponent(consumer);

        wsnComponent.getServiceUnitManager().start("subscription");

        wsnBroker.notify("myTopic", parse("<hello>world</hello>"));
        // Wait for notification
        Thread.sleep(50);
        receiver.getMessageList().assertMessagesReceived(1);
        receiver.getMessageList().flushMessages();

        wsnComponent.getServiceUnitManager().stop("subscription");

        wsnBroker.notify("myTopic", parse("<hello>world</hello>"));
        // Wait for notification
        Thread.sleep(50);
        assertEquals(0, receiver.getMessageList().flushMessages().size());

        wsnComponent.getServiceUnitManager().start("subscription");

        wsnBroker.notify("myTopic", parse("<hello>world</hello>"));
        // Wait for notification
        Thread.sleep(50);
        receiver.getMessageList().assertMessagesReceived(1);
        receiver.getMessageList().flushMessages();
    }
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) {
                            AbstractPersistenceTest.LOGGER.info("Message delivery rolled back: {}", exchange.getExchangeId());
                            delivered.put(exchange.getExchangeId(), Boolean.TRUE);
                            tm.setRollbackOnly();
                        } else {
                            AbstractPersistenceTest.LOGGER.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) {
                            LOGGER.info("Message delivery rolled back: {}", exchange.getExchangeId());
                            delivered.put(exchange.getExchangeId(), Boolean.TRUE);
                            tm.setRollbackOnly();
                            exchange.setStatus(ExchangeStatus.DONE);
                            getContext().getDeliveryChannel().send(exchange);
                        } else {
                            LOGGER.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

        wsnComponent.getServiceUnitManager().deploy("subscription", path.getAbsolutePath());

        ActivationSpec consumer = new ActivationSpec();
        consumer.setService(new QName("http://www.consumer.org", "service"));
        consumer.setEndpoint("endpoint");
        Receiver receiver = new ReceiverComponent();
        consumer.setComponent(receiver);
        jbi.activateComponent(consumer);

        wsnComponent.getServiceUnitManager().start("subscription");

        wsnBroker.notify("myTopic", parse("<hello>world</hello>"));
        // Wait for notification
        Thread.sleep(timeout);
        receiver.getMessageList().assertMessagesReceived(1);
        receiver.getMessageList().flushMessages();

        wsnComponent.getServiceUnitManager().stop("subscription");

        wsnBroker.notify("myTopic", parse("<hello>world</hello>"));
        // Wait for notification
        Thread.sleep(timeout);
        assertEquals(0, receiver.getMessageList().flushMessages().size());

        wsnComponent.getServiceUnitManager().start("subscription");

        wsnBroker.notify("myTopic", parse("<hello>world</hello>"));
        // Wait for notification
        Thread.sleep(timeout);
        receiver.getMessageList().assertMessagesReceived(1);
        receiver.getMessageList().flushMessages();
    }
View Full Code Here

            txt.setText("<hello>" + i + "</hello>");
            producer.send(txt);
        }
        System.out.println("Message sent");
       
        Receiver receiver = (Receiver) getBean("receiver");
        receiver.getMessageList().waitForMessagesToArrive(messageCount, 60000);
        assertEquals("expected number of messages", messageCount, receiver.getMessageList().getMessageCount());
    }
View Full Code Here

    protected void tearDown() throws Exception {
        container.shutDown();
    }
   
    public void testEndpointConnection() 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.setDestinationService(new QName("service"));
        asSender.setDestinationEndpoint("linkedEndpoint");
       
        container.activateComponent(asReceiver);
        container.activateComponent(asSender);
        container.getRegistry().registerEndpointConnection(new QName("service"), "linkedEndpoint", new QName("service"), "endpoint", null);
       
        sender.sendMessages(1);
        receiver.getMessageList().assertMessagesReceived(1);
    }
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.