Package org.apache.servicemix.nmr.api

Examples of org.apache.servicemix.nmr.api.Exchange


        assertNotNull(cpy.getProperty("header"));
        assertNotNull(cpy.getIn(false));
    }

    public void testMessages() {
        Exchange e = new ExchangeImpl(Pattern.InOut);
        assertNull(e.getMessage(Type.In, false));
        assertNull(e.getMessage(Type.Out, false));
        assertNull(e.getMessage(Type.Fault, false));
        assertNotNull(e.getMessage(Type.In));
        assertNotNull(e.getMessage(Type.Out));
        assertNotNull(e.getMessage(Type.Fault));
        assertNotNull(e.getMessage(Type.In));
        assertNotNull(e.getMessage(Type.Out));
        assertNotNull(e.getMessage(Type.Fault));
        assertNotNull(e.getMessage(Type.In, false));
        assertNotNull(e.getMessage(Type.Out, false));
        assertNotNull(e.getMessage(Type.Fault, false));
        e.setMessage(Type.In, null);
        e.setMessage(Type.Out, null);
        e.setMessage(Type.Fault, null);
    }
View Full Code Here


        e.setMessage(Type.Out, null);
        e.setMessage(Type.Fault, null);
    }

    public void testError() {
        Exchange e = new ExchangeImpl(Pattern.InOnly);
        assertNull(e.getError());
        assertEquals(Status.Active, e.getStatus());
        e.setError(new Exception());
        assertNotNull(e.getError());
        assertEquals(Status.Error, e.getStatus());
    }
View Full Code Here

    private ServiceMixBinding binding = new ServiceMixBinding();

    @Test
    public void testToCamelAndBackToNmr() {
        Exchange nmr = getChannel().createExchange(Pattern.InOnly);
        nmr.setProperty(KEY, VALUE);
        nmr.getIn().setBody(MESSAGE);
        nmr.getIn().setHeader(KEY, VALUE);

        org.apache.camel.Exchange camel =
                binding.populateCamelExchangeFromNmrExchange(new DefaultCamelContext(), nmr);

        assertEquals(VALUE, camel.getProperty(KEY));
View Full Code Here

            // Create a reference that will be used as the target for our exchanges
            Reference ref = nmr.getEndpointRegistry().lookup(ServiceHelper.createMap(Endpoint.NAME, "EchoEndpoint"));
            while (run) {
                try {
                    // Create an exchange and send it
                    Exchange e = client.createExchange(Pattern.InOut);
                    e.setTarget(ref);
                    e.getIn().setBody("Hello");
                    client.sendSync(e);
                    logger.info("Response from Endpoint {}", e.getOut().getBody());
                    // Send back the Done status
                    e.setStatus(Status.Done);
                    client.send(e);
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.error(e.getMessage());
                }
                // Sleep a bit
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
View Full Code Here

            // Create a reference that will be used as the target for our exchanges
            Reference ref = nmr.getEndpointRegistry().lookup(ServiceHelper.createMap(Endpoint.NAME, "EchoEndpoint"));
            while (run) {
                try {
                    // Create an exchange and send it
                    Exchange e = client.createExchange(Pattern.InOut);
                    e.setTarget(ref);
                    e.getIn().setBody("Hello");
                    client.sendSync(e);
                    LOG.info("Response from Endpoint " + e.getOut().getBody());
                    // Send back the Done status
                    e.setStatus(Status.Done);
                    client.send(e);
                } catch (Exception e) {
                    e.printStackTrace();
                    LOG.error(e.getMessage());
                }
                // Sleep a bit
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
View Full Code Here

        Thread.sleep(5000);
        NMR nmr = getOsgiService(NMR.class);
        assertNotNull(nmr);
       
        Channel client = nmr.createChannel();
        Exchange e = client.createExchange(Pattern.InOut);
        for (Endpoint ep : nmr.getEndpointRegistry().getServices()) {
          e.setTarget(nmr.getEndpointRegistry().lookup(nmr.getEndpointRegistry().getProperties(ep)));
          e.getIn().setBody(new StringSource("<?xml version=\"1.0\" encoding=\"UTF-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><ns2:sayHi xmlns:ns2=\"http://cxf.examples.servicemix.apache.org/\"><arg0>Bonjour</arg0></ns2:sayHi></soap:Body></soap:Envelope>"));
          boolean res = client.sendSync(e);
          assertTrue(res);
        }
   
    }
View Full Code Here

    public void exchangeDelivered(Exchange exchange) {
    }

    public void assertExchangeCompleted() throws Exception {
        long start = System.currentTimeMillis();
        Exchange active = null;
        while (true) {
            synchronized (exchanges) {
                for (Iterator<Exchange> it = exchanges.values().iterator(); it.hasNext();) {
                    active = null;
                    Exchange me = it.next();
                    if (me.getStatus() == Status.Active) {
                        active = me;
                        break;
                    }
                }
                if (active == null) {
View Full Code Here

        eip.setEndpoints(new EIPEndpoint[] { ep });
        eip.init(new ComponentContextImpl(reg, null, null, eip, new HashMap()));
        eip.getLifeCycle().start();

        Channel channel = smx.createChannel();
        Exchange e = channel.createExchange(Pattern.InOnly);
        e.getIn().setBody("<hello/>");
        e.setTarget(smx.getEndpointRegistry().lookup(ServiceHelper.createMap(Endpoint.NAME, "{uri:foo}bar:ep")));
        channel.sendSync(e);
    }
View Full Code Here

        assertNotNull(e.getProperty("name"));
    }

    @Test
    public void testDisplay() {
        Exchange e = new ExchangeImpl(Pattern.InOut);
        e.toString();
        e.display(false);
        e = new ExchangeImpl(Pattern.InOut);
        e.getIn();
        e.getOut();
        e.getFault();
        e.toString();
    }
View Full Code Here

        assertNotNull(e.getProviderLock(true));
    }

    @Test
  public void testInOnly() {
    Exchange e = new ExchangeImpl(Pattern.InOnly);
    assertNotNull(e.getIn());
    assertNull(e.getOut());
    assertNull(e.getFault());
  }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.nmr.api.Exchange

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.