Author: davsclaus Date: Thu Jan 19 15:57:52 2012 New Revision: 1233444 URL: http://svn.apache.org/viewvc?rev=1233444&view=rev Log: CAMEL-4920: PollEnrich without timeout explicit given, should be like -1 as timeout, eg block until message arrives.
Modified: camel/branches/camel-2.9.x/ (props changed) camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java camel/branches/camel-2.9.x/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala Propchange: camel/branches/camel-2.9.x/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Jan 19 15:57:52 2012 @@ -1 +1 @@ -/camel/trunk:1227209,1227212,1227540,1228015,1228027,1228223,1228879,1229565,1231135,1231704,1232309,1232312,1232429,1232763,1232782,1232834,1233183,1233259,1233269,1233398 +/camel/trunk:1227209,1227212,1227540,1228015,1228027,1228223,1228879,1229565,1231135,1231704,1232309,1232312,1232429,1232763,1232782,1232834,1233183,1233259,1233269,1233398,1233442 Propchange: camel/branches/camel-2.9.x/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Thu Jan 19 15:57:52 2012 @@ -1 +1 @@ -/camel/trunk:1-1227196,1227209,1227212,1227540,1228015,1228027,1228223,1228879,1229565,1231135,1231704,1232309,1232312,1232429,1232763,1232782,1232834,1233183,1233259,1233269,1233398 +/camel/trunk:1-1227196,1227209,1227212,1227540,1228015,1228027,1228223,1228879,1229565,1231135,1231704,1232309,1232312,1232429,1232763,1232782,1232834,1233183,1233259,1233269,1233398,1233442 Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java?rev=1233444&r1=1233443&r2=1233444&view=diff ============================================================================== --- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java (original) +++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java Thu Jan 19 15:57:52 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/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java?rev=1233444&r1=1233443&r2=1233444&view=diff ============================================================================== --- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java (original) +++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java Thu Jan 19 15:57:52 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/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java?rev=1233444&r1=1233443&r2=1233444&view=diff ============================================================================== --- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java (original) +++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherNoResourceTest.java Thu Jan 19 15:57:52 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/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java?rev=1233444&r1=1233443&r2=1233444&view=diff ============================================================================== --- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java (original) +++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java Thu Jan 19 15:57:52 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/branches/camel-2.9.x/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala?rev=1233444&r1=1233443&r2=1233444&view=diff ============================================================================== --- camel/branches/camel-2.9.x/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala (original) +++ camel/branches/camel-2.9.x/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SAbstractDefinition.scala Thu Jan 19 15:57:52 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))