Package org.apache.servicemix.tck

Examples of org.apache.servicemix.tck.SenderComponent


        Thread.sleep(3000);
        receiver.getMessageList().assertMessagesReceived(NUM_MESSAGES);
    }

    public void testClusteredInOnly() throws Exception {
        final SenderComponent sender2 = new SenderComponent();
        final ReceiverComponent receiver1 =  new ReceiverComponent();
        final ReceiverComponent receiver2 =  new ReceiverComponent();
        sender2.setResolver(new ServiceNameEndpointResolver(ReceiverComponent.SERVICE));

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

        sender2.sendMessages(NUM_MESSAGES);
        Thread.sleep(3000);
        assertTrue(receiver1.getMessageList().hasReceivedMessage());
        assertTrue(receiver2.getMessageList().hasReceivedMessage());
        receiver1.getMessageList().flushMessages();
        receiver2.getMessageList().flushMessages();
       
        senderContainer.deactivateComponent("receiver");
        Thread.sleep(1000);
       
        sender2.sendMessages(NUM_MESSAGES);
        Thread.sleep(3000);
        assertFalse(receiver1.getMessageList().hasReceivedMessage());
        assertTrue(receiver2.getMessageList().hasReceivedMessage());
        receiver1.getMessageList().flushMessages();
        receiver2.getMessageList().flushMessages();
       
        senderContainer.activateComponent(new ActivationSpec("receiver", receiver1));
        receiverContainer.deactivateComponent("receiver");
        Thread.sleep(1000);
       
        sender2.sendMessages(NUM_MESSAGES);
        Thread.sleep(3000);
        assertTrue(receiver1.getMessageList().hasReceivedMessage());
        assertFalse(receiver2.getMessageList().hasReceivedMessage());
        receiver1.getMessageList().flushMessages();
        receiver2.getMessageList().flushMessages();
View Full Code Here


            }
            container.setEmbedded(true);
            container.init();
            container.start();

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

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

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

            sender.sendMessages(1);

            Thread.sleep(100);

            assertFalse(receiver1.isPropertySetOnExchange());
            assertFalse(receiver2.isPropertySetOnExchange());
View Full Code Here

        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

        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

  protected QName getComponentService() {
    return new QName("http://www.neogrid.com.br", "component");
  }

  private void setUpSender() throws Exception {
    sender = new SenderComponent();
    ActivationSpec as = new ActivationSpec(SenderComponent.ENDPOINT, sender);
    as.setService(SenderComponent.SERVICE);
    as.setDestinationService(getComponentService());
    jbiContainer.activateComponent(as);
  }
View Full Code Here

        receiverContainer.shutDown();
        broker.stop();
    }

    public void testInOnly() throws Exception {
        final SenderComponent sender = new SenderComponent();
        final ReceiverComponent receiver = new ReceiverComponent();
        sender.setResolver(new ServiceNameEndpointResolver(ReceiverComponent.SERVICE));

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

        Thread.sleep(5000);

        sender.sendMessages(NUM_MESSAGES);
        Thread.sleep(3000);
        receiver.getMessageList().assertMessagesReceived(NUM_MESSAGES);
    }
View Full Code Here

        Thread.sleep(3000);
        receiver.getMessageList().assertMessagesReceived(NUM_MESSAGES);
    }

    public void testTxInOnly() throws Exception {
        final SenderComponent sender = new SenderComponent();
        final ReceiverComponent receiver = new ReceiverComponent();
        sender.setResolver(new ServiceNameEndpointResolver(ReceiverComponent.SERVICE));

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

        Thread.sleep(5000);

        senderContainer.setAutoEnlistInTransaction(true);
        tt.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus status) {
                try {
                    sender.sendMessages(NUM_MESSAGES);
                } catch (JBIException e) {
                    throw new RuntimeJBIException(e);
                }
                return null;
            }
View Full Code Here

        Thread.sleep(3000);
        receiver.getMessageList().assertMessagesReceived(NUM_MESSAGES);
    }

    public void testClusteredInOnly() throws Exception {
        final SenderComponent sender = new SenderComponent();
        final ReceiverComponent receiver1 = new ReceiverComponent();
        final ReceiverComponent receiver2 = new ReceiverComponent();
        sender.setResolver(new ServiceNameEndpointResolver(ReceiverComponent.SERVICE));

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

        sender.sendMessages(NUM_MESSAGES);
        Thread.sleep(3000);
        assertTrue(receiver1.getMessageList().hasReceivedMessage());
        assertTrue(receiver2.getMessageList().hasReceivedMessage());
        receiver1.getMessageList().flushMessages();
        receiver2.getMessageList().flushMessages();

        senderContainer.deactivateComponent("receiver");
        Thread.sleep(1000);

        sender.sendMessages(NUM_MESSAGES);
        Thread.sleep(3000);
        assertFalse(receiver1.getMessageList().hasReceivedMessage());
        assertTrue(receiver2.getMessageList().hasReceivedMessage());
        receiver1.getMessageList().flushMessages();
        receiver2.getMessageList().flushMessages();

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

        sender.sendMessages(NUM_MESSAGES);
        Thread.sleep(3000);
        assertTrue(receiver1.getMessageList().hasReceivedMessage());
        assertFalse(receiver2.getMessageList().hasReceivedMessage());
        receiver1.getMessageList().flushMessages();
        receiver2.getMessageList().flushMessages();
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;
            }
View Full Code Here

        receiverContainer.shutDown();
        super.tearDown();
    }

    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;
            }
View Full Code Here

TOP

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

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.