Author: davsclaus
Date: Thu Dec 10 10:24:46 2009
New Revision: 889172
URL: http://svn.apache.org/viewvc?rev=889172&view=rev
Log:
Added unit test based on user forum trouble
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/ExtractXPathWithNamespaceTest.java
(with props)
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceResultTypeTest.java
(with props)
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceTest.java
(contents, props changed)
- copied, changed from r889114,
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathHeaderTest.java
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/ExtractXPathWithNamespaceTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/ExtractXPathWithNamespaceTest.java?rev=889172&view=auto
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/ExtractXPathWithNamespaceTest.java
(added)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/ExtractXPathWithNamespaceTest.java
Thu Dec 10 10:24:46 2009
@@ -0,0 +1,69 @@
+/**
+ * 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.xml;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * XPath with namespace test
+ */
+public class ExtractXPathWithNamespaceTest extends ContextTestSupport {
+
+ public void testXPathWithNamespace() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedBodiesReceived("<number
xmlns=\"http://acme.com/cheese\">55</number>");
+ mock.expectedHeaderReceived("foo", 55);
+
+ template.sendBody("direct:in", "<number
xmlns=\"http://acme.com/cheese\">55</number>");
+
+ mock.assertIsSatisfied();
+ }
+
+ public void testXPathWithNamespaceOther() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedBodiesReceived("<number
xmlns=\"http://acme.com/cheese\">99</number>");
+ mock.expectedHeaderReceived("foo", 99);
+
+ template.sendBody("direct:in", "<number
xmlns=\"http://acme.com/cheese\">99</number>");
+
+ mock.assertIsSatisfied();
+ }
+
+ public void testXPathWithNamespaceDifferentNamespace() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedBodiesReceived("<number
xmlns=\"http://acme.com/cake\">55</number>");
+ mock.expectedHeaderReceived("foo", 0);
+
+ template.sendBody("direct:in", "<number
xmlns=\"http://acme.com/cake\">55</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")
+ .setHeader("foo").xpath("/c:number", Integer.class, ns)
+ .to("mock:result");
+ }
+ };
+ }
+}
\ No newline at end of file
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/ExtractXPathWithNamespaceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/ExtractXPathWithNamespaceTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceResultTypeTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceResultTypeTest.java?rev=889172&view=auto
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceResultTypeTest.java
(added)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceResultTypeTest.java
Thu Dec 10 10:24:46 2009
@@ -0,0 +1,40 @@
+/**
+ * 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.xml;
+
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * XPath with namespace test
+ */
+public class XPathNamespaceResultTypeTest extends XPathNamespaceTest {
+
+ 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().xpath("/c:number = 55", Integer.class, ns)
+ .to("mock:55")
+ .otherwise()
+ .to("mock:other")
+ .end();
+ }
+ };
+ }
+}
\ No newline at end of file
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceResultTypeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceResultTypeTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied:
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceTest.java
(from r889114,
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathHeaderTest.java)
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathHeaderTest.java&r1=889114&r2=889172&rev=889172&view=diff
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathHeaderTest.java
(original)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceTest.java
Thu Dec 10 10:24:46 2009
@@ -21,34 +21,33 @@
import org.apache.camel.component.mock.MockEndpoint;
/**
- * XPath with and without header test.
+ * XPath with namespace test
*/
-public class XPathHeaderTest extends ContextTestSupport {
+public class XPathNamespaceTest extends ContextTestSupport {
- public void testChoiceWithHeaderSelectCamel() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:camel");
- mock.expectedBodiesReceived("<name>King</name>");
- mock.expectedHeaderReceived("type", "Camel");
+ public void testXPathWithNamespace() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:55");
+ mock.expectedBodiesReceived("<number
xmlns=\"http://acme.com/cheese\">55</number>");
- template.sendBodyAndHeader("direct:in", "<name>King</name>", "type",
"Camel");
+ template.sendBody("direct:in", "<number
xmlns=\"http://acme.com/cheese\">55</number>");
mock.assertIsSatisfied();
}
- public void testChoiceWithNoHeaderSelectDonkey() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:donkey");
- mock.expectedBodiesReceived("<name>Kong</name>");
+ public void testXPathWithNamespaceOther() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:other");
+ mock.expectedBodiesReceived("<number
xmlns=\"http://acme.com/cheese\">99</number>");
- template.sendBody("direct:in", "<name>Kong</name>");
+ template.sendBody("direct:in", "<number
xmlns=\"http://acme.com/cheese\">99</number>");
mock.assertIsSatisfied();
}
- public void testChoiceWithNoHeaderSelectOther() throws Exception {
+ public void testXPathWithNamespaceDifferentNamespace() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:other");
- mock.expectedBodiesReceived("<name>Other</name>");
+ mock.expectedBodiesReceived("<number
xmlns=\"http://acme.com/cake\">55</number>");
- template.sendBody("direct:in", "<name>Other</name>");
+ template.sendBody("direct:in", "<number
xmlns=\"http://acme.com/cake\">55</number>");
mock.assertIsSatisfied();
}
@@ -56,19 +55,15 @@
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
- // START SNIPPET: e1
+ Namespaces ns = new Namespaces("c", "http://acme.com/cheese");
+
from("direct:in").choice()
- // using $headerName is special notation in Camel to get
the header key
- .when().xpath("$type = 'Camel'")
- .to("mock:camel")
- // here we test for the body name tag
- .when().xpath("//name = 'Kong'")
- .to("mock:donkey")
+ .when(ns.xpath("/c:number = 55", Integer.class))
+ .to("mock:55")
.otherwise()
.to("mock:other")
.end();
- // END SNIPPET: e1
}
};
}
-}
+}
\ No newline at end of file
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date