Package org.apache.servicemix.client

Examples of org.apache.servicemix.client.DefaultServiceMixClient


public class SpringConfigurationTest extends SpringTestSupport {

    public void testConfig() throws Exception {
        ActivationSpec as = new ActivationSpec();
        as.setComponentName("client");
        ServiceMixClient client = new DefaultServiceMixClient(jbi, as);
       
        int nbMsgs = 10;
        for (int i = 0; i < nbMsgs; i++) {
            InOnly me = client.createInOnlyExchange();
            me.setService(new QName("http://test", "entryPoint"));
            me.getInMessage().setContent(new StringSource(
                    "<test xmlns=\"http://test\"><echo/><world/><earth/></test>"));
            client.sendSync(me);
        }       
        ((Receiver) getBean("trace1")).getMessageList().assertMessagesReceived(1 * nbMsgs);
        ((Receiver) getBean("trace2")).getMessageList().assertMessagesReceived(1 * nbMsgs);
        ((Receiver) getBean("trace3")).getMessageList().assertMessagesReceived(1 * nbMsgs);
        ((Receiver) getBean("trace4")).getMessageList().assertMessagesReceived(2 * nbMsgs);
 
View Full Code Here


    }

    public void testConfigAsync() throws Exception {
        ActivationSpec as = new ActivationSpec();
        as.setComponentName("client");
        ServiceMixClient client = new DefaultServiceMixClient(jbi, as);
       
        int nbMsgs = 100;
        for (int i = 0; i < nbMsgs; i++) {
            InOnly me = client.createInOnlyExchange();
            me.setService(new QName("http://test", "entryPoint"));
            me.getInMessage().setContent(new StringSource(
                    "<test xmlns=\"http://test\"><echo/><world/><earth/></test>"));
            client.send(me);
        }
        for (int i = 0; i < nbMsgs; i++) {
            client.receive();
        }
        ((Receiver) getBean("trace1")).getMessageList().assertMessagesReceived(1 * nbMsgs);
        ((Receiver) getBean("trace2")).getMessageList().assertMessagesReceived(1 * nbMsgs);
        ((Receiver) getBean("trace3")).getMessageList().assertMessagesReceived(1 * nbMsgs);
        ((Receiver) getBean("trace4")).getMessageList().assertMessagesReceived(2 * nbMsgs);
 
View Full Code Here

public class ScriptComponentTest extends SpringTestSupport {
    private static transient Log log = LogFactory.getLog(ScriptComponentTest.class);

    public void testGroovy() throws Exception {
        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOut me = client.createInOutExchange();
        me.setService(new QName("urn:test", "groovy"));
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(me);
        if (me.getStatus() == ExchangeStatus.ERROR) {
            if (me.getError() != null) {
                throw me.getError();
            } else {
                fail("Received ERROR status");
            }
        } else if (me.getFault() != null) {
            fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
        }
        log.info(new SourceTransformer().toString(me.getOutMessage().getContent()));
        client.done(me);
    }
View Full Code Here

        log.info(new SourceTransformer().toString(me.getOutMessage().getContent()));
        client.done(me);
    }
   
    public void testRuby() throws Exception {
        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOut me = client.createInOutExchange();
        me.setService(new QName("urn:test", "jruby"));
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(me);
        if (me.getStatus() == ExchangeStatus.ERROR) {
            if (me.getError() != null) {
                throw me.getError();
            } else {
                fail("Received ERROR status");
            }
        } else if (me.getFault() != null) {
            fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
        }
        log.info(new SourceTransformer().toString(me.getOutMessage().getContent()));
        client.done(me);
    }
View Full Code Here

        super.setUp();
    }
   
    public void testSendToWriterSoItCanBePolled() throws Exception {
        // now lets make a request on this endpoint
        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);

        // lets send a request to be written to a file
        // which should then be polled
        for (int i = 0; i < NUMBER; i++) {
            InOnly me = client.createInOnlyExchange();
            me.setService(new QName("urn:test", "service"));
            NormalizedMessage message = me.getInMessage();
            message.setProperty(DefaultFileMarshaler.FILE_NAME_PROPERTY, "test" + i + ".xml");
            message.setContent(new StringSource("<hello>world</hello>"));
            client.sendSync(me);
        }

        Receiver receiver = (Receiver) getBean("receiver");
        receiver.getMessageList().assertMessagesReceived(NUMBER);
    }
View Full Code Here

        super.setUp();
        FileUtil.deleteFile(new java.io.File("target/dynamicEndpoint.zip"));
    }

    public void testSendingToDynamicEndpoint() throws Exception {
        ServiceMixClient client = new DefaultServiceMixClient(jbi);

        ServiceEndpoint se = client.resolveEndpointReference(dynamicURI);
        assertNotNull("We should find a service endpoint!", se);

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

        assertExchangeWorked(exchange);
    }
View Full Code Here

        listener = new ExchangeCompletedListener();
        jbi.addListener(listener);
        jbi.init();
        jbi.start();

        client = new DefaultServiceMixClient(jbi);
    }
View Full Code Here

        FileUtil.deleteFile(new File("target/componentOutput.zip"));
        super.setUp();
    }
   
    public void testSendingToStaticEndpoint() throws Exception {
        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOnly me = client.createInOnlyExchange();
        me.setService(new QName("urn:test", "service"));
        NormalizedMessage message = me.getInMessage();

        message.setProperty("name", "cheese");
        message.setContent(new StringSource("<hello>world</hello>"));

        client.sendSync(me);
        assertExchangeWorked(me);
    }
View Full Code Here

        CamelJbiComponent component = new CamelJbiComponent();
        container.activateComponent(component, "#ServiceMixComponent#");
        URL url = getClass().getResource(serviceUnitConfiguration);
        File path = new File(new URI(url.toString()));
        path = path.getParentFile();
        ServiceMixClient client = new DefaultServiceMixClient(container);

        try {
            for (int i = 0; i < 2; i++) {
                LOG.info("Loop counter: " + i);

                // Deploy and start su
                component.getServiceUnitManager().deploy(suName,
                        path.getAbsolutePath());
                component.getServiceUnitManager().init(suName,
                        path.getAbsolutePath());
                component.getServiceUnitManager().start(suName);

                // Send message
                MessageExchange exchange = createExchange(client);
                configureExchange(client, exchange);
                populateExchange(exchange);
                client.sendSync(exchange);
                assertNotNull(exchange.getMessage("out"));
                //assertNotNull(exchange.getMessage("out").getContent());
                // TODO: check out
                client.done(exchange);

                // Stop and undeploy
                component.getServiceUnitManager().stop(suName);
                component.getServiceUnitManager().shutDown(suName);
                component.getServiceUnitManager().undeploy(suName,
                        path.getAbsolutePath());

                // Send message
                exchange = createExchange(client);
                try {
                    configureExchange(client, exchange);
                    client.send(exchange);
                    fail("Should have failed to send to a no longer deployed component");
                } catch (Throwable e) {
                    LOG.debug(
                            "Caught expected exception as the component is undeployed: "
                                    + e, e);
View Full Code Here

        jbi.addListener(listener);
    
        jbi.init();
        jbi.start();

        client = new DefaultServiceMixClient(jbi);

        //LogManager.getLogger(DeliveryChannel.class).setLevel(Level.OFF);
    }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.client.DefaultServiceMixClient

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.