Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 76C09187F8 for ; Sun, 10 Jan 2016 10:12:44 +0000 (UTC) Received: (qmail 90877 invoked by uid 500); 10 Jan 2016 10:12:44 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 90777 invoked by uid 500); 10 Jan 2016 10:12:44 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 90725 invoked by uid 99); 10 Jan 2016 10:12:44 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Jan 2016 10:12:44 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 35A52DFD7B; Sun, 10 Jan 2016 10:12:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Sun, 10 Jan 2016 10:12:45 -0000 Message-Id: In-Reply-To: <1cd71af865374f8caefe4bcdacab4dea@git.apache.org> References: <1cd71af865374f8caefe4bcdacab4dea@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] camel git commit: Fixed and speedup test Fixed and speedup test Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9344aa87 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9344aa87 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9344aa87 Branch: refs/heads/camel-2.16.x Commit: 9344aa8741b94cfb3997ebcde06fba899c57a10a Parents: 92b137d Author: Claus Ibsen Authored: Sun Jan 10 11:12:14 2016 +0100 Committer: Claus Ibsen Committed: Sun Jan 10 11:12:34 2016 +0100 ---------------------------------------------------------------------- .../beanstalk/ConsumerCompletionTest.java | 33 +++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/9344aa87/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java ---------------------------------------------------------------------- diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java index 40d9437..809b78a 100644 --- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java +++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java @@ -16,14 +16,18 @@ */ package org.apache.camel.component.beanstalk; +import java.util.concurrent.TimeUnit; + import com.surftools.BeanstalkClient.BeanstalkException; import com.surftools.BeanstalkClient.Job; import org.apache.camel.Exchange; import org.apache.camel.Processor; +import org.apache.camel.builder.NotifyBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.Test; +import static org.mockito.Matchers.anyLong; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.atLeastOnce; @@ -59,15 +63,21 @@ public class ConsumerCompletionTest extends BeanstalkMockTestSupport { when(client.reserve(anyInt())) .thenReturn(jobMock) .thenReturn(null); + when(client.statsJob(anyInt())).thenReturn(null); MockEndpoint result = getMockEndpoint("mock:result"); + result.expectedMinimumMessageCount(1); result.expectedBodiesReceived(testMessage); result.expectedHeaderReceived(Headers.JOB_ID, jobId); result.message(0).header(Headers.JOB_ID).isEqualTo(jobId); - result.assertIsSatisfied(2000); + + context.startRoute("foo"); + + result.assertIsSatisfied(); verify(client, atLeastOnce()).reserve(anyInt()); + verify(client, atLeastOnce()).statsJob(anyInt()); verify(client).delete(jobId); } @@ -85,12 +95,20 @@ public class ConsumerCompletionTest extends BeanstalkMockTestSupport { when(client.reserve(anyInt())) .thenReturn(jobMock) .thenReturn(null); + when(client.statsJob(anyInt())).thenReturn(null); + when(client.release(anyInt(), anyLong(), anyInt())).thenReturn(true); + + NotifyBuilder notify = new NotifyBuilder(context).whenFailed(1).create(); MockEndpoint result = getMockEndpoint("mock:result"); - result.expectedMinimumMessageCount(1); - result.assertIsNotSatisfied(1000); + result.expectedMessageCount(0); + + context.startRoute("foo"); + + assertTrue(notify.matches(5, TimeUnit.SECONDS)); verify(client, atLeastOnce()).reserve(anyInt()); + verify(client, atLeastOnce()).statsJob(anyInt()); verify(client).release(jobId, priority, delay); } @@ -110,13 +128,17 @@ public class ConsumerCompletionTest extends BeanstalkMockTestSupport { when(client.reserve(anyInt())) .thenThrow(new BeanstalkException("test")) .thenReturn(jobMock); + when(client.statsJob(anyInt())).thenReturn(null); MockEndpoint result = getMockEndpoint("mock:result"); result.expectedMessageCount(1); result.expectedBodiesReceived(testMessage); result.expectedHeaderReceived(Headers.JOB_ID, jobId); result.message(0).header(Headers.JOB_ID).isEqualTo(jobId); - result.assertIsSatisfied(100); + + context.startRoute("foo"); + + result.assertIsSatisfied(); verify(client, atLeast(1)).reserve(anyInt()); verify(client, times(1)).close(); @@ -127,7 +149,8 @@ public class ConsumerCompletionTest extends BeanstalkMockTestSupport { return new RouteBuilder() { @Override public void configure() { - from("beanstalk:tube?consumer.onFailure=release").process(processor).to("mock:result"); + from("beanstalk:tube?consumer.onFailure=release").routeId("foo") + .process(processor).to("mock:result"); } }; }