Package org.apache.servicemix.client

Examples of org.apache.servicemix.client.DefaultServiceMixClient


    protected String directoryName = "target/pollDirectory";
    protected String dynamicURI = "file:" + directoryName;

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

        StringBuffer sb = new StringBuffer("<root>");
        for (int i = 0; i < SIZE; i++) {
            sb.append("<hello>world</hello>");
        }
        sb.append("</root>");
       
        // 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(sb.toString()));
            client.sendSync(me);
        }

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


import org.springframework.context.support.AbstractXmlApplicationContext;

public class DynamicEndpointTest extends SpringTestSupport {

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

        ServiceEndpoint se = client.resolveEndpointReference("ftp://servicemix:rocks@localhost/smx/test");
        assertNotNull("We should find a service endpoint!", se);

        InOnly exchange = client.createInOnlyExchange();
        exchange.setEndpoint(se);
        exchange.getInMessage().setProperty(DefaultFileMarshaler.FILE_NAME_PROPERTY, "test.xml");
        exchange.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(exchange);

        assertExchangeWorked(exchange);
    }
View Full Code Here

    private static final int NUMBER = 10;

    public void testSendingToStaticEndpoint() throws Exception {
        for (int i = 0; i < NUMBER; i++) {
            DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
            InOnly me = client.createInOnlyExchange();
            me.setService(new QName("urn:test", "service"));
            NormalizedMessage message = me.getInMessage();
   
            message.setProperty(DefaultFileMarshaler.FILE_NAME_PROPERTY, "test2.xml");
            message.setContent(new StringSource("<hello>world</hello>"));
   
            client.sendSync(me);
            assertExchangeWorked(me);
        }
    }
View Full Code Here

import org.springframework.context.support.AbstractXmlApplicationContext;

public class MySpringComponentTest extends SpringTestSupport {

    public void test() throws Exception {
        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOut me = client.createInOutExchange();
        me.setService(new QName("urn:test", "service"));
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(me);
        // By default, the endpoint throws an UnsupportedOperationException
        // so do not test anything here
    }
View Full Code Here

public class AutoDeployedEndpointTest extends SpringTestSupport {

    public void testSendingToDynamicEndpointForPlainBeanWithFooOperation() throws Exception {
        // now lets make a request on this endpoint
        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);

        InOnly exchange = client.createInOnlyExchange();
        exchange.setService(new QName("urn:test", "service"));
        exchange.setOperation(new QName("foo"));
        exchange.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(exchange);

        assertExchangeWorked(exchange);

        /*
        PlainBean bean = (PlainBean) getBean("plainBean");
View Full Code Here

        */
    }

    public void testSendingToDynamicEndpointForPlainBeanWithBarOperation() throws Exception {
        // now lets make a request on this endpoint
        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);

        InOnly exchange = client.createInOnlyExchange();
        exchange.setService(new QName("urn:test", "service"));
        exchange.setOperation(new QName("bar"));
        exchange.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(exchange);

        assertExchangeWorked(exchange);

        /*
        PlainBean bean = (PlainBean) getBean("plainBean");
View Full Code Here

        EchoComponent echo = new EchoComponent(new QName("echo"), "endpoint");
        jbi.activateComponent(echo, "echo");

        jbi.start();

        ServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOut me = client.createInOutExchange();
        me.setService(new QName("bean"));
        me.setOperation(new QName("receive"));
        NormalizedMessage nm = me.getInMessage();
        nm.setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(me);
        assertExchangeWorked(me);
        client.done(me);
    }
View Full Code Here

public class Jsr181SpringProxyTest extends SpringTestSupport {

    private static Log logger =  LogFactory.getLog(Jsr181ComponentTest.class);

    public void test() throws Exception {
        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOut me = client.createInOutExchange();
        me.setInterfaceName(new QName("http://test", "EchoPortType"));
        me.getInMessage().setContent(new StringSource("<echo xmlns='http://test'><echoin0>world</echoin0></echo>"));
        client.sendSync(me);
        if (me.getStatus() == ExchangeStatus.ERROR) {
            if (me.getFault() != null) {
                fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
            } else if (me.getError() != null) {
                throw me.getError();
View Full Code Here

        assertEquals("bean.getParam()", "abc", bean.getParam());
    }

    protected ListenerBean assertInvokeListenerBean(String uri) throws Exception {
        ServiceMixClient client = new DefaultServiceMixClient(jbi);

        ServiceEndpoint se = client.resolveEndpointReference(uri);
        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);

        ListenerBean bean = (ListenerBean) getBean("listenerBean");
        assertNotNull("Bean should bave been invoked", bean.getLastExchange());
View Full Code Here

        EchoComponent echo2 = new EchoComponent(new QName("urn", "service2"), "endpoint");
        jbi.activateComponent(echo2, "echo2");

        jbi.start();

        ServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOut me = client.createInOutExchange();
        me.setService(new QName("bean"));
        me.setOperation(new QName("receive"));
        NormalizedMessage nm = me.getInMessage();
        nm.setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(me);
        assertExchangeWorked(me);
        client.done(me);
    }
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.