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 2009/04/27 15:04:16 UTC

svn commit: r768963 - in /camel/trunk/camel-core/src/test/java/org/apache/camel/processor: InterceptEndpointTest.java InterceptorSimpleLogTest.java

Author: davsclaus
Date: Mon Apr 27 13:04:15 2009
New Revision: 768963

URL: http://svn.apache.org/viewvc?rev=768963&view=rev
Log:
CAMEL-1558: Added interceptEndpoint to intercept when an exchange is being sent to the given endpoint.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptorSimpleLogTest.java   (contents, props changed)
      - copied, changed from r768884, camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptorLogTest.java
Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptEndpointTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptEndpointTest.java?rev=768963&r1=768962&r2=768963&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptEndpointTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptEndpointTest.java Mon Apr 27 13:04:15 2009
@@ -66,7 +66,7 @@
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                // START SNIPPET: e1
+                // START SNIPPET: e2
                 // we can also attach a predicate to the endpoint interceptor. So in this example the exchange is
                 // only intercepted if the body is Hello World
                 interceptEndpoint("mock:foo").when(body().isEqualTo("Hello World")).to("mock:detour").transform(constant("Bye World"));
@@ -75,7 +75,7 @@
                     .to("mock:bar")
                     .to("mock:foo")
                     .to("mock:result");
-                // END SNIPPET: e1
+                // END SNIPPET: e2
 
             }
         });
@@ -97,7 +97,7 @@
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                // START SNIPPET: e1
+                // START SNIPPET: e3
                 // since we use the stop() at the end of the detour route we instruct Camel to skip
                 // sending the exchange to the original intended destination.
                 // That means that mock:foo will NOT receive the message, but the message
@@ -109,7 +109,7 @@
                     .to("mock:bar")
                     .to("mock:foo")
                     .to("mock:result");
-                // END SNIPPET: e1
+                // END SNIPPET: e3
             }
         });
         context.start();

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptorSimpleLogTest.java (from r768884, camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptorLogTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptorSimpleLogTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptorSimpleLogTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptorLogTest.java&r1=768884&r2=768963&rev=768963&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptorLogTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptorSimpleLogTest.java Mon Apr 27 13:04:15 2009
@@ -14,42 +14,39 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.issues;
+package org.apache.camel.processor;
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
 
 /**
  * Testing http://camel.apache.org/dsl.html
  */
-public class InterceptorLogTest extends ContextTestSupport {
+public class InterceptorSimpleLogTest extends ContextTestSupport {
 
-    public void testInterceptor() throws Exception {
-        MockEndpoint intercept = getMockEndpoint("mock:intercept");
-        intercept.expectedMessageCount(2);
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedMessageCount(1);
-        mock.expectedBodiesReceived("Hello World");
+    public void testInterceptLog() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+        getMockEndpoint("mock:first").expectedMessageCount(1);
 
-        template.sendBody("seda:foo", "Hello World");
+        template.sendBody("direct:start", "Hello World");
 
-        intercept.assertIsSatisfied();
-        mock.assertIsSatisfied();
+        assertMockEndpointsSatisfied();
     }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                // lets log all steps in all routes (must use proceed to let the exchange continue its
-                // normal route path instead of swallowing it here by our intercepter.
-                intercept().to("log:foo").proceed().to("mock:intercept");
-                intercept().to("log:bar").proceed();
-
-                from("seda:foo").to("seda:bar");
-                from("seda:bar").intercept().to("log:cheese").to("mock:result");
+                // START SNIPPET: e1
+                // intercept all incomming routes and log it
+                intercept().to("log:received");
+
+                // and here we have a couple of routes
+                from("direct:start").to("mock:first").to("seda:bar");
+                
+                from("seda:bar").to("mock:result");
+                // END SNIPPET: e1
             }
         };
     }
 
-}
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptorSimpleLogTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptorSimpleLogTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date