camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "sb.append" <a261...@drdrb.net>
Subject Re: help with getting xpath value?
Date Mon, 24 Mar 2014 17:17:51 GMT
Here is a failing test for the problem

package com.cameltest.tesxpath;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;

/**
 * XPath with namespace test
 */
public class XPathNamespaceTest extends CamelTestSupport {

    @Test
    public void testXPathWithNamespace() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:55");
        mock.expectedBodiesReceived("<number
xmlns=\"http://acme.com/cheese\"><id>55</id></number>");

        template.sendBody("direct:in", "<number
xmlns=\"http://acme.com/cheese\"><id>55</id></number>");

        mock.assertIsSatisfied();
    }

    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() throws Exception {
                Namespaces ns = new Namespaces("c",
"http://acme.com/cheese");

                from("direct:in").choice()
                    .when(ns.xpath("/c:number/id = 55", Integer.class))
                        .to("mock:55")
                    .otherwise()
                        .to("mock:other")
                    .end();
            }
        };
    }
}




--
View this message in context: http://camel.465427.n5.nabble.com/help-with-getting-xpath-value-tp5749286p5749290.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message