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 2016/01/10 11:12:45 UTC
[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 <da...@apache.org>
Authored: Sun Jan 10 11:12:14 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
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");
}
};
}