This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-2.23.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit cbed2195c719fa83b4a711a2d7257002caf44170 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Mon Dec 17 13:27:03 2018 +0100 CAMEL-12994: Added unit tests --- .../saxon/SpringXQueryTransformIssueTest.java | 44 ++++++++++++++++++ .../builder/saxon/XQueryTransformIssueTest.java | 52 ++++++++++++++++++++++ .../camel-saxon/src/test/resources/myinput.xml | 27 +++++++++++ .../saxon/SpringXQueryTransformIssueTest.xml | 38 ++++++++++++++++ 4 files changed, 161 insertions(+) diff --git a/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.java b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.java new file mode 100644 index 0000000..4389ff9 --- /dev/null +++ b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.java @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.builder.saxon; + +import java.io.FileInputStream; + +import org.apache.camel.test.spring.CamelSpringTestSupport; +import org.apache.camel.util.IOHelper; +import org.junit.Test; +import org.springframework.context.support.AbstractApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class SpringXQueryTransformIssueTest extends CamelSpringTestSupport { + + @Test + public void testTransform() throws Exception { + String data = IOHelper.loadText(new FileInputStream("src/test/resources/myinput.xml")); + + getMockEndpoint("mock:result").expectedBodiesReceived("123TestConcat"); + + template.sendBody("direct:start", data); + + assertMockEndpointsSatisfied(); + } + + @Override + protected AbstractApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.xml"); + } +} diff --git a/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryTransformIssueTest.java b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryTransformIssueTest.java new file mode 100644 index 0000000..e6a883e --- /dev/null +++ b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryTransformIssueTest.java @@ -0,0 +1,52 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.builder.saxon; + +import java.io.FileInputStream; + +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.camel.util.IOHelper; +import org.junit.Test; + +public class XQueryTransformIssueTest extends CamelTestSupport { + + @Test + public void testTransform() throws Exception { + String data = IOHelper.loadText(new FileInputStream("src/test/resources/myinput.xml")); + + getMockEndpoint("mock:result").expectedBodiesReceived("123TestConcat"); + + template.sendBody("direct:start", data); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RoutesBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .transform().xquery("concat(/Envelope/Body/getEmployee/EmpId/text(),\"TestConcat\")", String.class) + .to("log:info") + .to("mock:result"); + } + }; + } +} diff --git a/components/camel-saxon/src/test/resources/myinput.xml b/components/camel-saxon/src/test/resources/myinput.xml new file mode 100644 index 0000000..d7ca32e --- /dev/null +++ b/components/camel-saxon/src/test/resources/myinput.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<Envelope> + <Header/> + <Body> + <getEmployee> + <EmpId>123</EmpId> + </getEmployee> + </Body> +</Envelope> \ No newline at end of file diff --git a/components/camel-saxon/src/test/resources/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.xml b/components/camel-saxon/src/test/resources/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.xml new file mode 100644 index 0000000..ce68485 --- /dev/null +++ b/components/camel-saxon/src/test/resources/org/apache/camel/builder/saxon/SpringXQueryTransformIssueTest.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd + "> + + <camelContext xmlns="http://camel.apache.org/schema/spring"> + <route> + <from uri="direct:start"/> + <transform> + <xquery type="String">concat(/Envelope/Body/getEmployee/EmpId/text(),"TestConcat")</xquery> + </transform> + <to uri="log:info"/> + <to uri="mock:result"/> + </route> + </camelContext> + +</beans>