You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/09/17 17:36:45 UTC

svn commit: r1386665 - in /camel/trunk/components/camel-test-blueprint/src/test: java/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.java resources/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.xml

Author: davsclaus
Date: Mon Sep 17 15:36:45 2012
New Revision: 1386665

URL: http://svn.apache.org/viewvc?rev=1386665&view=rev
Log:
CAMEL-5619: Added xpath header test. Thanks to Alan Foster for the patch.

Added:
    camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.java   (with props)
    camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.xml   (with props)

Added: camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.java?rev=1386665&view=auto
==============================================================================
--- camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.java (added)
+++ camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.java Mon Sep 17 15:36:45 2012
@@ -0,0 +1,65 @@
+/**
+ * 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.test.blueprint.xpath;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
+import org.junit.Test;
+
+public class XPathHeaderNameTest extends CamelBlueprintTestSupport {
+	
+    @Override
+    protected String getBlueprintDescriptor() {
+        return "org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.xml";
+    }
+
+    @Test
+    public void testChoiceWithHeaderNamePremium() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:premium");
+        mock.expectedBodiesReceived("<response>OK</response>");
+        mock.expectedHeaderReceived("invoiceDetails", "<invoice orderType='premium'><person><name>Alan</name></person></invoice>");
+ 
+        template.sendBodyAndHeader("direct:in", "<response>OK</response>",
+        		"invoiceDetails", "<invoice orderType='premium'><person><name>Alan</name></person></invoice>");
+
+        mock.assertIsSatisfied();
+    }
+
+    @Test
+    public void testChoiceWithHeaderNameStandard() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:standard");
+        mock.expectedBodiesReceived("<response>OK</response>");
+        mock.expectedHeaderReceived("invoiceDetails", "<invoice orderType='standard'><person><name>Alan</name></person></invoice>");
+ 
+        template.sendBodyAndHeader("direct:in", "<response>OK</response>",
+        		"invoiceDetails", "<invoice orderType='standard'><person><name>Alan</name></person></invoice>");
+
+        mock.assertIsSatisfied();
+    }
+
+    @Test
+    public void testChoiceWithHeaderNameUnknown() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:unknown");
+        mock.expectedBodiesReceived("<response>OK</response>");
+        mock.expectedHeaderReceived("invoiceDetails", "<invoice />");
+ 
+        template.sendBodyAndHeader("direct:in", "<response>OK</response>",
+        		"invoiceDetails", "<invoice />");
+
+        mock.assertIsSatisfied();
+    }
+}

Propchange: camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.xml?rev=1386665&view=auto
==============================================================================
--- camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.xml (added)
+++ camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.xml Mon Sep 17 15:36:45 2012
@@ -0,0 +1,43 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:foo="http://example.com/person"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xsi:schemaLocation="
+             http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+  <camelContext id="xpathHeaderNameTest" xmlns="http://camel.apache.org/schema/blueprint">
+    <route>
+      <from uri="direct:in"/>
+      <choice>
+        <when>
+          <xpath headerName="invoiceDetails">/invoice/@orderType = 'premium'</xpath>
+          <to uri="mock:premium"/>
+        </when>
+        <when>
+          <xpath headerName="invoiceDetails">/invoice/@orderType = 'standard'</xpath>
+          <to uri="mock:standard"/>
+        </when>
+        <otherwise>
+          <to uri="mock:unknown"/>
+        </otherwise>
+      </choice>
+    </route>
+  </camelContext>
+
+</blueprint>
\ No newline at end of file

Propchange: camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/xpath/XPathHeaderNameTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml