Examples of InOnlyImpl


Examples of org.apache.servicemix.jbi.messaging.InOnlyImpl

public class MessageExchangeImplTest extends TestCase {
   
  private static final Log log = LogFactory.getLog(MessageExchangeImplTest.class);
 
    protected void testSerializeDeserialize(Source src) throws Exception {
        MessageExchange me = new InOnlyImpl("exchangeId");
        me.setOperation(new QName("uri", "op"));
        me.setProperty("myProp", "myValue");
        NormalizedMessage msg = me.createMessage();
        msg.setProperty("myMsgProp", "myMsgValue");
        msg.setContent(src);
        msg.addAttachment("myAttachment", new DataHandler(new StreamDataSource(new ByteArrayInputStream("hello".getBytes()))));
        me.setMessage(msg, "in");
        assertNotNull(((NormalizedMessageImpl) msg).getBody());
       
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(me);
View Full Code Here

Examples of org.apache.servicemix.jbi.messaging.InOnlyImpl

        //assertExpression(new XMLBeansStringXPathExpression("$name"), "James", "<foo><bar xyz='cheese'/></foo>");
        //assertExpression(new XMLBeansStringXPathExpression("foo/bar/text()"), "cheese", "<foo><bar>cheese</bar></foo>");
    }

    protected void assertExpression(Expression expression, String expected, String xml) throws MessagingException {
        MessageExchangeImpl exchange = new InOnlyImpl("dummy");
        NormalizedMessage message = new NormalizedMessageImpl(exchange);
        message.setProperty("name", "James");
        message.setContent(new StringSource(xml));
        Object value = expression.evaluate(exchange, message);
        assertEquals("Expression: " + expression, expected, value);
View Full Code Here

Examples of org.apache.servicemix.jbi.messaging.InOnlyImpl

        } catch (Exception e) {
            throw new AuditorException("Unable to reconstruct exchange", e);
        }
        URI mep = packet.getPattern();
        if (MessageExchangeSupport.IN_ONLY.equals(mep)) {
            return new InOnlyImpl(packet);
        } else if (MessageExchangeSupport.IN_OPTIONAL_OUT.equals(mep)) {
            return new InOptionalOutImpl(packet);
        } else if (MessageExchangeSupport.IN_OUT.equals(mep)) {
            return new InOutImpl(packet);
        } else if (MessageExchangeSupport.ROBUST_IN_ONLY.equals(mep)) {
View Full Code Here

Examples of org.apache.servicemix.jbi.messaging.InOnlyImpl

        exp.setXPath("/header/map");
        assertExpression(exp, params, "<header>" + xStream.toXML(params) + "</header>");
    }

    protected void assertExpression(Expression expression, Object expected, String xml) throws MessagingException {
        InOnlyImpl exchange = new InOnlyImpl("dummy");
        NormalizedMessage message = new NormalizedMessageImpl(exchange);
        message.setContent(new StringSource(xml));
        Object value = expression.evaluate(exchange, message);
        assertEquals("Expression: " + expression, expected, value);
    }
View Full Code Here

Examples of org.apache.servicemix.jbi.runtime.impl.InOnlyImpl

            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());

        try {
            URIResolver.configureExchange(null, ctx, "service:urn:test");
            fail("Should have thrown a NPE");
        } catch (NullPointerException e) {
View Full Code Here

Examples of org.apache.servicemix.jbi.runtime.impl.InOnlyImpl

            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());

        try {
            URIResolver.configureExchange(null, ctx, "service:urn:test");
            fail("Should have thrown a NPE");
        } catch (NullPointerException e) {
View Full Code Here

Examples of org.servicemix.jbi.messaging.InOnlyImpl

        //assertExpression(new XMLBeansStringXPathExpression("$name"), "James", "<foo><bar xyz='cheese'/></foo>");
        //assertExpression(new XMLBeansStringXPathExpression("foo/bar/text()"), "cheese", "<foo><bar>cheese</bar></foo>");
    }

    protected void assertExpression(Expression expression, String expected, String xml) throws MessagingException {
        MessageExchangeImpl exchange = new InOnlyImpl("dummy");
        NormalizedMessage message = new NormalizedMessageImpl(exchange);
        message.setProperty("name", "James");
        message.setContent(new StringSource(xml));
        Object value = expression.evaluate(exchange, message);
        assertEquals("Expression: " + expression, expected, value);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.