Package org.apache.servicemix.tck

Examples of org.apache.servicemix.tck.ReceiverComponent


      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


        endpoint.setPojo(new ComplexPojoImpl());
        endpoint.setServiceInterface(ComplexPojo.class.getName());
        component.setEndpoints(new Jsr181Endpoint[] { endpoint });
        container.activateComponent(component, "JSR181Component");
       
        ReceiverComponent receiver = new ReceiverComponent();
        container.activateComponent(receiver, "Receiver");
       
        container.start();

        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
View Full Code Here

        httpReceiver.setSoap(true);

        httpComponent.setEndpoints(new HttpEndpoint[] { httpWSNBroker, httpReceiver });
        jbi.activateComponent(new ActivationSpec("servicemix-http", httpComponent));

        ReceiverComponent receiver = new ReceiverComponent();
        receiver.setService(new QName("receiver"));
        receiver.setEndpoint("endpoint");
        jbi.activateComponent(new ActivationSpec("receiver", receiver));

        EndpointReferenceType epr = new EndpointReferenceType();
        epr.setAddress(new AttributedURIType());
        epr.getAddress().setValue("http://localhost:8192/Receiver/?http.soap=true");
        wsnBroker.subscribe(epr, "myTopic", null);
        wsnBroker.notify("myTopic", parse("<hello>world</hello>"));

        receiver.getMessageList().assertMessagesReceived(1);
    }
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(50);

        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(50);
View Full Code Here

        // Wait for acks to be processed
        Thread.sleep(50);
    }

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

        // START SNIPPET: notify
        EndpointReferenceType consumer = createEPR(ReceiverComponent.SERVICE, ReceiverComponent.ENDPOINT);
        wsnBroker.subscribe(consumer, "myTopic", null, true);

        Element body = parse("<hello>world</hello>");
        wsnBroker.notify("myTopic", body);
        // END SNIPPET: notify

        // Wait for notification
        Thread.sleep(50);

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

        // Wait for acks to be processed
        Thread.sleep(50);
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

    ((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

        activateComponent(pipeline, "pipeline");
    }
   
    public void testInOnlySync() throws Exception {
        activateComponent(new ReturnOutComponent(), "transformer");
        ReceiverComponent target = activateReceiver("target");

        tm.begin();
       
        InOnly me = client.createInOnlyExchange();
        me.setService(new QName("pipeline"));
        me.getInMessage().setContent(createSource("<hello/>"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        tm.commit();
       
        target.getMessageList().assertMessagesReceived(1);
       
        listener.assertExchangeCompleted();
    }
View Full Code Here

        listener.assertExchangeCompleted();
    }
   
    public void testInOnlyAsync() throws Exception {
        activateComponent(new ReturnOutComponent(), "transformer");
        ReceiverComponent target = activateReceiver("target");

        tm.begin();
       
        InOnly me = client.createInOnlyExchange();
        me.setService(new QName("pipeline"));
        me.getInMessage().setContent(createSource("<hello/>"));
        client.send(me);
       
        tm.commit();
       
        me = (InOnly) client.receive();
        assertEquals(ExchangeStatus.DONE, me.getStatus());
       
        target.getMessageList().assertMessagesReceived(1);
       
        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.