Package org.apache.servicemix.tck

Examples of org.apache.servicemix.tck.ReceiverComponent


        e = DOMUtils.getFirstChildElement(e);
        assertEquals(new QName(SoapMarshaler.SOAP_11_URI, SoapMarshaler.FAULT), DOMUtil.getQName(e));
    }

    public void testSoapXml() throws Exception {
        ReceiverComponent echo = new ReceiverComponent();
        echo.setService(new QName("urn:test", "echo"));
        echo.setEndpoint("echo");
        container.activateComponent(echo, "echo");
       
        HttpEndpoint ep1 = new HttpEndpoint();
        ep1.setService(new QName("urn:test", "http"));
        ep1.setEndpoint("ep1");
        ep1.setTargetService(new QName("urn:test", "echo"));
        ep1.setTargetEndpoint("echo");
        ep1.setLocationURI("http://localhost:8193/ep1/");
        ep1.setRoleAsString("consumer");
        ep1.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-only"));
        ep1.setSoap(false);
       
        HttpEndpoint ep2 = new HttpEndpoint();
        ep2.setService(new QName("urn:test", "http"));
        ep2.setEndpoint("ep2");
        ep2.setTargetService(new QName("urn:test", "http"));
        ep2.setTargetEndpoint("ep3");
        ep2.setLocationURI("http://localhost:8193/ep2/");
        ep2.setRoleAsString("consumer");
        ep2.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-only"));
        ep2.setSoap(true);
       
        HttpEndpoint ep3 = new HttpEndpoint();
        ep3.setService(new QName("urn:test", "http"));
        ep3.setEndpoint("ep3");
        ep3.setLocationURI("http://localhost:8193/ep1/");
        ep3.setRoleAsString("provider");
        ep3.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-only"));
        ep3.setSoap(true);
       
        HttpSpringComponent http = new HttpSpringComponent();
        http.setEndpoints(new HttpEndpoint[] { ep1, ep2, ep3 });
        container.activateComponent(http, "http1");
       
        container.start();
       
        PostMethod method = new PostMethod("http://localhost:8193/ep2/");
        method.setRequestEntity(new InputStreamRequestEntity(getClass().getResourceAsStream("request.xml")));
        new HttpClient().executeMethod(method);
       
        echo.getMessageList().assertMessagesReceived(1);
        List msgs = echo.getMessageList().flushMessages();
        NormalizedMessage msg = (NormalizedMessage) msgs.get(0);
        SourceTransformer st = new SourceTransformer();
        Element e = st.toDOMElement(msg);
        String strMsg = DOMUtil.asXML(e);
        System.err.println(strMsg);
View Full Code Here


        ep.setLocationURI("http://localhost:8192/");
        ep.setDefaultMep(MessageExchangeSupport.IN_ONLY);
        http.setEndpoints(new HttpEndpoint[] { ep });
        jbi.activateComponent(http, "servicemix-http");

        ReceiverComponent receiver = new ReceiverComponent();
        jbi.activateComponent(receiver, "receiver");

        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
        DocumentFragment epr = URIResolver.createWSAEPR("http://localhost:8192?http.soap=true");
        ServiceEndpoint se = client.getContext().resolveEndpointReference(epr);
        assertNotNull(se);

        InOnly inonly = client.createInOnlyExchange();
        inonly.setEndpoint(se);
        inonly.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(inonly);

        assertEquals(ExchangeStatus.DONE, inonly.getStatus());
        receiver.getMessageList().assertMessagesReceived(1);
        List msgs = receiver.getMessageList().flushMessages();
        NormalizedMessage msg = (NormalizedMessage) msgs.get(0);
        Element elem = new SourceTransformer().toDOMElement(msg);
        assertEquals("http://www.w3.org/2003/05/soap-envelope", elem.getNamespaceURI());
        assertEquals("env:Envelope", elem.getNodeName());
        System.out.println(new SourceTransformer().contentToString(msg));
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

        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' />"));
        try {
            client.send(me);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
       
        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

    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

        enricher.setCopyProperties(true);
       
        activateComponent(new ReturnMockComponent("<helloMock/>"), "enricherTarget");

        ReceiverComponent rec = activateReceiver("target");

        InOnly me = client.createInOnlyExchange();

        me.setService(new QName("enricher"));
        me.getInMessage().setContent(createSource("<hello/>"));
        me.getInMessage().setProperty(propName1, propVal1);
        me.getInMessage().setProperty(propName2, propVal2);
        client.sendSync(me);
               
        NormalizedMessage msg = (NormalizedMessage) rec.getMessageList()
            .getMessages().get(0);

        //assertions
        assertEquals(ExchangeStatus.DONE, me.getStatus());
        assertEquals(1, rec.getMessageList().getMessageCount());
        assertEquals(propVal1, msg.getProperty(propName1));
        assertEquals(propVal2, msg.getProperty(propName2));
        assertEquals(ReturnMockComponent.PROPERTY_VALUE, msg.getProperty(ReturnMockComponent.PROPERTY_NAME));
    }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public void testAsync() throws Exception {
        int numMessages = 5;
        ReceiverComponent receiver = activateReceiver(TARGET_NAME);
        //
        // This test depends on copyProperties of the CopyTransformer
        // singleton being set to true (the default).  However, if the
        // SpringConfigurationTest runs before this test (as it does on
        // the ibm jdk) copyProperties will be configured to false.  So,
        // explicitly ensure it is set to the default value of true here.
        //
        if (receiver.getMessageTransformer() instanceof CopyTransformer) {
            CopyTransformer copyTransformer = (CopyTransformer)receiver.getMessageTransformer();
            if (!copyTransformer.isCopyProperties()) {
                copyTransformer.setCopyProperties(true);
            }
        }
        client.send(createTestMessageExchange(4));
        client.send(createTestMessageExchange(1));
        client.send(createTestMessageExchange(3));
        client.send(createTestMessageExchange(5));
        client.send(createTestMessageExchange(2));
        MessageList ml = receiver.getMessageList();
        ml.waitForMessagesToArrive(numMessages);
        assertEquals("wrong number of messages", numMessages, ml.getMessageCount());
        for (int i = 0; i < numMessages; i++) {
            assertSequenceProperties((NormalizedMessage)ml.getMessages().get(i), i + 1);
        }
View Full Code Here

        configurePattern(wireTap);
        activateComponent(wireTap, "wireTap");
    }
   
    public void testInOnly() throws Exception {
        ReceiverComponent target = activateReceiver("target");

        InOnly me = client.createInOnlyExchange();
        me.setService(new QName("wireTap"));
        me.getInMessage().setContent(createSource("<hello/>"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        target.getMessageList().assertMessagesReceived(1);
        inReceiver.getMessageList().assertMessagesReceived(1);
        outReceiver.getMessageList().assertMessagesReceived(0);
        faultReceiver.getMessageList().assertMessagesReceived(0);
       
        listener.assertExchangeCompleted();
View Full Code Here

       
        listener.assertExchangeCompleted();
    }
   
    public void testRobustInOnly() throws Exception {
        ReceiverComponent target = activateReceiver("target");

        RobustInOnly me = client.createRobustInOnlyExchange();
        me.setService(new QName("wireTap"));
        me.getInMessage().setContent(createSource("<hello/>"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        target.getMessageList().assertMessagesReceived(1);
        inReceiver.getMessageList().assertMessagesReceived(1);
        outReceiver.getMessageList().assertMessagesReceived(0);
        faultReceiver.getMessageList().assertMessagesReceived(0);
       
        listener.assertExchangeCompleted();
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.