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 2015/05/20 17:07:13 UTC

[1/3] camel git commit: Added support for passing time and pattern as references to the Timer component. Added JUnit test for reference based configuration of the Timer Component

Repository: camel
Updated Branches:
  refs/heads/master 02d6e0a45 -> 0583aa113


Added support for passing time and pattern as references to the Timer component.
Added JUnit test for reference based configuration of the Timer Component

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a8065d8b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a8065d8b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a8065d8b

Branch: refs/heads/master
Commit: a8065d8bc7e17f989cd0b44dca8aac2c0f02cce4
Parents: 02d6e0a
Author: Jeff Costello <je...@gmail.com>
Authored: Wed May 20 10:34:12 2015 -0400
Committer: Jeff Costello <je...@gmail.com>
Committed: Wed May 20 10:34:12 2015 -0400

----------------------------------------------------------------------
 .../camel/component/timer/TimerComponent.java   |   4 +-
 .../timer/TimerReferenceConfigurationTest.java  | 144 +++++++++++++++++++
 2 files changed, 146 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a8065d8b/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java b/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java
index 63404ee..567bc40 100644
--- a/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java
@@ -95,8 +95,8 @@ public class TimerComponent extends UriEndpointComponent {
         TimerEndpoint answer = new TimerEndpoint(uri, this, remaining);
 
         // convert time from String to a java.util.Date using the supported patterns
-        String time = getAndRemoveParameter(parameters, "time", String.class);
-        String pattern = getAndRemoveParameter(parameters, "pattern", String.class);
+        String time = getAndRemoveOrResolveReferenceParameter(parameters, "time", String.class);
+        String pattern = getAndRemoveOrResolveReferenceParameter(parameters, "pattern", String.class);
         if (time != null) {
             SimpleDateFormat sdf;
             if (pattern != null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/a8065d8b/camel-core/src/test/java/org/apache/camel/component/timer/TimerReferenceConfigurationTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/timer/TimerReferenceConfigurationTest.java b/camel-core/src/test/java/org/apache/camel/component/timer/TimerReferenceConfigurationTest.java
new file mode 100644
index 0000000..ace24d7
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/timer/TimerReferenceConfigurationTest.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2015 The Apache Software Foundation.
+ *
+ * Licensed 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.component.timer;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+
+/**
+ *
+ * @author JCostello
+ */
+public class TimerReferenceConfigurationTest extends ContextTestSupport{
+    
+    /**
+     * reference params
+     */
+    final String refExpectedTimeString = "1972-12-11 19:55:00";
+    final String refExpectedPattern = "yyyy-MM-dd HH:mm:ss";
+    final long refExpectedPeriod = 500;
+    final long refExpectedDelay = 100;
+    final boolean refExpectedFixedRate = true;
+    final boolean refExpectedDaemon = false;
+    final long refExpectedRepeatCount = 11;
+    
+    /**
+     * value params
+     */
+    final String valExpectedTimeString = "1970-04-17T18:07:41";
+    final String valExpectedPattern = "yyyy-MM-dd'T'HH:mm:ss";
+    final long valExpectedPeriod = 350;
+    final long valExpectedDelay = 123;
+    final boolean valExpectedFixedRate = false;
+    final boolean valExpectedDaemon = true;
+    final long valExpectedRepeatCount = 13;
+    
+    final String refTimerUri = "timer://passByRefTimer?"
+            + "time=#refExpectedTimeString"
+            + "&pattern=#refExpectedPattern"
+            + "&period=#refExpectedPeriod"
+            + "&delay=#refExpectedDelay"
+            + "&fixedRate=#refExpectedFixedRate"
+            + "&daemon=#refExpectedDaemon"
+            + "&repeatCount=#refExpectedRepeatCount";
+    
+    final String valueTimerUri = "timer://passByValueTimer?"
+            + "time="+valExpectedTimeString
+            + "&pattern="+valExpectedPattern
+            + "&period="+valExpectedPeriod
+            + "&delay="+valExpectedDelay
+            + "&fixedRate="+valExpectedFixedRate
+            + "&daemon="+valExpectedDaemon
+            + "&repeatCount="+valExpectedRepeatCount;
+    
+    final String mockEndpointUri = "mock:result";
+    
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry reg = super.createRegistry();
+        reg.bind("refExpectedTimeString", refExpectedTimeString);
+        reg.bind("refExpectedPattern", refExpectedPattern);
+        reg.bind("refExpectedPeriod", refExpectedPeriod);
+        reg.bind("refExpectedDelay", refExpectedDelay);
+        reg.bind("refExpectedFixedRate", refExpectedFixedRate);
+        reg.bind("refExpectedDaemon", refExpectedDaemon);
+        reg.bind("refExpectedRepeatCount", refExpectedRepeatCount);
+        return reg;
+    } 
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(refTimerUri).to(mockEndpointUri);
+                from(valueTimerUri).to(mockEndpointUri);
+            }
+        };
+    }
+
+    /**
+     * Test that the reference configuration params are correct
+     * @throws Exception 
+     */
+    public void testReferenceConfiguration()throws Exception{
+        
+        Endpoint e = context.getEndpoint(refTimerUri);
+        TimerEndpoint timer = (TimerEndpoint)e;
+        final Date expectedTimeObject = new SimpleDateFormat(refExpectedPattern).parse(refExpectedTimeString);
+        final Date time = timer.getTime();
+        final long period = timer.getPeriod();
+        final long delay = timer.getDelay();
+        final boolean fixedRate = timer.isFixedRate();
+        final boolean daemon = timer.isDaemon();
+        final long repeatCount = timer.getRepeatCount();
+        
+        assertEquals(refExpectedDelay, delay);
+        assertEquals(refExpectedPeriod, period);
+        assertEquals(expectedTimeObject, time);
+        assertEquals(refExpectedFixedRate, fixedRate);
+        assertEquals(refExpectedDaemon, daemon);
+        assertEquals(refExpectedRepeatCount, repeatCount);
+    }
+    
+    /**
+     * Test that the 'value' configuration params are correct
+     * @throws Exception 
+     */
+    public void testValueConfiguration()throws Exception{
+        Endpoint e = context.getEndpoint(valueTimerUri);
+        TimerEndpoint timer = (TimerEndpoint)e;
+        final Date expectedTimeObject = new SimpleDateFormat(valExpectedPattern).parse(valExpectedTimeString);
+        final Date time = timer.getTime();
+        final long period = timer.getPeriod();
+        final long delay = timer.getDelay();
+        final boolean fixedRate = timer.isFixedRate();
+        final boolean daemon = timer.isDaemon();
+        final long repeatCount = timer.getRepeatCount();
+        
+        assertEquals(valExpectedDelay, delay);
+        assertEquals(valExpectedPeriod, period);
+        assertEquals(expectedTimeObject, time);
+        assertEquals(valExpectedFixedRate, fixedRate);
+        assertEquals(valExpectedDaemon, daemon);
+        assertEquals(valExpectedRepeatCount, repeatCount);
+    }
+    
+}


[2/3] camel git commit: Fixed CS

Posted by da...@apache.org.
Fixed CS


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/546a0d28
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/546a0d28
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/546a0d28

Branch: refs/heads/master
Commit: 546a0d28d5a2f46407dd41874ed6a22b41f7a849
Parents: a8065d8
Author: Claus Ibsen <da...@apache.org>
Authored: Wed May 20 17:09:01 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed May 20 17:09:01 2015 +0200

----------------------------------------------------------------------
 .../timer/TimerReferenceConfigurationTest.java  | 72 ++++++++++----------
 1 file changed, 36 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/546a0d28/camel-core/src/test/java/org/apache/camel/component/timer/TimerReferenceConfigurationTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/timer/TimerReferenceConfigurationTest.java b/camel-core/src/test/java/org/apache/camel/component/timer/TimerReferenceConfigurationTest.java
index ace24d7..b6b4b03 100644
--- a/camel-core/src/test/java/org/apache/camel/component/timer/TimerReferenceConfigurationTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/timer/TimerReferenceConfigurationTest.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2015 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -17,17 +18,14 @@ package org.apache.camel.component.timer;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Endpoint;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
 
-/**
- *
- * @author JCostello
- */
-public class TimerReferenceConfigurationTest extends ContextTestSupport{
-    
+public class TimerReferenceConfigurationTest extends ContextTestSupport {
+
     /**
      * reference params
      */
@@ -38,7 +36,7 @@ public class TimerReferenceConfigurationTest extends ContextTestSupport{
     final boolean refExpectedFixedRate = true;
     final boolean refExpectedDaemon = false;
     final long refExpectedRepeatCount = 11;
-    
+
     /**
      * value params
      */
@@ -49,7 +47,7 @@ public class TimerReferenceConfigurationTest extends ContextTestSupport{
     final boolean valExpectedFixedRate = false;
     final boolean valExpectedDaemon = true;
     final long valExpectedRepeatCount = 13;
-    
+
     final String refTimerUri = "timer://passByRefTimer?"
             + "time=#refExpectedTimeString"
             + "&pattern=#refExpectedPattern"
@@ -58,18 +56,18 @@ public class TimerReferenceConfigurationTest extends ContextTestSupport{
             + "&fixedRate=#refExpectedFixedRate"
             + "&daemon=#refExpectedDaemon"
             + "&repeatCount=#refExpectedRepeatCount";
-    
+
     final String valueTimerUri = "timer://passByValueTimer?"
-            + "time="+valExpectedTimeString
-            + "&pattern="+valExpectedPattern
-            + "&period="+valExpectedPeriod
-            + "&delay="+valExpectedDelay
-            + "&fixedRate="+valExpectedFixedRate
-            + "&daemon="+valExpectedDaemon
-            + "&repeatCount="+valExpectedRepeatCount;
-    
+            + "time=" + valExpectedTimeString
+            + "&pattern=" + valExpectedPattern
+            + "&period=" + valExpectedPeriod
+            + "&delay=" + valExpectedDelay
+            + "&fixedRate=" + valExpectedFixedRate
+            + "&daemon=" + valExpectedDaemon
+            + "&repeatCount=" + valExpectedRepeatCount;
+
     final String mockEndpointUri = "mock:result";
-    
+
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry reg = super.createRegistry();
@@ -81,7 +79,7 @@ public class TimerReferenceConfigurationTest extends ContextTestSupport{
         reg.bind("refExpectedDaemon", refExpectedDaemon);
         reg.bind("refExpectedRepeatCount", refExpectedRepeatCount);
         return reg;
-    } 
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -96,12 +94,13 @@ public class TimerReferenceConfigurationTest extends ContextTestSupport{
 
     /**
      * Test that the reference configuration params are correct
-     * @throws Exception 
+     *
+     * @throws Exception
      */
-    public void testReferenceConfiguration()throws Exception{
-        
+    public void testReferenceConfiguration() throws Exception {
+
         Endpoint e = context.getEndpoint(refTimerUri);
-        TimerEndpoint timer = (TimerEndpoint)e;
+        TimerEndpoint timer = (TimerEndpoint) e;
         final Date expectedTimeObject = new SimpleDateFormat(refExpectedPattern).parse(refExpectedTimeString);
         final Date time = timer.getTime();
         final long period = timer.getPeriod();
@@ -109,7 +108,7 @@ public class TimerReferenceConfigurationTest extends ContextTestSupport{
         final boolean fixedRate = timer.isFixedRate();
         final boolean daemon = timer.isDaemon();
         final long repeatCount = timer.getRepeatCount();
-        
+
         assertEquals(refExpectedDelay, delay);
         assertEquals(refExpectedPeriod, period);
         assertEquals(expectedTimeObject, time);
@@ -117,14 +116,15 @@ public class TimerReferenceConfigurationTest extends ContextTestSupport{
         assertEquals(refExpectedDaemon, daemon);
         assertEquals(refExpectedRepeatCount, repeatCount);
     }
-    
+
     /**
      * Test that the 'value' configuration params are correct
-     * @throws Exception 
+     *
+     * @throws Exception
      */
-    public void testValueConfiguration()throws Exception{
+    public void testValueConfiguration() throws Exception {
         Endpoint e = context.getEndpoint(valueTimerUri);
-        TimerEndpoint timer = (TimerEndpoint)e;
+        TimerEndpoint timer = (TimerEndpoint) e;
         final Date expectedTimeObject = new SimpleDateFormat(valExpectedPattern).parse(valExpectedTimeString);
         final Date time = timer.getTime();
         final long period = timer.getPeriod();
@@ -132,7 +132,7 @@ public class TimerReferenceConfigurationTest extends ContextTestSupport{
         final boolean fixedRate = timer.isFixedRate();
         final boolean daemon = timer.isDaemon();
         final long repeatCount = timer.getRepeatCount();
-        
+
         assertEquals(valExpectedDelay, delay);
         assertEquals(valExpectedPeriod, period);
         assertEquals(expectedTimeObject, time);
@@ -140,5 +140,5 @@ public class TimerReferenceConfigurationTest extends ContextTestSupport{
         assertEquals(valExpectedDaemon, daemon);
         assertEquals(valExpectedRepeatCount, repeatCount);
     }
-    
+
 }


[3/3] camel git commit: Fixed CS

Posted by da...@apache.org.
Fixed CS


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0583aa11
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0583aa11
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0583aa11

Branch: refs/heads/master
Commit: 0583aa1134f2eeacaf7788c81004e21d1f3b24de
Parents: 546a0d2
Author: Claus Ibsen <da...@apache.org>
Authored: Wed May 20 17:11:36 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed May 20 17:11:36 2015 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/model/rest/RestDefinition.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0583aa11/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
index f3729d5..964015b 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -562,7 +562,7 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
                 }
             }
 
-            if( verb.getType() != null ) {
+            if (verb.getType() != null) {
                 String bodyType = verb.getType();
                 if (bodyType.endsWith("[]")) {
                     bodyType = "List[" + bodyType.substring(0, bodyType.length() - 2) + "]";