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 2010/04/26 13:39:11 UTC
svn commit: r938010 - in /camel/trunk:
camel-core/src/main/java/org/apache/camel/component/mock/
components/camel-test/src/main/java/org/apache/camel/test/
components/camel-test/src/main/java/org/apache/camel/test/junit4/
Author: davsclaus
Date: Mon Apr 26 11:39:10 2010
New Revision: 938010
URL: http://svn.apache.org/viewvc?rev=938010&view=rev
Log:
Made it easier to let multiple mocks have longer timeout when testing.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java?rev=938010&r1=938009&r2=938010&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java Mon Apr 26 11:39:10 2010
@@ -153,6 +153,28 @@ public class MockEndpoint extends Defaul
}
/**
+ * Asserts that all the expectations on any {@link MockEndpoint} instances registered
+ * in the given context are valid
+ *
+ * @param context the camel context used to find all the available endpoints to be asserted
+ * @param timeout timeout
+ * @param unit time unit
+ */
+ public static void assertIsSatisfied(CamelContext context, long timeout, TimeUnit unit) throws InterruptedException {
+ ObjectHelper.notNull(context, "camelContext");
+ ObjectHelper.notNull(unit, "unit");
+ Collection<Endpoint> endpoints = context.getEndpoints();
+ long millis = unit.toMillis(timeout);
+ for (Endpoint endpoint : endpoints) {
+ if (endpoint instanceof MockEndpoint) {
+ MockEndpoint mockEndpoint = (MockEndpoint) endpoint;
+ mockEndpoint.setResultWaitTime(millis);
+ mockEndpoint.assertIsSatisfied();
+ }
+ }
+ }
+
+ /**
* Reset all mock endpoints
*
* @param context the camel context used to find all the available endpoints to reset
Modified: camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java?rev=938010&r1=938009&r2=938010&view=diff
==============================================================================
--- camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java (original)
+++ camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java Mon Apr 26 11:39:10 2010
@@ -20,6 +20,7 @@ import java.io.InputStream;
import java.util.Hashtable;
import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.TimeUnit;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -346,6 +347,13 @@ public abstract class CamelTestSupport e
}
/**
+ * Asserts that all the expectations of the Mock endpoints are valid
+ */
+ protected void assertMockEndpointsSatisfied(long timeout, TimeUnit unit) throws InterruptedException {
+ MockEndpoint.assertIsSatisfied(context, timeout, unit);
+ }
+
+ /**
* Reset all Mock endpoints.
*/
protected void resetMocks() {
Modified: camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java?rev=938010&r1=938009&r2=938010&view=diff
==============================================================================
--- camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java (original)
+++ camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java Mon Apr 26 11:39:10 2010
@@ -20,6 +20,7 @@ import java.io.InputStream;
import java.util.Hashtable;
import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.TimeUnit;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -347,6 +348,13 @@ public abstract class CamelTestSupport e
}
/**
+ * Asserts that all the expectations of the Mock endpoints are valid
+ */
+ protected void assertMockEndpointsSatisfied(long timeout, TimeUnit unit) throws InterruptedException {
+ MockEndpoint.assertIsSatisfied(context, timeout, unit);
+ }
+
+ /**
* Reset all Mock endpoints.
*/
protected void resetMocks() {