git commit: CAMEL-7448 updated Throttler to use previous maximumRequestsPerPeriod value if missing

2014-08-26 Thread boday
Repository: camel
Updated Branches:
  refs/heads/camel-2.13.x 40b308409 -> f9340dcaf


CAMEL-7448 updated Throttler to use previous maximumRequestsPerPeriod value if 
missing


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

Branch: refs/heads/camel-2.13.x
Commit: f9340dcaf830f08cc2a0476402a081399553258c
Parents: 40b3084
Author: boday 
Authored: Tue Aug 26 15:57:39 2014 -0700
Committer: boday 
Committed: Tue Aug 26 20:42:20 2014 -0700

--
 .../org/apache/camel/processor/Throttler.java   |  2 +-
 .../camel/processor/ThrottlerNullEvalTest.java  | 26 +---
 2 files changed, 24 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/f9340dca/camel-core/src/main/java/org/apache/camel/processor/Throttler.java
--
diff --git a/camel-core/src/main/java/org/apache/camel/processor/Throttler.java 
b/camel-core/src/main/java/org/apache/camel/processor/Throttler.java
index 6b51a2c..fb38495 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/Throttler.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/Throttler.java
@@ -105,7 +105,7 @@ public class Throttler extends DelayProcessorSupport 
implements Traceable {
 protected long calculateDelay(Exchange exchange) {
 // evaluate as Object first to see if we get any result at all
 Object result = maxRequestsPerPeriodExpression.evaluate(exchange, 
Object.class);
-if (result == null) {
+if (maximumRequestsPerPeriod == 0 && result == null) {
 throw new RuntimeExchangeException("The max requests per period 
expression was evaluated as null: " + maxRequestsPerPeriodExpression, exchange);
 }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/f9340dca/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java
--
diff --git 
a/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java
 
b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java
index a3db8ae..6205059 100644
--- 
a/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java
+++ 
b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java
@@ -24,21 +24,41 @@ import org.apache.camel.builder.RouteBuilder;
  */
 public class ThrottlerNullEvalTest extends ContextTestSupport {
 
-public void testNullEvalTest() throws Exception {
+public void testFirstNullEvalTest() throws Exception {
 getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", 
"Bye World");
 getMockEndpoint("mock:dead").expectedBodiesReceived("Kaboom");
 
-template.sendBodyAndHeader("seda:a", "Hello World", "max", 2);
 template.sendBodyAndHeader("seda:a", "Kaboom", "max", null);
+template.sendBodyAndHeader("seda:a", "Hello World", "max", 2);
 template.sendBodyAndHeader("seda:a", "Bye World", "max", 2);
 
 assertMockEndpointsSatisfied();
 }
 
-public void testNoHeaderTest() throws Exception {
+public void testFirstNoHeaderTest() throws Exception {
 getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", 
"Bye World");
 getMockEndpoint("mock:dead").expectedBodiesReceived("Kaboom");
 
+template.sendBody("seda:a", "Kaboom");
+template.sendBodyAndHeader("seda:a", "Hello World", "max", 2);
+template.sendBodyAndHeader("seda:a", "Bye World", "max", 2);
+
+assertMockEndpointsSatisfied();
+}
+
+public void testNullEvalTest() throws Exception {
+getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", 
"Kaboom", "Bye World");
+
+template.sendBodyAndHeader("seda:a", "Hello World", "max", 2);
+template.sendBodyAndHeader("seda:a", "Kaboom", "max", null);
+template.sendBodyAndHeader("seda:a", "Bye World", "max", 2);
+
+assertMockEndpointsSatisfied();
+}
+
+public void testNoHeaderTest() throws Exception {
+getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", 
"Kaboom", "Bye World");
+
 template.sendBodyAndHeader("seda:a", "Hello World", "max", 2);
 template.sendBody("seda:a", "Kaboom");
 template.sendBodyAndHeader("seda:a", "Bye World", "max", 2);



git commit: CAMEL-7448 updated Throttler to use previous maximumRequestsPerPeriod value if missing

2014-08-26 Thread boday
Repository: camel
Updated Branches:
  refs/heads/master d0a36fe12 -> 35bde2b29


CAMEL-7448 updated Throttler to use previous maximumRequestsPerPeriod value if 
missing


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

Branch: refs/heads/master
Commit: 35bde2b29f616d2f3b51e81b805b4ea635d228c9
Parents: d0a36fe
Author: boday 
Authored: Tue Aug 26 15:57:39 2014 -0700
Committer: boday 
Committed: Tue Aug 26 15:57:39 2014 -0700

--
 .../org/apache/camel/processor/Throttler.java   |  2 +-
 .../camel/processor/ThrottlerNullEvalTest.java  | 26 +---
 2 files changed, 24 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/35bde2b2/camel-core/src/main/java/org/apache/camel/processor/Throttler.java
--
diff --git a/camel-core/src/main/java/org/apache/camel/processor/Throttler.java 
b/camel-core/src/main/java/org/apache/camel/processor/Throttler.java
index f70325d..c986bf7 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/Throttler.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/Throttler.java
@@ -108,7 +108,7 @@ public class Throttler extends DelayProcessorSupport 
implements Traceable {
 protected long calculateDelay(Exchange exchange) {
 // evaluate as Object first to see if we get any result at all
 Object result = maxRequestsPerPeriodExpression.evaluate(exchange, 
Object.class);
-if (result == null) {
+if (maximumRequestsPerPeriod == 0 && result == null) {
 throw new RuntimeExchangeException("The max requests per period 
expression was evaluated as null: " + maxRequestsPerPeriodExpression, exchange);
 }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/35bde2b2/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java
--
diff --git 
a/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java
 
b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java
index a3db8ae..6205059 100644
--- 
a/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java
+++ 
b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerNullEvalTest.java
@@ -24,21 +24,41 @@ import org.apache.camel.builder.RouteBuilder;
  */
 public class ThrottlerNullEvalTest extends ContextTestSupport {
 
-public void testNullEvalTest() throws Exception {
+public void testFirstNullEvalTest() throws Exception {
 getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", 
"Bye World");
 getMockEndpoint("mock:dead").expectedBodiesReceived("Kaboom");
 
-template.sendBodyAndHeader("seda:a", "Hello World", "max", 2);
 template.sendBodyAndHeader("seda:a", "Kaboom", "max", null);
+template.sendBodyAndHeader("seda:a", "Hello World", "max", 2);
 template.sendBodyAndHeader("seda:a", "Bye World", "max", 2);
 
 assertMockEndpointsSatisfied();
 }
 
-public void testNoHeaderTest() throws Exception {
+public void testFirstNoHeaderTest() throws Exception {
 getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", 
"Bye World");
 getMockEndpoint("mock:dead").expectedBodiesReceived("Kaboom");
 
+template.sendBody("seda:a", "Kaboom");
+template.sendBodyAndHeader("seda:a", "Hello World", "max", 2);
+template.sendBodyAndHeader("seda:a", "Bye World", "max", 2);
+
+assertMockEndpointsSatisfied();
+}
+
+public void testNullEvalTest() throws Exception {
+getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", 
"Kaboom", "Bye World");
+
+template.sendBodyAndHeader("seda:a", "Hello World", "max", 2);
+template.sendBodyAndHeader("seda:a", "Kaboom", "max", null);
+template.sendBodyAndHeader("seda:a", "Bye World", "max", 2);
+
+assertMockEndpointsSatisfied();
+}
+
+public void testNoHeaderTest() throws Exception {
+getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", 
"Kaboom", "Bye World");
+
 template.sendBodyAndHeader("seda:a", "Hello World", "max", 2);
 template.sendBody("seda:a", "Kaboom");
 template.sendBodyAndHeader("seda:a", "Bye World", "max", 2);