camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r773318 - /camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpSyncTest.java
Date Sun, 10 May 2009 09:08:56 GMT
Author: davsclaus
Date: Sun May 10 09:08:56 2009
New Revision: 773318

URL: http://svn.apache.org/viewvc?rev=773318&view=rev
Log:
CAMEL-1572: Added another sync sample for comparision with async for show and tell.

Added:
    camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpSyncTest.java
      - copied, changed from r773224, camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java

Copied: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpSyncTest.java
(from r773224, camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpSyncTest.java?p2=camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpSyncTest.java&p1=camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java&r1=773224&r2=773318&rev=773318&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java
(original)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpSyncTest.java
Sun May 10 09:08:56 2009
@@ -25,34 +25,22 @@
 /**
  * @version $Revision$
  */
-public class HttpAsyncTest extends ContextTestSupport {
+public class HttpSyncTest extends ContextTestSupport {
 
-    public void testAsyncAndSyncAtSameTimeWithHttp() throws Exception {
+    public void testSyncAndSyncAtSameTimeWithHttp() throws Exception {
         // START SNIPPET: e2
         MockEndpoint mock = getMockEndpoint("mock:result");
-        // We expect the name job to be faster than the async job even though the async job
-        // was started first
-        mock.expectedBodiesReceived("Claus", "Bye World");
+        // We expect the http job to complete before the name job
+        mock.expectedBodiesReceived("Bye World", "Claus");
 
-        // Send a async request/reply message to the http endpoint
-        Future future = template.asyncRequestBody("http://0.0.0.0:9080/myservice", "Hello
World");
+        // Send a sync request/reply message to the http endpoint
+        String response = template.requestBody("http://0.0.0.0:9080/myservice", "Hello World",
String.class);
+        assertEquals("Bye World", response);
 
-        // We got the future so in the meantime we can do other stuff, as this is Camel
-        // so lets invoke another request/reply route but this time is synchronous
+        // Send a sync request/reply message to the direct endpoint
         String name = template.requestBody("direct:name", "Give me a name", String.class);
         assertEquals("Claus", name);
 
-        // Okay we got a name and we have done some other work at the same time
-        // the async route is running, but now its about time to wait and get
-        // get the response from the async task
-
-        // We use the extract future body to get the response from the future
-        // (waiting if needed) and then return a string body response.
-        // This allows us to do this in a single code line instead of using the
-        // JDK Future API to get hold of it, but you can also use that if you want
-        String response = template.extractFutureBody(future, String.class);
-        assertEquals("Bye World", response);
-
         assertMockEndpointsSatisfied();
         // END SNIPPET: e2
     }
@@ -78,4 +66,4 @@
         };
     }
 
-}
+}
\ No newline at end of file



Mime
View raw message