Package org.apache.servicemix.client

Examples of org.apache.servicemix.client.DefaultServiceMixClient


            e.printStackTrace();
        }
    }

    public void testSendingToStaticEndpoint() throws Exception {
        ServiceMixClient 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


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);
        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()));
        }
        System.err.println(new SourceTransformer().toString(me.getOutMessage().getContent()));
        client.done(me);
    }
View Full Code Here

        return context.getSubject();
    }
   
    public void testOk() throws Exception {
        Subject subject = login("first", "secret");
        ServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOnly me = client.createInOnlyExchange();
        me.setService(ReceiverComponent.SERVICE);
        me.getInMessage().setSecuritySubject(subject);
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(me);
       
        receiver.getMessageList().assertMessagesReceived(1);
    }
View Full Code Here

        receiver.getMessageList().assertMessagesReceived(1);
    }
   
    public void testNOk() throws Exception {
        Subject subject = login("second", "password");
        ServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOnly me = client.createInOnlyExchange();
        me.setService(ReceiverComponent.SERVICE);
        me.getInMessage().setSecuritySubject(subject);
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        try {
            client.sendSync(me);
            fail("Should have thrown a SecurityException");
        } catch (SecurityException e) {
            // ok
        }
    }
View Full Code Here

    protected void setUp() throws Exception {
        super.setUp();
        receiver1 = (Receiver) jbi.getBean("receiver1");
        receiver2 = (Receiver) jbi.getBean("receiver2");
        receiver3 = (Receiver) jbi.getBean("receiver3");
        client = new DefaultServiceMixClient(jbi);
    }
View Full Code Here

        jbi.setAutoEnlistInTransaction(true);
        jbi.init();
        jbi.start();
        component = new TestComponent();
        jbi.activateComponent(component, "test");
        client = new DefaultServiceMixClient(jbi);
    }
View Full Code Here

        endpoint2.setPojo(new ProxyPojoService());
        endpoint2.setServiceInterface(ProxyPojo.class.getName());
        component2.setEndpoints(new Jsr181Endpoint[] {endpoint2 });
        container.activateComponent(component2, "JSR181Component-2");
       
        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
        InOut me = client.createInOutExchange();
        me.setInterfaceName(new QName("http://xfire.jsr181.servicemix.apache.org", "ProxyPojoPortType"));
        me.getInMessage().setContent(new StringSource(
                "<echo xmlns='http://jsr181.servicemix.apache.org'><echoin0>world</echoin0></echo>"));
        client.sendSync(me);
        if (me.getError() != null) {
            throw me.getError();
        }
        assertTrue(me.getStatus() == ExchangeStatus.ACTIVE);
        client.done(me);
    }
View Full Code Here

        return context.getSubject();
    }
   
    public void testOk() throws Exception {
        Subject subject = login("first", "secret");
        ServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOnly me = client.createInOnlyExchange();
        me.setService(ReceiverComponent.SERVICE);
        me.getInMessage().setSecuritySubject(subject);
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(me);
       
        receiver.getMessageList().assertMessagesReceived(1);
    }
View Full Code Here

        receiver.getMessageList().assertMessagesReceived(1);
    }
   
    public void testNOk() throws Exception {
        Subject subject = login("second", "password");
        ServiceMixClient client = new DefaultServiceMixClient(jbi);
        InOnly me = client.createInOnlyExchange();
        me.setService(ReceiverComponent.SERVICE);
        me.getInMessage().setSecuritySubject(subject);
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        try {
            client.sendSync(me);
            fail("Should have thrown a SecurityException");
        } catch (SecurityException e) {
            // ok
        }
    }
View Full Code Here

        container.activateComponent(jms, "servicemix-jms");

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

        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
        DocumentFragment epr = URIResolver.createWSAEPR("jms://queue/foo.bar.myqueue?jms.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);
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.