camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From BAltmiks <bernd.altm...@steria-mummert.de>
Subject Simple Testcase: XPATH Query does not work
Date Thu, 19 Aug 2010 14:50:08 GMT

Hi,

my xpath query does not work. Here is my Testcase:

import org.apache.camel.EndpointInject;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;


public class XPathFilterTest extends CamelTestSupport
{
	@EndpointInject(uri = "mock:result")
    protected MockEndpoint resultEndpoint;

    @Produce(uri = "direct:start")
    protected ProducerTemplate template;

    @Override
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {
            	from("direct:start").filter().xpath("//one/two",
String.class).to("mock:result");
            }
        };
    }
    
    @Test
    public void testSendMatchingMessage() throws Exception {
        String body = "<one><two/></one>";
    	String expectedBody = "<two/>";

        resultEndpoint.expectedBodiesReceived(expectedBody);

        template.sendBodyAndHeader(body, "foo", "bar");
        resultEndpoint.getExchanges();

        resultEndpoint.assertIsSatisfied();
    }    
}


java.lang.AssertionError: mock://result Body of message: 0. Expected:
<<two/>> but was: <<one><two/></one>>
	at org.apache.camel.component.mock.MockEndpoint.fail(MockEndpoint.java:986)
	at
org.apache.camel.component.mock.MockEndpoint.assertEquals(MockEndpoint.java:968)
	at
org.apache.camel.component.mock.MockEndpoint$4.run(MockEndpoint.java:457)
	at
org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:315)
	at
org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:282)

any idea?

thanks in advance,

Bernd

-- 
View this message in context: http://camel.465427.n5.nabble.com/Simple-Testcase-XPATH-Query-does-not-work-tp2641038p2641038.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message