Package org.apache.servicemix.tck

Examples of org.apache.servicemix.tck.ReceiverComponent


        configurePattern(recipientList);
        activateComponent(recipientList, "recipientList");
    }

    public void testInOnlySync() throws Exception {
        ReceiverComponent r1 = activateReceiver("recipient1");
        ReceiverComponent r2 = activateReceiver("recipient2");
        ReceiverComponent r3 = activateReceiver("recipient3");
       
        tm.begin();
       
        InOnly me = client.createInOnlyExchange();
        me.setService(new QName("recipientList"));
        me.getInMessage().setContent(createSource("<hello/>"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        tm.commit();
       
        r1.getMessageList().assertMessagesReceived(1);
        r2.getMessageList().assertMessagesReceived(1);
        r3.getMessageList().assertMessagesReceived(1);
    }
View Full Code Here


        r2.getMessageList().assertMessagesReceived(1);
        r3.getMessageList().assertMessagesReceived(1);
    }
   
    public void testInOnlyAsync() throws Exception {
        ReceiverComponent r1 = activateReceiver("recipient1");
        ReceiverComponent r2 = activateReceiver("recipient2");
        ReceiverComponent r3 = activateReceiver("recipient3");
       
        tm.begin();
       
        InOnly me = client.createInOnlyExchange();
        me.setService(new QName("recipientList"));
        me.getInMessage().setContent(createSource("<hello/>"));
        client.send(me);
       
        tm.commit();

        me = (InOnly) client.receive();
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        r1.getMessageList().assertMessagesReceived(1);
        r2.getMessageList().assertMessagesReceived(1);
        r3.getMessageList().assertMessagesReceived(1);
    }
View Full Code Here

        configurePattern(router);
        activateComponent(router, "router");
    }
   
    public void testInOnly() throws Exception {
        ReceiverComponent rec1 = activateReceiver("target1");
        ReceiverComponent rec2 = activateReceiver("target2");
        ReceiverComponent rec3 = activateReceiver("target3");
       
        InOnly me = client.createInOnlyExchange();
        me.setService(new QName("router"));
        me.getInMessage().setContent(createSource("<hello id='1' />"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        rec1.getMessageList().assertMessagesReceived(1);
        rec2.getMessageList().assertMessagesReceived(0);
        rec3.getMessageList().assertMessagesReceived(0);

        rec1.getMessageList().flushMessages();
        rec2.getMessageList().flushMessages();
        rec3.getMessageList().flushMessages();

        me = client.createInOnlyExchange();
        me.setService(new QName("router"));
        me.getInMessage().setContent(createSource("<hello id='2' />"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        rec1.getMessageList().assertMessagesReceived(0);
        rec2.getMessageList().assertMessagesReceived(1);
        rec3.getMessageList().assertMessagesReceived(0);

        rec1.getMessageList().flushMessages();
        rec2.getMessageList().flushMessages();
        rec3.getMessageList().flushMessages();

        me = client.createInOnlyExchange();
        me.setService(new QName("router"));
        me.getInMessage().setContent(createSource("<hello id='3' />"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        rec1.getMessageList().assertMessagesReceived(0);
        rec2.getMessageList().assertMessagesReceived(0);
        rec3.getMessageList().assertMessagesReceived(1);
    }
View Full Code Here

    public void testInOnly() throws Exception {

        activateComponent(new ReturnMockComponent("<halloMock/>"),
                "enricherTarget");

        ReceiverComponent rec = activateReceiver("target");

        InOnly me = client.createInOnlyExchange();

        me.setService(new QName("enricher"));
        me.getInMessage().setContent(createSource("<hello/>"));
        client.sendSync(me);

        assertEquals(ExchangeStatus.DONE, me.getStatus());

        assertEquals(1, rec.getMessageList().getMessageCount());

        NormalizedMessage object = (NormalizedMessage) rec.getMessageList()
                .getMessages().get(0);

        DOMSource domSource = (DOMSource) object.getContent();
        Document doc = (Document) domSource.getNode();
       
View Full Code Here

        configurePattern(aggregator);
        activateComponent(aggregator, "aggregator");
    }
   
    protected NormalizedMessage testRun(boolean[] msgs, boolean async) throws Exception {
        ReceiverComponent rec = activateReceiver("target");
       
        int nbMessages = 3;
        String corrId = Long.toString(System.currentTimeMillis());
        for (int i = 0; i < 3; i++) {
            if (msgs == null || msgs[i]) {
                InOnly me = client.createInOnlyExchange();
                me.setService(new QName("aggregator"));
                me.getInMessage().setContent(createSource("<hello id='" + i + "' />"));
                me.getInMessage().setProperty(AbstractSplitter.SPLITTER_COUNT, new Integer(nbMessages));
                me.getInMessage().setProperty(AbstractSplitter.SPLITTER_INDEX, new Integer(i));
                me.getInMessage().setProperty(AbstractSplitter.SPLITTER_CORRID, corrId);
                tm.begin();
                if (async) {
                    client.send(me);
                } else {
                    client.sendSync(me);
                }
                tm.commit();
            }
        }       
       
        rec.getMessageList().assertMessagesReceived(1);
        return (NormalizedMessage) rec.getMessageList().flushMessages().get(0);
    }
View Full Code Here

        configurePattern(router);
        activateComponent(router, "router");
    }
   
    public void testInOnlySync() throws Exception {
        ReceiverComponent rec1 = activateReceiver("target1");
        ReceiverComponent rec2 = activateReceiver("target2");
        ReceiverComponent rec3 = activateReceiver("target3");
       
        tm.begin();
       
        InOnly me = client.createInOnlyExchange();
        me.setService(new QName("router"));
        me.getInMessage().setContent(createSource("<hello id='1' />"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        rec1.getMessageList().assertMessagesReceived(1);
        rec2.getMessageList().assertMessagesReceived(0);
        rec3.getMessageList().assertMessagesReceived(0);

        rec1.getMessageList().flushMessages();
        rec2.getMessageList().flushMessages();
        rec3.getMessageList().flushMessages();
       
        me = client.createInOnlyExchange();
        me.setService(new QName("router"));
        me.getInMessage().setContent(createSource("<hello id='2' />"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        rec1.getMessageList().assertMessagesReceived(0);
        rec2.getMessageList().assertMessagesReceived(1);
        rec3.getMessageList().assertMessagesReceived(0);

        rec1.getMessageList().flushMessages();
        rec2.getMessageList().flushMessages();
        rec3.getMessageList().flushMessages();

        me = client.createInOnlyExchange();
        me.setService(new QName("router"));
        me.getInMessage().setContent(createSource("<hello id='3' />"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        rec1.getMessageList().assertMessagesReceived(0);
        rec2.getMessageList().assertMessagesReceived(0);
        rec3.getMessageList().assertMessagesReceived(1);

        tm.commit();
    }
View Full Code Here

        tm.commit();
    }

    public void testInOnlyAsync() throws Exception {
        ReceiverComponent rec1 = activateReceiver("target1");
        ReceiverComponent rec2 = activateReceiver("target2");
        ReceiverComponent rec3 = activateReceiver("target3");
       
        tm.begin();
       
        InOnly me = client.createInOnlyExchange();
        me.setService(new QName("router"));
        me.getInMessage().setContent(createSource("<hello id='1' />"));
        client.send(me);
       
        me = client.createInOnlyExchange();
        me.setService(new QName("router"));
        me.getInMessage().setContent(createSource("<hello id='2' />"));
        client.send(me);
       
        me = client.createInOnlyExchange();
        me.setService(new QName("router"));
        me.getInMessage().setContent(createSource("<hello id='3' />"));
        client.send(me);
       
        tm.commit();
       
        me = (InOnly) client.receive();
        assertEquals(ExchangeStatus.DONE, me.getStatus());
        me = (InOnly) client.receive();
        assertEquals(ExchangeStatus.DONE, me.getStatus());
        me = (InOnly) client.receive();
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        rec1.getMessageList().assertMessagesReceived(1);
        rec2.getMessageList().assertMessagesReceived(1);
        rec3.getMessageList().assertMessagesReceived(1);
    }
View Full Code Here

        target.setService(name);
        return target;
    }
   
    protected ReceiverComponent activateReceiver(String name) throws Exception {
        ReceiverComponent receiver = new ReceiverComponent();
        activateComponent(receiver, name);
        return receiver;
    }
View Full Code Here

            // ok
        }
    }

    public void testNotify() throws Exception {
        ReceiverComponent receiver = new ReceiverComponent();
        jbi.activateComponent(receiver, "receiver");

        EndpointReferenceType consumer = createEPR(ReceiverComponent.SERVICE, ReceiverComponent.ENDPOINT);
        wsnBroker.subscribe(consumer, "myTopic", null);

        wsnBroker.notify("myTopic", parse("<hello>world</hello>"));
        // Wait for notification
        Thread.sleep(150);

        receiver.getMessageList().assertMessagesReceived(1);
        NormalizedMessage msg = (NormalizedMessage) receiver.getMessageList().getMessages().get(0);
        Node node = new SourceTransformer().toDOMNode(msg);
        assertEquals("Notify", node.getLocalName());

        // Wait for acks to be processed
        Thread.sleep(150);
View Full Code Here

        configurePattern(splitter);
        activateComponent(splitter, "splitter");
    }
   
    public void testSync() throws Exception {
        ReceiverComponent rec = activateReceiver("target");
       
        tm.begin();
       
        InOnly me = client.createInOnlyExchange();
        me.setService(new QName("splitter"));
        me.getInMessage().setContent(createSource("<hello><one/><two/><three/></hello>"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        tm.commit();
       
        rec.getMessageList().assertMessagesReceived(3);
    }
View Full Code Here

TOP

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

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.