Package org.apache.servicemix.client

Examples of org.apache.servicemix.client.ServiceMixClient


        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

        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

public class SpringConfigurationTest extends SpringTestSupport {

    public void testConfig() throws Exception {
        ActivationSpec as = new ActivationSpec();
        as.setComponentName("client");
        ServiceMixClient client = new DefaultServiceMixClient(jbi, as);
        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);
        ((Receiver) getBean("trace2")).getMessageList().assertMessagesReceived(1);
        ((Receiver) getBean("trace3")).getMessageList().assertMessagesReceived(1);
        ((Receiver) getBean("trace4")).getMessageList().assertMessagesReceived(2);
View Full Code Here

        // Deploy SU
        component.getServiceUnitManager().deploy("su", getServiceUnitPath("org/apache/servicemix/sca/bigbank"));
        component.getServiceUnitManager().init("su", getServiceUnitPath("org/apache/servicemix/sca/bigbank"));
        component.getServiceUnitManager().start("su");
       
        ServiceMixClient client = new DefaultServiceMixClient(container);
        Source req = new StringSource("<AccountReportRequest><CustomerID>id</CustomerID></AccountReportRequest>");
        Object rep = client.request(new ServiceNameEndpointResolver(
                            new QName("http://sca.servicemix.apache.org/Bigbank/Account", "AccountService")),
                              null, null, req);
        if (rep instanceof Node) {
            rep = new DOMSource((Node) rep);
        }
View Full Code Here

       
        container.activateComponent(http, "http");
       
        container.start();
       
        ServiceMixClient client = new DefaultServiceMixClient(container);
        client.request(new ServiceNameEndpointResolver(new QName("urn:test", "s2")), null, null,
                       new StreamSource(getClass().getResourceAsStream("soap-request.xml")));
       
    }
View Full Code Here

       
        container.activateComponent(http, "http");
       
        container.start();
       
        ServiceMixClient client = new DefaultServiceMixClient(container);
        Destination dest = client.createDestination("service:urn:test:s2");
        InOut me = dest.createInOutExchange();
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
        String str = new SourceTransformer().contentToString(me.getOutMessage());
        client.done(me);
        System.err.println(str);
    }
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);
                checkResult(exchange);
                //assertNotNull(exchange.getMessage("out").getContent());
                // TODO: check out the exchange
                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

        http.setEndpoints(new HttpEndpointType[] {ep0, ep1 });
        container.activateComponent(http, "http");
        container.start();

        ServiceMixClient client = new DefaultServiceMixClient(container);
        InOut me = client.createInOutExchange();
        me.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "PersonService"));
        me.setOperation(new QName("http://servicemix.apache.org/samples/wsdl-first", "GetPerson"));
        me.getInMessage().setContent(new StringSource(
                                "<jbi:message xmlns:jbi=\"http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper\""
                             "             xmlns:msg=\"http://servicemix.apache.org/samples/wsdl-first/types\" "
                             "             name=\"Hello\" "
                             "             type=\"msg:HelloRequest\" "
                             "             version=\"1.0\">"
                             "  <jbi:part>"
                             "    <msg:GetPerson><msg:personId>id</msg:personId></msg:GetPerson>"
                             "  </jbi:part>"
                             "</jbi:message>"));
        client.sendSync(me);

        System.err.println(new SourceTransformer().contentToString(me.getOutMessage()));
    }
View Full Code Here

TOP

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

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.