camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r679170 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/builder/xml/ camel-core/src/test/java/org/apache/camel/builder/xml/ components/camel-spring/src/test/java/org/apache/camel/spring/processor/
Date Wed, 23 Jul 2008 19:45:08 GMT
Author: davsclaus
Date: Wed Jul 23 12:45:07 2008
New Revision: 679170

URL: http://svn.apache.org/viewvc?rev=679170&view=rev
Log:
CAMEL-747: xpath evaluation of headers ($ notation) now handle missing headers also.

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/MessageVariableResolver.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathHeaderTest.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringXPathHeaderTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/MessageVariableResolver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/MessageVariableResolver.java?rev=679170&r1=679169&r2=679170&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/MessageVariableResolver.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/MessageVariableResolver.java
Wed Jul 23 12:45:07 2008
@@ -75,9 +75,8 @@
             try {
                 answer = System.getProperty(localPart);
             } catch (Exception e) {
-                LOG
-                    .debug("Security exception evaluating system property: " + localPart
+ ". Reason: " + e,
-                           e);
+                LOG.debug("Security exception evaluating system property: " + localPart +
+                    ". Reason: " + e, e);
             }
         } else if (uri.equals(ENVIRONMENT_VARIABLES)) {
             answer = System.getenv().get(localPart);
@@ -99,7 +98,14 @@
         }
 
         // TODO support exposing CamelContext properties/resources via XPath?
-        return answer;
+
+        // If we can't find an answer we must return void.
+        // We can't return null then the xpath engine will throw a NullPointerException
+        if (answer == null) {
+            return Void.class;
+        } else {
+            return answer;
+        }
     }
 
     public void addVariable(String localPart, Object value) {

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathHeaderTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathHeaderTest.java?rev=679170&r1=679169&r2=679170&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathHeaderTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/xml/XPathHeaderTest.java
Wed Jul 23 12:45:07 2008
@@ -39,10 +39,7 @@
         MockEndpoint mock = getMockEndpoint("mock:donkey");
         mock.expectedBodiesReceived("<name>Kong</name>");
 
-        // TODO: must send header type so $type evaluates
-        // however maybe we should support missing headers is evaluated to false
-        // if so the we should test by sending no headers
-        template.sendBodyAndHeader("direct:in", "<name>Kong</name>", "type",
"Donkey");
+        template.sendBody("direct:in", "<name>Kong</name>");
 
         mock.assertIsSatisfied();
     }
@@ -51,10 +48,7 @@
         MockEndpoint mock = getMockEndpoint("mock:other");
         mock.expectedBodiesReceived("<name>Other</name>");
 
-        // TODO: must send header type so $type evaluates
-        // however maybe we should support missing headers is evaluated to false
-        // if so the we should test by sending no headers
-        template.sendBodyAndHeader("direct:in", "<name>Other</name>", "type",
"Foo");
+        template.sendBody("direct:in", "<name>Other</name>");
 
         mock.assertIsSatisfied();
     }

Modified: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringXPathHeaderTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringXPathHeaderTest.java?rev=679170&r1=679169&r2=679170&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringXPathHeaderTest.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringXPathHeaderTest.java
Wed Jul 23 12:45:07 2008
@@ -24,10 +24,7 @@
         MockEndpoint mock = getMockEndpoint("mock:donkey");
         mock.expectedBodiesReceived("<name>Kong</name>");
 
-        // TODO: must send header type so $type evaluates
-        // however maybe we should support missing headers is evaluated to false
-        // if so the we should test by sending no headers
-        template.sendBodyAndHeader("direct:in", "<name>Kong</name>", "type",
"Donkey");
+        template.sendBody("direct:in", "<name>Kong</name>");
 
         mock.assertIsSatisfied();
     }
@@ -36,10 +33,7 @@
         MockEndpoint mock = getMockEndpoint("mock:other");
         mock.expectedBodiesReceived("<name>Other</name>");
 
-        // TODO: must send header type so $type evaluates
-        // however maybe we should support missing headers is evaluated to false
-        // if so the we should test by sending no headers
-        template.sendBodyAndHeader("direct:in", "<name>Other</name>", "type",
"Foo");
+        template.sendBody("direct:in", "<name>Other</name>");
 
         mock.assertIsSatisfied();
     }



Mime
View raw message