Package org.apache.servicemix.nmr.api

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


   
    @Test
    public void testUnknownOperation() throws Exception {
        PhaseInterceptor<NMRMessage> interceptor = new NMROperationInInterceptor();
        NMRMessage msg = new NMRMessage(new MessageImpl());
        Exchange me = EasyMock.createMock(Exchange.class);
        EasyMock.expect(me.getOperation()).andReturn(new QName("urn:test", "SayHi")).times(4);
        EasyMock.replay(me);
        msg.put(Exchange.class, me);

        TestApplicationContext ctx = new TestApplicationContext(new String[] {
                S1, S2 });
View Full Code Here


        eip.setEndpoints(new EIPEndpoint[] { ep });
        eip.init(new ComponentContextImpl(reg, new SimpleComponentWrapper(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);
        if (e.getError() != null) {
            throw e.getError();
        }
        assertEquals(Status.Done, e.getStatus());
    }
View Full Code Here

        assertNotNull(e.getError());
        assertEquals(Status.Error, e.getStatus());
    }

    public void testProperties() {
        Exchange e = new ExchangeImpl(Pattern.InOnly);
        assertNotNull(e.getProperties());
        e.setProperty("name", "value");
        assertEquals("value", e.getProperty("name"));
        assertNotNull(e.getProperty("name", String.class));
        assertNotNull(e.getProperty("name", byte[].class));
        assertNotNull(e.removeProperty("name"));
        assertNull(e.getProperty("name"));
        e.setProperty(Exchange.class, new ExchangeImpl(Pattern.InOnly));
        assertNotNull(e.getProperty(Exchange.class.getName(), Exchange.class));
        assertNotNull(e.getProperty(Exchange.class));
        assertNotNull(e.removeProperty(Exchange.class));
        assertNull(e.getProperty(Exchange.class));
        assertTrue(e.getProperties().isEmpty());
        e.setProperties(createMap("key", "val"));
        assertNotNull(e.getProperties());
        assertFalse(e.getProperties().isEmpty());
        e.setProperties(null);
        assertNull(e.getProperty("name"));
        assertNull(e.getProperty(Exchange.class));
        assertNull(e.getProperty("name", byte[].class));
        assertNull(e.removeProperty("name"));
        e.setProperties(null);
        e.setProperty(Exchange.class, new ExchangeImpl(Pattern.InOnly));
        assertNotNull(e.getProperty(Exchange.class));
        e.setProperties(null);
        e.setProperty("name", "value");
        assertNotNull(e.getProperty("name"));
    }
View Full Code Here

        e.setProperty("name", "value");
        assertNotNull(e.getProperty("name"));
    }

    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

        assertNull(e.getProviderLock(false));
        assertNotNull(e.getProviderLock(true));
    }

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

    assertNull(e.getOut());
    assertNull(e.getFault());
  }

  public void testRobustInOnly() {
    Exchange e = new ExchangeImpl(Pattern.RobustInOnly);
    assertNotNull(e.getIn());
    assertNull(e.getOut());
    assertNotNull(e.getFault());
  }
View Full Code Here

    assertNull(e.getOut());
    assertNotNull(e.getFault());
  }

  public void testInOut() {
    Exchange e = new ExchangeImpl(Pattern.InOut);
    assertNotNull(e.getIn());
    assertNotNull(e.getOut());
    assertNotNull(e.getFault());
  }
View Full Code Here

    assertNotNull(e.getOut());
    assertNotNull(e.getFault());
  }

  public void testInOptionalOut() {
    Exchange e = new ExchangeImpl(Pattern.InOptionalOut);
    assertNotNull(e.getIn());
    assertNotNull(e.getOut());
    assertNotNull(e.getFault());
  }
View Full Code Here

public class ExchangeUtilsTest extends TestCase {

    private static final Log LOG = LogFactory.getLog(ExchangeUtilsTest.class);

    public void testReReadable() throws Exception {
        Exchange e = new ExchangeImpl(Pattern.InOnly);
        Message msg = e.getIn();
        msg.addAttachment("id", new BufferedInputStream(new ByteArrayInputStream(new byte[] { 1, 2, 3, 4 })));
        msg.setBody(new DOMSource(parse("<hello/>")));

        e.ensureReReadable();

        assertNotNull(msg.getBody());
        assertTrue(msg.getBody() instanceof StringSource);
        assertNotNull(msg.getAttachment("id"));
        assertTrue(msg.getAttachment("id") instanceof ByteArrayInputStream);
View Full Code Here

        assertNotNull(msg.getAttachment("id"));
        assertTrue(msg.getAttachment("id") instanceof ByteArrayInputStream);
    }

    public void testDisplay() throws Exception {
        Exchange e = new ExchangeImpl(Pattern.InOnly);
        e.setOperation(new QName("op"));
        e.setProperty("key", "value");
        e.setStatus(Status.Done);
        Message msg = e.getIn();
        msg.setHeader("header", "value");
        msg.addAttachment("id", new BufferedInputStream(new ByteArrayInputStream(new byte[] { 1, 2, 3, 4 })));
        msg.setBody(new StringSource("<hello/>"));

        String str = e.display(false);
        LOG.info(str);
        assertNotNull(msg.getBody());
        assertTrue(msg.getBody() instanceof StringSource);
        assertNotNull(msg.getAttachment("id"));
        assertTrue(msg.getAttachment("id") instanceof BufferedInputStream);

        str = e.display(true);
        LOG.info(str);
        assertNotNull(msg.getBody());
        assertTrue(msg.getBody() instanceof StringSource);
        assertNotNull(msg.getAttachment("id"));
        assertTrue(msg.getAttachment("id") instanceof ByteArrayInputStream);
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.