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/01/19 16:49:55 UTC

svn commit: r1233442 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/test/java/org/apache/camel/processor/enricher/ components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/

Author: davsclaus
Date: Thu Jan 19 15:49:54 2012
New Revision: 1233442

URL: http://svn.apache.org/viewvc?rev=1233442&view=rev
Log:
CAMEL-4920: PollEnrich without timeout explicit given, should be like -1 as timeout, eg block until message arrives.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java
    camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java?rev=1233442&r1=1233441&r2=1233442&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java Thu Jan 19 15:49:54 2012
@@ -50,7 +50,6 @@ public class PollEnrichDefinition extend
     private AggregationStrategy aggregationStrategy;
 
     public PollEnrichDefinition() {
-        this(null, null, 0);
     }
 
     public PollEnrichDefinition(AggregationStrategy aggregationStrategy, String resourceUri, long timeout) {
@@ -96,7 +95,8 @@ public class PollEnrichDefinition extend
         if (timeout != null) {
             enricher = new PollEnricher(null, endpoint.createPollingConsumer(), timeout);
         } else {
-            enricher = new PollEnricher(null, endpoint.createPollingConsumer(), 0);
+            // if no timeout then we should block, and there use a negative timeout
+            enricher = new PollEnricher(null, endpoint.createPollingConsumer(), -1);
         }
 
         if (aggregationStrategyRef != null) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java?rev=1233442&r1=1233441&r2=1233442&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java Thu Jan 19 15:49:54 2012
@@ -2820,7 +2820,7 @@ public abstract class ProcessorDefinitio
      * The difference between this and {@link #enrich(String)} is that this uses a consumer
      * to obtain the additional data, where as enrich uses a producer.
      * <p/>
-     * This method will block until data is avialable, use the method with timeout if you do not
+     * This method will <tt>block</tt> until data is available, use the method with timeout if you do not
      * want to risk waiting a long time before data is available from the resourceUri.
      *
      * @param resourceUri           URI of resource endpoint for obtaining additional data.
@@ -2829,7 +2829,7 @@ public abstract class ProcessorDefinitio
      */
     @SuppressWarnings("unchecked")
     public Type pollEnrich(String resourceUri) {
-        addOutput(new PollEnrichDefinition(null, resourceUri, 0));
+        addOutput(new PollEnrichDefinition(null, resourceUri, -1));
         return (Type) this;
     }
 
@@ -2841,7 +2841,7 @@ public abstract class ProcessorDefinitio
      * The difference between this and {@link #enrich(String)} is that this uses a consumer
      * to obtain the additional data, where as enrich uses a producer.
      * <p/>
-     * This method will block until data is avialable, use the method with timeout if you do not
+     * This method will <b>block</b> until data is available, use the method with timeout if you do not
      * want to risk waiting a long time before data is available from the resourceUri.
      *
      * @param resourceUri           URI of resource endpoint for obtaining additional data.
@@ -2851,7 +2851,7 @@ public abstract class ProcessorDefinitio
      */
     @SuppressWarnings("unchecked")
     public Type pollEnrich(String resourceUri, AggregationStrategy aggregationStrategy) {
-        addOutput(new PollEnrichDefinition(aggregationStrategy, resourceUri, 0));
+        addOutput(new PollEnrichDefinition(aggregationStrategy, resourceUri, -1));
         return (Type) this;
     }
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java?rev=1233442&r1=1233441&r2=1233442&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java Thu Jan 19 15:49:54 2012
@@ -33,17 +33,6 @@ public class PollEnricherNoResourceTest 
         assertMockEndpointsSatisfied();
     }
 
-    public void testNoResourceB() throws Exception {
-        // there should be no message body
-        getMockEndpoint("mock:result").expectedMessageCount(1);
-        getMockEndpoint("mock:result").message(0).body().isNull();
-        getMockEndpoint("mock:result").expectedHeaderReceived(Exchange.TO_ENDPOINT, "seda://bar");
-
-        template.sendBody("direct:b", "Hello World");
-
-        assertMockEndpointsSatisfied();
-    }
-
     public void testResourceA() throws Exception {
         template.sendBody("seda:foo", "Bye World");
 
@@ -61,8 +50,6 @@ public class PollEnricherNoResourceTest 
     public void testResourceB() throws Exception {
         template.sendBody("seda:bar", "Bye World");
 
-        Thread.sleep(250);
-
         // there should be a message body
         getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
         getMockEndpoint("mock:result").expectedHeaderReceived(Exchange.TO_ENDPOINT, "seda://bar");

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java?rev=1233442&r1=1233441&r2=1233442&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java Thu Jan 19 15:49:54 2012
@@ -35,11 +35,6 @@ public class PollEnricherTest extends Co
         mock = getMockEndpoint("mock:mock");
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
     // -------------------------------------------------------------
     //  InOnly routes
     // -------------------------------------------------------------
@@ -47,11 +42,11 @@ public class PollEnricherTest extends Co
     public void testPollEnrichInOnly() throws InterruptedException {
         template.sendBody("seda:foo1", "blah");
 
-        Thread.sleep(250);
-
         mock.expectedBodiesReceived("test:blah");
         mock.expectedHeaderReceived(Exchange.TO_ENDPOINT, "seda://foo1");
+
         template.sendBody("direct:enricher-test-1", "test");
+
         mock.assertIsSatisfied();
     }
 
@@ -101,8 +96,6 @@ public class PollEnricherTest extends Co
     public void testPollEnrichInOut() throws InterruptedException {
         template.sendBody("seda:foo4", "blah");
 
-        Thread.sleep(250);
-
         String result = (String) template.sendBody("direct:enricher-test-4", ExchangePattern.InOut, "test");
         assertEquals("test:blah", result);
     }
@@ -110,8 +103,6 @@ public class PollEnricherTest extends Co
     public void testPollEnrichInOutPlusHeader() throws InterruptedException {
         template.sendBody("seda:foo4", "blah");
 
-        Thread.sleep(250);
-
         Exchange exchange = template.request("direct:enricher-test-4", new Processor() {
             public void process(Exchange exchange) {
                 exchange.getIn().setHeader("foo", "bar");

Modified: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala?rev=1233442&r1=1233441&r2=1233442&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala (original)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala Thu Jan 19 15:49:54 2012
@@ -107,7 +107,7 @@ abstract class SAbstractDefinition[P <: 
 
   def pipeline = SPipelineDefinition(target.pipeline)
   def policy(policy: Policy) = wrap(target.policy(policy))
-  def pollEnrich(uri: String, strategy: AggregationStrategy = null, timeout: Long = 0) =
+  def pollEnrich(uri: String, strategy: AggregationStrategy = null, timeout: Long = -1) =
     wrap(target.pollEnrich(uri, timeout, strategy))
   def process(function: Exchange => Unit) = wrap(target.process(new ScalaProcessor(function)))
   def process(processor: Processor) = wrap(target.process(processor))