It's pretty much the same thing, and it shows how to use it in a simple way. The only way it would make a difference is if we'd change the event() method later, but I don't see that as being the case. I think it's ok the way it is, but if you feel strongly about reverting the change on the NotifyBuilderTest let me know and I'll do it.
Thanks Hadrian On Dec 9, 2010, at 1:25 PM, Claus Ibsen wrote: > It would probably be better to keep the NotifyBuilder test indpendent > of the event from ContextTestSupport. > Because this is an isolated test where you test NotifyBuilder. > > The event can be used in all the other places where it can make it > faster and easier to use, where we dont test NotifyBuilder but just > use it. > > > > On Thu, Dec 9, 2010 at 6:48 PM, <hadr...@apache.org> wrote: >> Author: hadrian >> Date: Thu Dec 9 17:48:31 2010 >> New Revision: 1044052 >> >> URL: http://svn.apache.org/viewvc?rev=1044052&view=rev >> Log: >> CAMEL-3411. Simplify usage of NotifyBuilder >> >> Modified: >> >> camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java >> >> camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java >> >> camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ZipDataFormatFileUnmarshalDeleteTest.java >> >> camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java >> >> Modified: >> camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java >> URL: >> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java?rev=1044052&r1=1044051&r2=1044052&view=diff >> ============================================================================== >> --- >> camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java >> (original) >> +++ >> camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java >> Thu Dec 9 17:48:31 2010 >> @@ -65,6 +65,13 @@ public abstract class ContextTestSupport >> this.camelContextService = camelContextService; >> } >> >> + /** >> + * Convenient api to create a NotifyBuilder to be notified of a >> specific event >> + */ >> + protected NotifyBuilder event() { >> + return new NotifyBuilder(context); >> + } >> + >> @Override >> protected void setUp() throws Exception { >> if (!useJmx()) { >> @@ -84,7 +91,7 @@ public abstract class ContextTestSupport >> consumer.start(); >> >> // create a default notifier when 1 exchange is done which is the >> most common caase >> - oneExchangeDone = new NotifyBuilder(context).whenDone(1).create(); >> + oneExchangeDone = event().whenDone(1).create(); >> >> if (isUseRouteBuilder()) { >> RouteBuilder[] builders = createRouteBuilders(); >> >> 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=1044052&r1=1044051&r2=1044052&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 >> Thu Dec 9 17:48:31 2010 >> @@ -28,386 +28,343 @@ import org.apache.camel.component.seda.S >> public class NotifyBuilderTest extends ContextTestSupport { >> >> public void testDirectWhenExchangeDoneSimple() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .from("direct:foo").whenDone(1) >> - .create(); >> + NotifyBuilder event = event() >> + .from("direct:foo").whenDone(1) >> + .create(); >> >> - assertEquals("from(direct:foo).whenDone(1)", notify.toString()); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals("from(direct:foo).whenDone(1)", event.toString()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "A"); >> - >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testDirectBeerWhenExchangeDoneSimple() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .from("direct:beer").whenDone(1) >> - .create(); >> - >> - assertEquals("from(direct:beer).whenDone(1)", notify.toString()); >> + NotifyBuilder event = event() >> + .from("direct:beer").whenDone(1) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals("from(direct:beer).whenDone(1)", event.toString()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:beer", "A"); >> - >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testDirectFromRoute() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .fromRoute("foo").whenDone(1) >> - .create(); >> - >> - assertEquals("fromRoute(foo).whenDone(1)", notify.toString()); >> + NotifyBuilder event = event() >> + .fromRoute("foo").whenDone(1) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals("fromRoute(foo).whenDone(1)", event.toString()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "A"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "B"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testDirectFromRouteReceived() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .fromRoute("foo").whenReceived(1) >> - .create(); >> - >> - assertEquals("fromRoute(foo).whenReceived(1)", notify.toString()); >> + NotifyBuilder event = event() >> + .fromRoute("foo").whenReceived(1) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals("fromRoute(foo).whenReceived(1)", event.toString()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "A"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "B"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testWhenExchangeDone() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .from("direct:foo").whenDone(5) >> - .create(); >> + NotifyBuilder event = event() >> + .from("direct:foo").whenDone(5) >> + .create(); >> >> - assertEquals("from(direct:foo).whenDone(5)", notify.toString()); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals("from(direct:foo).whenDone(5)", event.toString()); >> + assertEquals(false, event.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, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "F"); >> template.sendBody("direct:bar", "G"); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "H"); >> template.sendBody("direct:bar", "I"); >> - >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testWhenExchangeDoneAnd() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .from("direct:foo").whenDone(5) >> - .and().from("direct:bar").whenDone(7) >> - .create(); >> + NotifyBuilder event = event() >> + .from("direct:foo").whenDone(5) >> + .and().from("direct:bar").whenDone(7) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.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, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "F"); >> template.sendBody("direct:bar", "G"); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "H"); >> template.sendBody("direct:bar", "I"); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "J"); >> template.sendBody("direct:bar", "K"); >> template.sendBody("direct:bar", "L"); >> - >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testFromRouteWhenExchangeDoneAnd() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .fromRoute("foo").whenDone(5) >> - .and().fromRoute("bar").whenDone(7) >> - .create(); >> + NotifyBuilder event = event() >> + .fromRoute("foo").whenDone(5) >> + .and().fromRoute("bar").whenDone(7) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.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, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "F"); >> template.sendBody("direct:bar", "G"); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "H"); >> template.sendBody("direct:bar", "I"); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "J"); >> template.sendBody("direct:bar", "K"); >> template.sendBody("direct:bar", "L"); >> - >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testFromRouteAndNot() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .fromRoute("foo").whenDone(2) >> - .and().fromRoute("bar").whenReceived(1) >> - .not().fromRoute("cake").whenDone(1) >> - .create(); >> + NotifyBuilder event = event() >> + .fromRoute("foo").whenDone(2) >> + .and().fromRoute("bar").whenReceived(1) >> + .not().fromRoute("cake").whenDone(1) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "A"); >> template.sendBody("direct:foo", "B"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "C"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:foo", "D"); >> template.sendBody("direct:bar", "E"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> // and now the cake to make it false >> template.sendBody("direct:cake", "F"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> } >> >> public void testWhenExchangeDoneOr() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .from("direct:foo").whenDone(5) >> - .or().from("direct:bar").whenDone(7) >> - .create(); >> + NotifyBuilder event = event() >> + .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(false, notify.matches()); >> + >> assertEquals("from(direct:foo).whenDone(5).or().from(direct:bar).whenDone(7)", >> event.toString()); >> + assertEquals(false, event.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, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "G"); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "I"); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "J"); >> template.sendBody("direct:bar", "K"); >> template.sendBody("direct:bar", "L"); >> - >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testWhenExchangeDoneNot() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .from("direct:foo").whenDone(5) >> - .not().from("direct:bar").whenDone(1) >> - .create(); >> + NotifyBuilder event = event() >> + .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(false, notify.matches()); >> + >> assertEquals("from(direct:foo).whenDone(5).not().from(direct:bar).whenDone(1)", >> event.toString()); >> + assertEquals(false, event.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, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:foo", "F"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:bar", "G"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> } >> >> public void testWhenExchangeDoneOrFailure() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenDone(5) >> - .or().whenFailed(1) >> - .create(); >> - >> - assertEquals("whenDone(5).or().whenFailed(1)", notify.toString()); >> + NotifyBuilder event = event() >> + .whenDone(5) >> + .or().whenFailed(1) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals("whenDone(5).or().whenFailed(1)", event.toString()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "A"); >> template.sendBody("direct:foo", "B"); >> template.sendBody("direct:foo", "D"); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> try { >> template.sendBody("direct:fail", "E"); >> } catch (Exception e) { >> // ignore >> } >> - >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testWhenExchangeDoneNotFailure() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenDone(5) >> - .not().whenFailed(1) >> - .create(); >> + NotifyBuilder event = event() >> + .whenDone(5) >> + .not().whenFailed(1) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.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, notify.matches()); >> + assertEquals(true, event.matches()); >> >> try { >> template.sendBody("direct:fail", "G"); >> } catch (Exception e) { >> // ignore >> } >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> } >> >> public void testFilterWhenExchangeDone() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .filter(body().contains("World")).whenDone(3) >> - .create(); >> + NotifyBuilder event = event() >> + .filter(body().contains("World")).whenDone(3) >> + .create(); >> >> - assertEquals("filter(body contains World).whenDone(3)", >> notify.toString()); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals("filter(body contains World).whenDone(3)", >> event.toString()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hello World"); >> template.sendBody("direct:foo", "Hi World"); >> template.sendBody("direct:foo", "A"); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "B"); >> template.sendBody("direct:bar", "C"); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "Bye World"); >> - >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:foo", "D"); >> template.sendBody("direct:bar", "Hey World"); >> - >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testFromFilterWhenExchangeDone() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - >> .from("direct:foo").filter(body().contains("World")).whenDone(3) >> - .create(); >> + NotifyBuilder event = event() >> + .from("direct:foo").filter(body().contains("World")).whenDone(3) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hello World"); >> template.sendBody("direct:foo", "Hi World"); >> template.sendBody("direct:foo", "A"); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "B"); >> template.sendBody("direct:foo", "C"); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "Bye World"); >> - >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "D"); >> template.sendBody("direct:foo", "Hey World"); >> - >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:bar", "E"); >> template.sendBody("direct:foo", "Hi Again World"); >> - >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testFromFilterBuilderWhenExchangeDone() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .filter().xpath("/pers...@name='James']").whenDone(1) >> - .create(); >> + NotifyBuilder event = event() >> + .filter().xpath("/pers...@name='James']").whenDone(1) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "<person name='Claus'/>"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "<person name='Jonathan'/>"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "<person name='James'/>"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:foo", "<person name='Hadrian'/>"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testWhenExchangeCompleted() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenCompleted(5) >> - .create(); >> + NotifyBuilder event = event() >> + .whenCompleted(5) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "A"); >> template.sendBody("direct:foo", "B"); >> @@ -424,66 +381,62 @@ public class NotifyBuilderTest extends C >> } catch (Exception e) { >> // ignore >> } >> - >> // should NOT be completed as it only counts successful exchanges >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "F"); >> template.sendBody("direct:foo", "G"); >> template.sendBody("direct:bar", "H"); >> - >> // now it should match >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testWhenExchangeExactlyDone() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenExactlyDone(5) >> - .create(); >> + NotifyBuilder event = event() >> + .whenExactlyDone(5) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "A"); >> template.sendBody("direct:foo", "B"); >> template.sendBody("direct:foo", "C"); >> - >> template.sendBody("direct:bar", "D"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "E"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:foo", "F"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> } >> >> public void testWhenExchangeExactlyComplete() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenExactlyCompleted(5) >> - .create(); >> + NotifyBuilder event = event() >> + .whenExactlyCompleted(5) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "A"); >> template.sendBody("direct:foo", "B"); >> template.sendBody("direct:foo", "C"); >> - >> template.sendBody("direct:bar", "D"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "E"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:foo", "F"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> } >> >> public void testWhenExchangeExactlyFailed() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenExactlyFailed(2) >> - .create(); >> + NotifyBuilder event = event() >> + .whenExactlyFailed(2) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "A"); >> template.sendBody("direct:foo", "B"); >> @@ -496,170 +449,170 @@ public class NotifyBuilderTest extends C >> } >> >> template.sendBody("direct:bar", "E"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> try { >> template.sendBody("direct:fail", "F"); >> } catch (Exception e) { >> // ignore >> } >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:bar", "G"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> try { >> template.sendBody("direct:fail", "H"); >> } catch (Exception e) { >> // ignore >> } >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> } >> >> public void testWhenAnyReceivedMatches() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenAnyReceivedMatches(body().contains("Camel")) >> - .create(); >> + NotifyBuilder event = event() >> + .whenAnyReceivedMatches(body().contains("Camel")) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hello World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Bye World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "Hello Camel"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testWhenAllReceivedMatches() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenAllReceivedMatches(body().contains("Camel")) >> - .create(); >> + NotifyBuilder event = event() >> + .whenAllReceivedMatches(body().contains("Camel")) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hello Camel"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:foo", "Bye Camel"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:bar", "Hello World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> } >> >> public void testWhenAnyDoneMatches() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenAnyDoneMatches(body().contains("Bye")) >> - .create(); >> + NotifyBuilder event = event() >> + .whenAnyDoneMatches(body().contains("Bye")) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hi World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:cake", "Camel"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:foo", "Damn World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testWhenAllDoneMatches() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenAllDoneMatches(body().contains("Bye")) >> - .create(); >> + NotifyBuilder event = event() >> + .whenAllDoneMatches(body().contains("Bye")) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:cake", "Camel"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:cake", "World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:foo", "Hi World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> } >> >> public void testWhenBodiesReceived() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenBodiesReceived("Hi World", "Hello World") >> - .create(); >> + NotifyBuilder event = event() >> + .whenBodiesReceived("Hi World", "Hello World") >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hi World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hello World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> // should keep being true >> template.sendBody("direct:foo", "Bye World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:foo", "Damn World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testWhenBodiesDone() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenBodiesDone("Bye World", "Bye Camel") >> - .create(); >> + NotifyBuilder event = event() >> + .whenBodiesDone("Bye World", "Bye Camel") >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.requestBody("direct:cake", "World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:cake", "Camel"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> // should keep being true >> template.sendBody("direct:foo", "Damn World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testWhenExactBodiesReceived() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenExactBodiesReceived("Hi World", "Hello World") >> - .create(); >> + NotifyBuilder event = event() >> + .whenExactBodiesReceived("Hi World", "Hello World") >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hi World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hello World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> // should not keep being true >> template.sendBody("direct:foo", "Bye World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Damn World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> } >> >> public void testWhenExactBodiesDone() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenExactBodiesDone("Bye World", "Bye Camel") >> - .create(); >> + NotifyBuilder event = event() >> + .whenExactBodiesDone("Bye World", "Bye Camel") >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.requestBody("direct:cake", "World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:cake", "Camel"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> // should NOT keep being true >> template.sendBody("direct:foo", "Damn World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> } >> >> public void testWhenReceivedSatisfied() throws Exception { >> @@ -668,24 +621,24 @@ public class NotifyBuilderTest extends C >> MockEndpoint mock = getMockEndpoint("mock:assert"); >> mock.expectedBodiesReceivedInAnyOrder("Hello World", "Bye World", >> "Hi World"); >> >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .from("direct:foo").whenDoneSatisfied(mock) >> - .create(); >> + NotifyBuilder event = event() >> + .from("direct:foo").whenDoneSatisfied(mock) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Bye World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hello World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> - // the notify is based on direct:foo so sending to bar should not >> trigger match >> + // the event is based on direct:foo so sending to bar should not >> trigger match >> template.sendBody("direct:bar", "Hi World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hi World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testWhenReceivedNotSatisfied() throws Exception { >> @@ -695,18 +648,18 @@ public class NotifyBuilderTest extends C >> mock.expectedMessageCount(2); >> mock.message(1).body().contains("Camel"); >> >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .from("direct:foo").whenReceivedNotSatisfied(mock) >> - .create(); >> + NotifyBuilder event = event() >> + .from("direct:foo").whenReceivedNotSatisfied(mock) >> + .create(); >> >> // is always false to start with >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Bye World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:foo", "Hello Camel"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> } >> >> public void testWhenNotSatisfiedUsingSatisfied() throws Exception { >> @@ -716,50 +669,50 @@ public class NotifyBuilderTest extends C >> mock.expectedMessageCount(2); >> mock.message(1).body().contains("Camel"); >> >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .from("direct:foo").whenReceivedSatisfied(mock) >> - .create(); >> + NotifyBuilder event = event() >> + .from("direct:foo").whenReceivedSatisfied(mock) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Bye World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hello Camel"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testComplexOrCamel() throws Exception { >> MockEndpoint mock = getMockEndpoint("mock:assert"); >> mock.expectedBodiesReceivedInAnyOrder("Hello World", "Bye World", >> "Hi World"); >> >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .from("direct:foo").whenReceivedSatisfied(mock) >> - >> .and().from("direct:bar").whenExactlyDone(5).whenAnyReceivedMatches(body().contains("Camel")) >> - .create(); >> + NotifyBuilder event = event() >> + .from("direct:foo").whenReceivedSatisfied(mock) >> + >> .and().from("direct:bar").whenExactlyDone(5).whenAnyReceivedMatches(body().contains("Camel")) >> + .create(); >> >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Bye World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hello World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> - // the notify is based on direct:foo so sending to bar should not >> trigger match >> + // the event is based on direct:foo so sending to bar should not >> trigger match >> template.sendBody("direct:bar", "Hi World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hi World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "Hi Camel"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:bar", "A"); >> template.sendBody("direct:bar", "B"); >> template.sendBody("direct:bar", "C"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testWhenDoneSatisfied() throws Exception { >> @@ -768,22 +721,22 @@ public class NotifyBuilderTest extends C >> MockEndpoint mock = getMockEndpoint("mock:assert"); >> mock.expectedBodiesReceived("Bye World", "Bye Camel"); >> >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenDoneSatisfied(mock) >> - .create(); >> + NotifyBuilder event = event() >> + .whenDoneSatisfied(mock) >> + .create(); >> >> // is always false to start with >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.requestBody("direct:cake", "World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.requestBody("direct:cake", "Camel"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.requestBody("direct:cake", "Damn"); >> // will still be true as the mock has been completed >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> public void testWhenDoneNotSatisfied() throws Exception { >> @@ -792,64 +745,64 @@ public class NotifyBuilderTest extends C >> MockEndpoint mock = getMockEndpoint("mock:assert"); >> mock.expectedBodiesReceived("Bye World", "Bye Camel"); >> >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenDoneNotSatisfied(mock) >> - .create(); >> + NotifyBuilder event = event() >> + .whenDoneNotSatisfied(mock) >> + .create(); >> >> // is always false to start with >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.requestBody("direct:cake", "World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.requestBody("direct:cake", "Camel"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.requestBody("direct:cake", "Damn"); >> // will still be false as the mock has been completed >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> } >> >> public void testReset() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenExactlyDone(1) >> - .create(); >> + NotifyBuilder event = event() >> + .whenExactlyDone(1) >> + .create(); >> >> template.sendBody("direct:foo", "Hello World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:foo", "Bye World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> // reset >> - notify.reset(); >> - assertEquals(false, notify.matches()); >> + event.reset(); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hello World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> template.sendBody("direct:foo", "Bye World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> } >> >> public void testResetBodiesReceived() throws Exception { >> - NotifyBuilder notify = new NotifyBuilder(context) >> - .whenBodiesReceived("Hello World", "Bye World") >> - .create(); >> + NotifyBuilder event = event() >> + .whenBodiesReceived("Hello World", "Bye World") >> + .create(); >> >> template.sendBody("direct:foo", "Hello World"); >> template.sendBody("direct:foo", "Bye World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> >> // reset >> - notify.reset(); >> - assertEquals(false, notify.matches()); >> + event.reset(); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Hello World"); >> - assertEquals(false, notify.matches()); >> + assertEquals(false, event.matches()); >> >> template.sendBody("direct:foo", "Bye World"); >> - assertEquals(true, notify.matches()); >> + assertEquals(true, event.matches()); >> } >> >> @Override >> >> Modified: >> camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ZipDataFormatFileUnmarshalDeleteTest.java >> URL: >> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ZipDataFormatFileUnmarshalDeleteTest.java?rev=1044052&r1=1044051&r2=1044052&view=diff >> ============================================================================== >> --- >> camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ZipDataFormatFileUnmarshalDeleteTest.java >> (original) >> +++ >> camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ZipDataFormatFileUnmarshalDeleteTest.java >> Thu Dec 9 17:48:31 2010 >> @@ -36,13 +36,13 @@ public class ZipDataFormatFileUnmarshalD >> >> public void testZipFileUnmarshalDelete() throws Exception { >> // there are 2 exchanges >> - NotifyBuilder notify = new >> NotifyBuilder(context).whenDone(2).create(); >> + NotifyBuilder event = event().whenDone(2).create(); >> >> getMockEndpoint("mock:result").expectedBodiesReceived("Hello World"); >> template.sendBodyAndHeader("file:target/zip", "Hello World", >> Exchange.FILE_NAME, "hello.txt"); >> assertMockEndpointsSatisfied(); >> >> - notify.matchesMockWaitTime(); >> + event.matchesMockWaitTime(); >> >> File in = new File("target/zip/hello.txt").getAbsoluteFile(); >> assertFalse("Should have been deleted " + in, in.exists()); >> >> Modified: >> camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java >> URL: >> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java?rev=1044052&r1=1044051&r2=1044052&view=diff >> ============================================================================== >> --- >> camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java >> (original) >> +++ >> camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java >> Thu Dec 9 17:48:31 2010 >> @@ -134,7 +134,7 @@ public class RetryRouteScopedUntilRecipi >> public void testRetryUntilRecipientListFailOnly() throws Exception { >> invoked.set(0); >> >> - NotifyBuilder notify = new >> NotifyBuilder(context).whenDone(1).create(); >> + NotifyBuilder event = event().whenDone(1).create(); >> >> getMockEndpoint("mock:result").expectedMessageCount(0); >> getMockEndpoint("mock:foo").expectedMessageCount(0); >> @@ -144,7 +144,7 @@ public class RetryRouteScopedUntilRecipi >> assertMockEndpointsSatisfied(); >> >> // wait until its done before we stop and check that retry was >> invoked >> - boolean matches = notify.matches(10, TimeUnit.SECONDS); >> + boolean matches = event.matches(10, TimeUnit.SECONDS); >> assertTrue(matches); >> >> context.stop(); >> @@ -155,7 +155,7 @@ public class RetryRouteScopedUntilRecipi >> public void testRetryUntilRecipientListFailAndOk() throws Exception { >> invoked.set(0); >> >> - NotifyBuilder notify = new >> NotifyBuilder(context).whenDone(1).create(); >> + NotifyBuilder event = event().whenDone(1).create(); >> >> getMockEndpoint("mock:result").expectedMessageCount(0); >> getMockEndpoint("mock:foo").expectedMinimumMessageCount(0); >> @@ -165,7 +165,7 @@ public class RetryRouteScopedUntilRecipi >> assertMockEndpointsSatisfied(); >> >> // wait until its done before we stop and check that retry was >> invoked >> - boolean matches = notify.matches(10, TimeUnit.SECONDS); >> + boolean matches = event.matches(10, TimeUnit.SECONDS); >> assertTrue(matches); >> >> context.stop(); >> @@ -176,7 +176,7 @@ public class RetryRouteScopedUntilRecipi >> public void testRetryUntilRecipientListOkAndFail() throws Exception { >> invoked.set(0); >> >> - NotifyBuilder notify = new >> NotifyBuilder(context).whenFailed(1).create(); >> + NotifyBuilder event = event().whenFailed(1).create(); >> >> getMockEndpoint("mock:result").expectedMessageCount(0); >> getMockEndpoint("mock:foo").expectedMessageCount(1); >> @@ -186,7 +186,7 @@ public class RetryRouteScopedUntilRecipi >> assertMockEndpointsSatisfied(); >> >> // wait until its done before we stop and check that retry was >> invoked >> - boolean matches = notify.matches(10, TimeUnit.SECONDS); >> + boolean matches = event.matches(10, TimeUnit.SECONDS); >> assertTrue(matches); >> >> context.stop(); >> @@ -212,7 +212,7 @@ public class RetryRouteScopedUntilRecipi >> public void testRetryUntilRecipientFailAndNotFail() throws Exception { >> invoked.set(0); >> >> - NotifyBuilder notify = new >> NotifyBuilder(context).whenDone(1).create(); >> + NotifyBuilder event = event().whenDone(1).create(); >> >> getMockEndpoint("mock:result").expectedMessageCount(0); >> getMockEndpoint("mock:foo").expectedMinimumMessageCount(0); >> @@ -222,7 +222,7 @@ public class RetryRouteScopedUntilRecipi >> assertMockEndpointsSatisfied(); >> >> // wait until its done before we stop and check that retry was >> invoked >> - boolean matches = notify.matches(10, TimeUnit.SECONDS); >> + boolean matches = event.matches(10, TimeUnit.SECONDS); >> assertTrue(matches); >> >> context.stop(); >> @@ -233,17 +233,16 @@ public class RetryRouteScopedUntilRecipi >> public void testRetryUntilRecipientNotFailAndFail() throws Exception { >> invoked.set(0); >> >> - NotifyBuilder notify = new >> NotifyBuilder(context).whenDone(1).create(); >> + NotifyBuilder event = event().whenDone(1).create(); >> >> getMockEndpoint("mock:result").expectedMessageCount(0); >> getMockEndpoint("mock:foo").expectedMinimumMessageCount(0); >> >> template.sendBodyAndHeader("seda:start", "Hello World", >> "recipientListHeader", "not-fail,fail"); >> - >> assertMockEndpointsSatisfied(); >> >> // wait until its done before we stop and check that retry was >> invoked >> - boolean matches = notify.matches(10, TimeUnit.SECONDS); >> + boolean matches = event.matches(10, TimeUnit.SECONDS); >> assertTrue(matches); >> >> context.stop(); >> >> >> > > > > -- > Claus Ibsen > ----------------- > FuseSource > Email: cib...@fusesource.com > Web: http://fusesource.com > Twitter: davsclaus > Blog: http://davsclaus.blogspot.com/ > Author of Camel in Action: http://www.manning.com/ibsen/