camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1236667 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/test/java/org/apache/camel/processor/ components/camel-spring/src/test/resources/org/apache/camel/spring/processor/
Date Fri, 27 Jan 2012 13:02:43 GMT
Author: davsclaus
Date: Fri Jan 27 13:02:42 2012
New Revision: 1236667

URL: http://svn.apache.org/viewvc?rev=1236667&view=rev
Log:
CAMEL-4947: Fixed delayer in XML DSL not working with method call expression.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MyDelayCalcBean.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayDefinition.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DelayerTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/delayer.xml

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayDefinition.java?rev=1236667&r1=1236666&r2=1236667&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayDefinition.java Fri Jan
27 13:02:42 2012
@@ -103,10 +103,8 @@ public class DelayDefinition extends Exp
     private Expression createAbsoluteTimeDelayExpression(RouteContext routeContext) {
         ExpressionDefinition expr = getExpression();
         if (expr != null) {
-            if (ObjectHelper.isNotEmpty(expr.getExpression()) || expr.getExpressionValue()
!= null) {
-                return expr.createExpression(routeContext);
-            } 
-        } 
+            return expr.createExpression(routeContext);
+        }
         return null;
     }
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DelayerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DelayerTest.java?rev=1236667&r1=1236666&r2=1236667&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DelayerTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DelayerTest.java Fri Jan
27 13:02:42 2012
@@ -25,6 +25,8 @@ import org.apache.camel.component.mock.M
  */
 public class DelayerTest extends ContextTestSupport {
 
+    private MyDelayCalcBean bean = new MyDelayCalcBean();
+
     public void testSendingMessageGetsDelayed() throws Exception {
         MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
 
@@ -50,6 +52,15 @@ public class DelayerTest extends Context
         resultEndpoint.assertIsSatisfied();
     }
 
+    public void testDelayBean() throws Exception {
+        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
+        resultEndpoint.expectedMessageCount(1);
+        // should at least take 1 sec to complete
+        resultEndpoint.setMinimumResultWaitTime(900);
+        template.sendBody("seda:c", "<hello>world!</hello>");
+        resultEndpoint.assertIsSatisfied();
+    }
+
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
@@ -60,6 +71,10 @@ public class DelayerTest extends Context
                 // START SNIPPET: ex2
                 from("seda:b").delay(1000).to("mock:result");
                 // END SNIPPET: ex2
+
+                // START SNIPPET: ex3
+                from("seda:c").delay().method(bean, "delayMe").to("mock:result");
+                // END SNIPPET: ex3
             }
         };
     }

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MyDelayCalcBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MyDelayCalcBean.java?rev=1236667&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MyDelayCalcBean.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MyDelayCalcBean.java Fri
Jan 27 13:02:42 2012
@@ -0,0 +1,27 @@
+/**
+ * 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.processor;
+
+/**
+ *
+ */
+public class MyDelayCalcBean {
+    
+    public long delayMe(String body) {
+        return 1000;
+    }
+}

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/delayer.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/delayer.xml?rev=1236667&r1=1236666&r2=1236667&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/delayer.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/delayer.xml
Fri Jan 27 13:02:42 2012
@@ -23,6 +23,8 @@
     ">
 
     <!-- START SNIPPET: example -->
+    <bean id="myDelayBean" class="org.apache.camel.processor.MyDelayCalcBean"/>
+
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         <route>
             <from uri="seda:a"/>
@@ -38,6 +40,13 @@
             </delay>
             <to uri="mock:result"/>
         </route>
+        <route>
+            <from uri="seda:c"/>
+            <delay>
+                <method ref="myDelayBean" method="delayMe"/>
+            </delay>
+            <to uri="mock:result"/>
+        </route>
     </camelContext>
     <!-- END SNIPPET: example -->
 



Mime
View raw message