camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1044224 - in /camel/trunk/camel-core/src/test/java/org/apache/camel: builder/NotifyBuilderTest.java processor/SplitterTest.java
Date Fri, 10 Dec 2010 07:14:16 GMT
Author: davsclaus
Date: Fri Dec 10 07:14:16 2010
New Revision: 1044224

URL: http://svn.apache.org/viewvc?rev=1044224&view=rev
Log:
NotifyBuilderTest now looks as if a Camel end user would use NotifyBuilder. Fixed CS.

Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java?rev=1044224&r1=1044223&r2=1044224&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java Fri
Dec 10 07:14:16 2010
@@ -16,11 +16,8 @@
  */
 package org.apache.camel.builder;
 
-import java.util.concurrent.TimeUnit;
-
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.seda.SedaEndpoint;
 
 /**
  * @version $Revision$
@@ -28,343 +25,386 @@ import org.apache.camel.component.seda.S
 public class NotifyBuilderTest extends ContextTestSupport {
 
     public void testDirectWhenExchangeDoneSimple() throws Exception {
-        NotifyBuilder event = event()
-            .from("direct:foo").whenDone(1)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .from("direct:foo").whenDone(1)
+                .create();
+
+        assertEquals("from(direct:foo).whenDone(1)", notify.toString());
 
-        assertEquals("from(direct:foo).whenDone(1)", event.toString());
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "A");
-        assertEquals(true, event.matches());
+
+        assertEquals(true, notify.matches());
     }
 
     public void testDirectBeerWhenExchangeDoneSimple() throws Exception {
-        NotifyBuilder event = event()
-            .from("direct:beer").whenDone(1)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .from("direct:beer").whenDone(1)
+                .create();
 
-        assertEquals("from(direct:beer).whenDone(1)", event.toString());
-        assertEquals(false, event.matches());
+        assertEquals("from(direct:beer).whenDone(1)", notify.toString());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:beer", "A");
-        assertEquals(true, event.matches());
+
+        assertEquals(true, notify.matches());
     }
 
     public void testDirectFromRoute() throws Exception {
-        NotifyBuilder event = event()
-            .fromRoute("foo").whenDone(1)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .fromRoute("foo").whenDone(1)
+                .create();
+
+        assertEquals("fromRoute(foo).whenDone(1)", notify.toString());
 
-        assertEquals("fromRoute(foo).whenDone(1)", event.toString());
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "A");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "B");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
     }
 
     public void testDirectFromRouteReceived() throws Exception {
-        NotifyBuilder event = event()
-            .fromRoute("foo").whenReceived(1)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .fromRoute("foo").whenReceived(1)
+                .create();
 
-        assertEquals("fromRoute(foo).whenReceived(1)", event.toString());
-        assertEquals(false, event.matches());
+        assertEquals("fromRoute(foo).whenReceived(1)", notify.toString());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "A");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "B");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
     }
 
     public void testWhenExchangeDone() throws Exception {
-        NotifyBuilder event = event()
-            .from("direct:foo").whenDone(5)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .from("direct:foo").whenDone(5)
+                .create();
+
+        assertEquals("from(direct:foo).whenDone(5)", notify.toString());
 
-        assertEquals("from(direct:foo).whenDone(5)", event.toString());
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "A");
         template.sendBody("direct:foo", "B");
         template.sendBody("direct:foo", "C");
+
         template.sendBody("direct:bar", "D");
         template.sendBody("direct:bar", "E");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "F");
         template.sendBody("direct:bar", "G");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "H");
         template.sendBody("direct:bar", "I");
-        assertEquals(true, event.matches());
+
+        assertEquals(true, notify.matches());
     }
 
     public void testWhenExchangeDoneAnd() throws Exception {
-        NotifyBuilder event = event()
-            .from("direct:foo").whenDone(5)
-            .and().from("direct:bar").whenDone(7)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .from("direct:foo").whenDone(5)
+                .and().from("direct:bar").whenDone(7)
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "A");
         template.sendBody("direct:foo", "B");
         template.sendBody("direct:foo", "C");
+
         template.sendBody("direct:bar", "D");
         template.sendBody("direct:bar", "E");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "F");
         template.sendBody("direct:bar", "G");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "H");
         template.sendBody("direct:bar", "I");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "J");
         template.sendBody("direct:bar", "K");
         template.sendBody("direct:bar", "L");
-        assertEquals(true, event.matches());
+
+        assertEquals(true, notify.matches());
     }
 
     public void testFromRouteWhenExchangeDoneAnd() throws Exception {
-        NotifyBuilder event = event()
-            .fromRoute("foo").whenDone(5)
-            .and().fromRoute("bar").whenDone(7)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .fromRoute("foo").whenDone(5)
+                .and().fromRoute("bar").whenDone(7)
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "A");
         template.sendBody("direct:foo", "B");
         template.sendBody("direct:foo", "C");
+
         template.sendBody("direct:bar", "D");
         template.sendBody("direct:bar", "E");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "F");
         template.sendBody("direct:bar", "G");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "H");
         template.sendBody("direct:bar", "I");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "J");
         template.sendBody("direct:bar", "K");
         template.sendBody("direct:bar", "L");
-        assertEquals(true, event.matches());
+
+        assertEquals(true, notify.matches());
     }
 
     public void testFromRouteAndNot() throws Exception {
-        NotifyBuilder event = event()
-            .fromRoute("foo").whenDone(2)
-            .and().fromRoute("bar").whenReceived(1)
-            .not().fromRoute("cake").whenDone(1)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .fromRoute("foo").whenDone(2)
+                .and().fromRoute("bar").whenReceived(1)
+                .not().fromRoute("cake").whenDone(1)
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "A");
         template.sendBody("direct:foo", "B");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "C");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:foo", "D");
         template.sendBody("direct:bar", "E");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         // and now the cake to make it false
         template.sendBody("direct:cake", "F");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
     }
 
     public void testWhenExchangeDoneOr() throws Exception {
-        NotifyBuilder event = event()
-            .from("direct:foo").whenDone(5)
-            .or().from("direct:bar").whenDone(7)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .from("direct:foo").whenDone(5)
+                .or().from("direct:bar").whenDone(7)
+                .create();
+
+        assertEquals("from(direct:foo).whenDone(5).or().from(direct:bar).whenDone(7)", notify.toString());
 
-        assertEquals("from(direct:foo).whenDone(5).or().from(direct:bar).whenDone(7)", event.toString());
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "A");
         template.sendBody("direct:foo", "B");
         template.sendBody("direct:foo", "C");
+
         template.sendBody("direct:bar", "D");
         template.sendBody("direct:bar", "E");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "G");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "I");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "J");
         template.sendBody("direct:bar", "K");
         template.sendBody("direct:bar", "L");
-        assertEquals(true, event.matches());
+
+        assertEquals(true, notify.matches());
     }
 
     public void testWhenExchangeDoneNot() throws Exception {
-        NotifyBuilder event = event()
-            .from("direct:foo").whenDone(5)
-            .not().from("direct:bar").whenDone(1)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .from("direct:foo").whenDone(5)
+                .not().from("direct:bar").whenDone(1)
+                .create();
+
+        assertEquals("from(direct:foo).whenDone(5).not().from(direct:bar).whenDone(1)", notify.toString());
 
-        assertEquals("from(direct:foo).whenDone(5).not().from(direct:bar).whenDone(1)", event.toString());
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "A");
         template.sendBody("direct:foo", "B");
         template.sendBody("direct:foo", "C");
         template.sendBody("direct:foo", "D");
-        assertEquals(false, event.matches());
 
+        assertEquals(false, notify.matches());
         template.sendBody("direct:foo", "E");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:foo", "F");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:bar", "G");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
     }
 
     public void testWhenExchangeDoneOrFailure() throws Exception {
-        NotifyBuilder event = event()
-            .whenDone(5)
-            .or().whenFailed(1)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenDone(5)
+                .or().whenFailed(1)
+                .create();
+
+        assertEquals("whenDone(5).or().whenFailed(1)", notify.toString());
 
-        assertEquals("whenDone(5).or().whenFailed(1)", event.toString());
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "A");
         template.sendBody("direct:foo", "B");
         template.sendBody("direct:foo", "D");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         try {
             template.sendBody("direct:fail", "E");
         } catch (Exception e) {
             // ignore
         }
-        assertEquals(true, event.matches());
+
+        assertEquals(true, notify.matches());
     }
 
     public void testWhenExchangeDoneNotFailure() throws Exception {
-        NotifyBuilder event = event()
-            .whenDone(5)
-            .not().whenFailed(1)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenDone(5)
+                .not().whenFailed(1)
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "A");
         template.sendBody("direct:foo", "B");
         template.sendBody("direct:foo", "D");
         template.sendBody("direct:bar", "E");
         template.sendBody("direct:bar", "F");
-        assertEquals(true, event.matches());
+
+        assertEquals(true, notify.matches());
 
         try {
             template.sendBody("direct:fail", "G");
         } catch (Exception e) {
             // ignore
         }
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
     }
 
     public void testFilterWhenExchangeDone() throws Exception {
-        NotifyBuilder event = event()
-            .filter(body().contains("World")).whenDone(3)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .filter(body().contains("World")).whenDone(3)
+                .create();
+
+        assertEquals("filter(body contains World).whenDone(3)", notify.toString());
 
-        assertEquals("filter(body contains World).whenDone(3)", event.toString());
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hello World");
         template.sendBody("direct:foo", "Hi World");
         template.sendBody("direct:foo", "A");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "B");
         template.sendBody("direct:bar", "C");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "Bye World");
-        assertEquals(true, event.matches());
+
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:foo", "D");
         template.sendBody("direct:bar", "Hey World");
-        assertEquals(true, event.matches());
+
+        assertEquals(true, notify.matches());
     }
 
     public void testFromFilterWhenExchangeDone() throws Exception {
-        NotifyBuilder event = event()
-            .from("direct:foo").filter(body().contains("World")).whenDone(3)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .from("direct:foo").filter(body().contains("World")).whenDone(3)
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hello World");
         template.sendBody("direct:foo", "Hi World");
         template.sendBody("direct:foo", "A");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "B");
         template.sendBody("direct:foo", "C");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "Bye World");
-        assertEquals(false, event.matches());
+
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "D");
         template.sendBody("direct:foo", "Hey World");
-        assertEquals(true, event.matches());
+
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:bar", "E");
         template.sendBody("direct:foo", "Hi Again World");
-        assertEquals(true, event.matches());
+
+        assertEquals(true, notify.matches());
     }
 
     public void testFromFilterBuilderWhenExchangeDone() throws Exception {
-        NotifyBuilder event = event()
-            .filter().xpath("/person[@name='James']").whenDone(1)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .filter().xpath("/person[@name='James']").whenDone(1)
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "<person name='Claus'/>");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "<person name='Jonathan'/>");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "<person name='James'/>");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:foo", "<person name='Hadrian'/>");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
     }
 
     public void testWhenExchangeCompleted() throws Exception {
-        NotifyBuilder event = event()
-            .whenCompleted(5)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenCompleted(5)
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "A");
         template.sendBody("direct:foo", "B");
@@ -381,62 +421,66 @@ public class NotifyBuilderTest extends C
         } catch (Exception e) {
             // ignore
         }
+
         // should NOT be completed as it only counts successful exchanges
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "F");
         template.sendBody("direct:foo", "G");
         template.sendBody("direct:bar", "H");
+
         // now it should match
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
     }
 
     public void testWhenExchangeExactlyDone() throws Exception {
-        NotifyBuilder event = event()
-            .whenExactlyDone(5)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenExactlyDone(5)
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "A");
         template.sendBody("direct:foo", "B");
         template.sendBody("direct:foo", "C");
+
         template.sendBody("direct:bar", "D");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "E");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:foo", "F");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
     }
 
     public void testWhenExchangeExactlyComplete() throws Exception {
-        NotifyBuilder event = event()
-            .whenExactlyCompleted(5)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenExactlyCompleted(5)
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "A");
         template.sendBody("direct:foo", "B");
         template.sendBody("direct:foo", "C");
+
         template.sendBody("direct:bar", "D");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "E");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:foo", "F");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
     }
 
     public void testWhenExchangeExactlyFailed() throws Exception {
-        NotifyBuilder event = event()
-            .whenExactlyFailed(2)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenExactlyFailed(2)
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "A");
         template.sendBody("direct:foo", "B");
@@ -449,170 +493,170 @@ public class NotifyBuilderTest extends C
         }
 
         template.sendBody("direct:bar", "E");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         try {
             template.sendBody("direct:fail", "F");
         } catch (Exception e) {
             // ignore
         }
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:bar", "G");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         try {
             template.sendBody("direct:fail", "H");
         } catch (Exception e) {
             // ignore
         }
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
     }
 
     public void testWhenAnyReceivedMatches() throws Exception {
-        NotifyBuilder event = event()
-            .whenAnyReceivedMatches(body().contains("Camel"))
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenAnyReceivedMatches(body().contains("Camel"))
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hello World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Bye World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "Hello Camel");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
     }
 
     public void testWhenAllReceivedMatches() throws Exception {
-        NotifyBuilder event = event()
-            .whenAllReceivedMatches(body().contains("Camel"))
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenAllReceivedMatches(body().contains("Camel"))
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hello Camel");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:foo", "Bye Camel");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:bar", "Hello World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
     }
 
     public void testWhenAnyDoneMatches() throws Exception {
-        NotifyBuilder event = event()
-            .whenAnyDoneMatches(body().contains("Bye"))
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenAnyDoneMatches(body().contains("Bye"))
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hi World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:cake", "Camel");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:foo", "Damn World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
     }
 
     public void testWhenAllDoneMatches() throws Exception {
-        NotifyBuilder event = event()
-            .whenAllDoneMatches(body().contains("Bye"))
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenAllDoneMatches(body().contains("Bye"))
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:cake", "Camel");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:cake", "World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:foo", "Hi World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
     }
 
     public void testWhenBodiesReceived() throws Exception {
-        NotifyBuilder event = event()
-            .whenBodiesReceived("Hi World", "Hello World")
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenBodiesReceived("Hi World", "Hello World")
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hi World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hello World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         // should keep being true
         template.sendBody("direct:foo", "Bye World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:foo", "Damn World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
     }
 
     public void testWhenBodiesDone() throws Exception {
-        NotifyBuilder event = event()
-            .whenBodiesDone("Bye World", "Bye Camel")
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenBodiesDone("Bye World", "Bye Camel")
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.requestBody("direct:cake", "World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:cake", "Camel");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         // should keep being true
         template.sendBody("direct:foo", "Damn World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
     }
 
     public void testWhenExactBodiesReceived() throws Exception {
-        NotifyBuilder event = event()
-            .whenExactBodiesReceived("Hi World", "Hello World")
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenExactBodiesReceived("Hi World", "Hello World")
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hi World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hello World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         // should not keep being true
         template.sendBody("direct:foo", "Bye World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Damn World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
     }
 
     public void testWhenExactBodiesDone() throws Exception {
-        NotifyBuilder event = event()
-            .whenExactBodiesDone("Bye World", "Bye Camel")
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenExactBodiesDone("Bye World", "Bye Camel")
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.requestBody("direct:cake", "World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:cake", "Camel");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         // should NOT keep being true
         template.sendBody("direct:foo", "Damn World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
     }
 
     public void testWhenReceivedSatisfied() throws Exception {
@@ -621,24 +665,24 @@ public class NotifyBuilderTest extends C
         MockEndpoint mock = getMockEndpoint("mock:assert");
         mock.expectedBodiesReceivedInAnyOrder("Hello World", "Bye World", "Hi World");
 
-        NotifyBuilder event = event()
-            .from("direct:foo").whenDoneSatisfied(mock)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .from("direct:foo").whenDoneSatisfied(mock)
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Bye World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hello World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
-        // the event  is based on direct:foo so sending to bar should not trigger match
+        // the notify  is based on direct:foo so sending to bar should not trigger match
         template.sendBody("direct:bar", "Hi World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hi World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
     }
 
     public void testWhenReceivedNotSatisfied() throws Exception {
@@ -648,18 +692,18 @@ public class NotifyBuilderTest extends C
         mock.expectedMessageCount(2);
         mock.message(1).body().contains("Camel");
 
-        NotifyBuilder event = event()
-            .from("direct:foo").whenReceivedNotSatisfied(mock)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .from("direct:foo").whenReceivedNotSatisfied(mock)
+                .create();
 
         // is always false to start with
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Bye World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:foo", "Hello Camel");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
     }
 
     public void testWhenNotSatisfiedUsingSatisfied() throws Exception {
@@ -669,50 +713,50 @@ public class NotifyBuilderTest extends C
         mock.expectedMessageCount(2);
         mock.message(1).body().contains("Camel");
 
-        NotifyBuilder event = event()
-            .from("direct:foo").whenReceivedSatisfied(mock)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .from("direct:foo").whenReceivedSatisfied(mock)
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Bye World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hello Camel");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
     }
 
     public void testComplexOrCamel() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:assert");
         mock.expectedBodiesReceivedInAnyOrder("Hello World", "Bye World", "Hi World");
 
-        NotifyBuilder event = event()
-            .from("direct:foo").whenReceivedSatisfied(mock)
-            .and().from("direct:bar").whenExactlyDone(5).whenAnyReceivedMatches(body().contains("Camel"))
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .from("direct:foo").whenReceivedSatisfied(mock)
+                .and().from("direct:bar").whenExactlyDone(5).whenAnyReceivedMatches(body().contains("Camel"))
+                .create();
 
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Bye World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hello World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
-        // the event  is based on direct:foo so sending to bar should not trigger match
+        // the notify  is based on direct:foo so sending to bar should not trigger match
         template.sendBody("direct:bar", "Hi World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hi World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "Hi Camel");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:bar", "A");
         template.sendBody("direct:bar", "B");
         template.sendBody("direct:bar", "C");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
     }
 
     public void testWhenDoneSatisfied() throws Exception {
@@ -721,22 +765,22 @@ public class NotifyBuilderTest extends C
         MockEndpoint mock = getMockEndpoint("mock:assert");
         mock.expectedBodiesReceived("Bye World", "Bye Camel");
 
-        NotifyBuilder event = event()
-            .whenDoneSatisfied(mock)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenDoneSatisfied(mock)
+                .create();
 
         // is always false to start with
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.requestBody("direct:cake", "World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.requestBody("direct:cake", "Camel");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.requestBody("direct:cake", "Damn");
         // will still be true as the mock has been completed
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
     }
 
     public void testWhenDoneNotSatisfied() throws Exception {
@@ -745,64 +789,64 @@ public class NotifyBuilderTest extends C
         MockEndpoint mock = getMockEndpoint("mock:assert");
         mock.expectedBodiesReceived("Bye World", "Bye Camel");
 
-        NotifyBuilder event = event()
-            .whenDoneNotSatisfied(mock)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenDoneNotSatisfied(mock)
+                .create();
 
         // is always false to start with
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.requestBody("direct:cake", "World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.requestBody("direct:cake", "Camel");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.requestBody("direct:cake", "Damn");
         // will still be false as the mock has been completed
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
     }
 
     public void testReset() throws Exception {
-        NotifyBuilder event = event()
-            .whenExactlyDone(1)
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenExactlyDone(1)
+                .create();
 
         template.sendBody("direct:foo", "Hello World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:foo", "Bye World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         // reset
-        event.reset();
-        assertEquals(false, event.matches());
+        notify.reset();
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hello World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         template.sendBody("direct:foo", "Bye World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
     }
 
     public void testResetBodiesReceived() throws Exception {
-        NotifyBuilder event = event()
-            .whenBodiesReceived("Hello World", "Bye World")
-            .create();
+        NotifyBuilder notify = new NotifyBuilder(context)
+                .whenBodiesReceived("Hello World", "Bye World")
+                .create();
 
         template.sendBody("direct:foo", "Hello World");
         template.sendBody("direct:foo", "Bye World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
 
         // reset
-        event.reset();
-        assertEquals(false, event.matches());
+        notify.reset();
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Hello World");
-        assertEquals(false, event.matches());
+        assertEquals(false, notify.matches());
 
         template.sendBody("direct:foo", "Bye World");
-        assertEquals(true, event.matches());
+        assertEquals(true, notify.matches());
     }
 
     @Override

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java?rev=1044224&r1=1044223&r2=1044224&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java Fri
Dec 10 07:14:16 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.processor;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
@@ -140,9 +139,9 @@ public class SplitterTest extends Contex
         Message out = result.getOut();
 
         assertMessageHeader(out, "foo", "bar");
-        assertEquals((Integer)5, result.getProperty("aggregated", Integer.class));
+        assertEquals((Integer) 5, result.getProperty("aggregated", Integer.class));
     }
-    
+
     public void testSplitterWithAggregationStrategyParallelStreaming() throws Exception {
         MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
         resultEndpoint.expectedMessageCount(5);
@@ -160,9 +159,9 @@ public class SplitterTest extends Contex
         Message out = result.getOut();
 
         assertMessageHeader(out, "foo", "bar");
-        assertEquals((Integer)5, result.getProperty("aggregated", Integer.class));
+        assertEquals((Integer) 5, result.getProperty("aggregated", Integer.class));
     }
-    
+
     public void testSplitterWithStreaming() throws Exception {
         MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
         resultEndpoint.expectedMessageCount(5);
@@ -175,7 +174,7 @@ public class SplitterTest extends Contex
                 in.setHeader("foo", "bar");
             }
         });
-        
+
         assertMockEndpointsSatisfied();
         for (Exchange exchange : resultEndpoint.getReceivedExchanges()) {
             assertNotNull(exchange.getProperty(Exchange.SPLIT_INDEX));
@@ -183,16 +182,16 @@ public class SplitterTest extends Contex
             assertNull(exchange.getProperty(Exchange.SPLIT_SIZE));
         }
     }
-    
+
     public void testSplitterWithException() throws Exception {
         MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
         resultEndpoint.expectedMessageCount(4);
         resultEndpoint.expectedHeaderReceived("foo", "bar");
-        
+
         MockEndpoint failedEndpoint = getMockEndpoint("mock:failed");
         failedEndpoint.expectedMessageCount(1);
         failedEndpoint.expectedHeaderReceived("foo", "bar");
-        
+
         Exchange result = template.request("direct:exception", new Processor() {
             public void process(Exchange exchange) {
                 Message in = exchange.getIn();
@@ -200,7 +199,7 @@ public class SplitterTest extends Contex
                 in.setHeader("foo", "bar");
             }
         });
-        
+
         assertTrue("The result exchange should have a camel exception", result.getException()
instanceof CamelException);
 
         assertMockEndpointsSatisfied();
@@ -209,8 +208,8 @@ public class SplitterTest extends Contex
     public void testSplitterWithIterable() throws Exception {
         MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
         resultEndpoint.expectedMessageCount(4);
-        resultEndpoint.expectedBodiesReceived("A","B","C","D");
-        final List<String> data = Arrays.asList("A","B","C","D");
+        resultEndpoint.expectedBodiesReceived("A", "B", "C", "D");
+        final List<String> data = Arrays.asList("A", "B", "C", "D");
         Iterable itb = new Iterable() {
             public Iterator iterator() {
                 return data.iterator();
@@ -234,18 +233,18 @@ public class SplitterTest extends Contex
                 from("direct:parallel-streaming").split(body().tokenize(","), new MyAggregationStrategy()).parallelProcessing().streaming().to("mock:result");
 
                 from("direct:exception")
-                    .split(body().tokenize(","))
-                    .aggregationStrategy(new MyAggregationStrategy())
-                    .parallelProcessing()
-                    .process(new Processor() {
-                        public void process(Exchange exchange) throws Exception {
-                            String string = exchange.getIn().getBody(String.class);
-                            if ("Exception".equals(string)) {
-                                throw new CamelException("Just want to throw exception here");
+                        .split(body().tokenize(","))
+                        .aggregationStrategy(new MyAggregationStrategy())
+                        .parallelProcessing()
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                String string = exchange.getIn().getBody(String.class);
+                                if ("Exception".equals(string)) {
+                                    throw new CamelException("Just want to throw exception
here");
+                                }
+
                             }
-                        
-                        }                    
-                    }).to("mock:result");
+                        }).to("mock:result");
 
                 from("direct:simple").split(body()).to("mock:result");
             }



Mime
View raw message