Package org.apache.servicemix.nmr.core

Examples of org.apache.servicemix.nmr.core.ExchangeImpl


     * @return InOut exchange
     * @throws MessagingException
     */
    public InOut createInOutExchange() throws MessagingException {
        checkNotClosed();
        InOutImpl result = new InOutImpl(new ExchangeImpl(Pattern.InOut));
        setDefaults(result);
        return result;
    }
View Full Code Here


     * @return InOptionalOut exchange
     * @throws MessagingException
     */
    public InOptionalOut createInOptionalOutExchange() throws MessagingException {
        checkNotClosed();
        InOptionalOutImpl result = new InOptionalOutImpl(new ExchangeImpl(Pattern.InOptionalOut));
        setDefaults(result);
        return result;
    }
View Full Code Here

     * @throws MessagingException
     */
    public MessageExchange createExchange(QName svcName, QName opName) throws MessagingException {
        // TODO: look for the operation in the wsdl and infer the MEP
        checkNotClosed();
        InOptionalOutImpl me = new InOptionalOutImpl(new ExchangeImpl(Pattern.InOptionalOut));
        setDefaults(me);
        me.setService(svcName);
        me.setOperation(opName);
        return me;
    }
View Full Code Here

        InternalEndpoint endpoint = new InternalEndpointWrapper(new EndpointImpl(ServiceHelper.createMap(Endpoint.ENDPOINT_NAME, "endpoint")),
                                                                ServiceHelper.createMap(Endpoint.ENDPOINT_NAME, "internal-endpoint"));
        listener.endpointRegistered(endpoint);
        listener.setAssembly(null);
       
        InternalExchange exchange = new ExchangeImpl(Pattern.InOnly);
        exchange.setSource(endpoint);
        exchange.setProperty(DeliveryChannelImpl.SEND_SYNC, Boolean.TRUE);
        listener.exchangeSent(exchange);
       
        assertEquals(1, listener.getPending(sa).size());
       
        exchange.setStatus(Status.Done);
        listener.exchangeDelivered(exchange);
       
        assertEquals(0, listener.getPending(sa).size());
    }
View Full Code Here

        InternalEndpoint endpoint = new InternalEndpointWrapper(new EndpointImpl(ServiceHelper.createMap(Endpoint.ENDPOINT_NAME, "endpoint")),
                                                                ServiceHelper.createMap(Endpoint.ENDPOINT_NAME, "internal-endpoint"));
        listener.endpointRegistered(endpoint);
        listener.setAssembly(null);
       
        InternalExchange exchange = new ExchangeImpl(Pattern.InOnly);
        exchange.setSource(endpoint);
        exchange.setProperty(DeliveryChannelImpl.SEND_SYNC, Boolean.TRUE);
        listener.exchangeSent(exchange);
       
        assertEquals(1, listener.getPending(sa).size());
       
        exchange.setStatus(Status.Error);
        listener.exchangeFailed(exchange);
       
        assertEquals(0, listener.getPending(sa).size());
    }
View Full Code Here

        InternalEndpoint endpoint = new InternalEndpointWrapper(new EndpointImpl(ServiceHelper.createMap(Endpoint.ENDPOINT_NAME, "endpoint")),
                                                                ServiceHelper.createMap(Endpoint.ENDPOINT_NAME, "internal-endpoint"));
        listener.endpointRegistered(endpoint);
        listener.setAssembly(null);
       
        InternalExchange exchange = new ExchangeImpl(Pattern.InOnly);
        exchange.setSource(endpoint);
        exchange.setProperty(DeliveryChannelImpl.SEND_SYNC, Boolean.TRUE);
        exchange.getConsumerLock(true);
        listener.exchangeSent(exchange);
       
        assertEquals(1, listener.getPending(sa).size());
       
        listener.cancelPendingSyncExchanges(sa);
        assertEquals(Status.Error, exchange.getStatus());
    }
View Full Code Here

    public void testNoExceptionsOnUnknownExchange() throws Exception {
        AssemblyReferencesListener listener = new AssemblyReferencesListener();
        InternalEndpoint endpoint = new InternalEndpointWrapper(new EndpointImpl(ServiceHelper.createMap(Endpoint.ENDPOINT_NAME, "endpoint")),
                                                                ServiceHelper.createMap(Endpoint.ENDPOINT_NAME, "internal-endpoint"));
       
        InternalExchange exchange = new ExchangeImpl(Pattern.InOnly);
        exchange.setSource(endpoint);
        exchange.setProperty(DeliveryChannelImpl.SEND_SYNC, Boolean.TRUE);
        exchange.getConsumerLock(true);
       
        // this should not throw an exception
        listener.exchangeSent(exchange);
    }
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 StringSource("<hello/>"));

        e.ensureReReadable();

        assertNotNull(msg.getBody());
        assertTrue(msg.getBody() instanceof DOMSource);
        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 DOMSource);
        assertNotNull(msg.getAttachment("id"));
        assertTrue(msg.getAttachment("id") instanceof ByteArrayInputStream);
View Full Code Here

            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                throw new UnsupportedOperationException();
            }
        });

        MessageExchange me = new InOnlyImpl(new ExchangeImpl(Pattern.InOnly));
        URIResolver.configureExchange(me, ctx, "interface:urn:test");
        assertEquals(new QName("urn", "test"), me.getInterfaceName());
        assertNull(me.getOperation());
        assertNull(me.getService());
        assertNull(me.getEndpoint());

        me = new InOnlyImpl(new ExchangeImpl(Pattern.InOnly));
        URIResolver.configureExchange(me, ctx, "operation:urn:test:op");
        assertEquals(new QName("urn", "test"), me.getInterfaceName());
        assertEquals(new QName("urn", "op"), me.getOperation());
        assertNull(me.getService());
        assertNull(me.getEndpoint());

        me = new InOnlyImpl(new ExchangeImpl(Pattern.InOnly));
        URIResolver.configureExchange(me, ctx, "service:urn:test");
        assertNull(me.getInterfaceName());
        assertNull(me.getOperation());
        assertEquals(new QName("urn", "test"), me.getService());
        assertNull(me.getEndpoint());

        ctx = (ComponentContext) Proxy.newProxyInstance(ComponentContext.class.getClassLoader(),
                                                        new Class[] { ComponentContext.class },
                                                        new InvocationHandler() {
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                assertEquals("getEndpoint", method.getName());
                assertEquals(new QName("urn", "svc"), args[0]);
                assertEquals("ep", args[1]);
                return new ServiceEndpointImpl((QName) args[0], (String) args[1]);
            }
        });
        me = new InOnlyImpl(new ExchangeImpl(Pattern.InOnly));
        URIResolver.configureExchange(me, ctx, "endpoint:urn:svc:ep");
        assertNull(me.getInterfaceName());
        assertNull(me.getOperation());
        assertNull(me.getService());
        assertNotNull(me.getEndpoint());

        ctx = (ComponentContext) Proxy.newProxyInstance(ComponentContext.class.getClassLoader(),
                                                        new Class[] { ComponentContext.class },
                                                        new InvocationHandler() {
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                assertEquals("resolveEndpointReference", method.getName());
                assertTrue(args[0] instanceof DocumentFragment);
                return new ServiceEndpointImpl(new QName("svc"), "ep");
            }
        });
        me = new InOnlyImpl(new ExchangeImpl(Pattern.InOnly));
        URIResolver.configureExchange(me, ctx, "http://urn/");
        assertNull(me.getInterfaceName());
        assertNull(me.getOperation());
        assertNull(me.getService());
        assertNotNull(me.getEndpoint());
View Full Code Here

TOP

Related Classes of org.apache.servicemix.nmr.core.ExchangeImpl

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.