You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/01/14 12:50:45 UTC
svn commit: r899166 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/builder/NotifierBuilder.java
test/java/org/apache/camel/builder/NotifierBuilderTest.java
test/java/org/apache/camel/language/SimpleTest.java
Author: davsclaus
Date: Thu Jan 14 11:50:44 2010
New Revision: 899166
URL: http://svn.apache.org/viewvc?rev=899166&view=rev
Log:
Fixed CS
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NotifierBuilder.java
camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifierBuilderTest.java
camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NotifierBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NotifierBuilder.java?rev=899166&r1=899165&r2=899166&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NotifierBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NotifierBuilder.java Thu Jan 14 11:50:44 2010
@@ -541,7 +541,7 @@
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- for (Iterator<EventPredicateHolder> it = predicates.iterator(); it.hasNext(); ) {
+ for (Iterator<EventPredicateHolder> it = predicates.iterator(); it.hasNext();) {
if (sb.length() > 0) {
sb.append(".");
}
@@ -572,7 +572,7 @@
/**
* Notifier which hooks into Camel to listen for {@link Exchange} relevant events for this builder
*/
- private class ExchangeNotifier extends EventNotifierSupport {
+ private final class ExchangeNotifier extends EventNotifierSupport {
public void notify(EventObject event) throws Exception {
if (event instanceof ExchangeCreatedEvent) {
@@ -721,7 +721,7 @@
/**
* To hold an operation and predicate
*/
- private class EventPredicateHolder {
+ private final class EventPredicateHolder {
private final EventOperation operation;
private final EventPredicate predicate;
@@ -747,7 +747,7 @@
/**
* To hold multiple predicates which are part of same expression
*/
- private class CompoundEventPredicate implements EventPredicate {
+ private final class CompoundEventPredicate implements EventPredicate {
private List<EventPredicate> predicates = new ArrayList<EventPredicate>();
@@ -794,7 +794,7 @@
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- for (Iterator<EventPredicate> it = predicates.iterator(); it.hasNext(); ) {
+ for (Iterator<EventPredicate> it = predicates.iterator(); it.hasNext();) {
if (sb.length() > 0) {
sb.append(".");
}
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifierBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifierBuilderTest.java?rev=899166&r1=899165&r2=899166&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifierBuilderTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/builder/NotifierBuilderTest.java Thu Jan 14 11:50:44 2010
@@ -27,13 +27,13 @@
public class NotifierBuilderTest extends ContextTestSupport {
public void testWhenExchangeDone() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.from("direct:foo").whenDone(5)
.create();
- assertEquals("from(direct:foo).whenDone(5)", notifier .toString());
+ assertEquals("from(direct:foo).whenDone(5)", notifier.toString());
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "A");
template.sendBody("direct:foo", "B");
@@ -42,17 +42,17 @@
template.sendBody("direct:bar", "D");
template.sendBody("direct:bar", "E");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "F");
template.sendBody("direct:bar", "G");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "H");
template.sendBody("direct:bar", "I");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
}
public void testWhenExchangeDoneAnd() throws Exception {
@@ -61,7 +61,7 @@
.and().from("direct:bar").whenDone(7)
.create();
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "A");
template.sendBody("direct:foo", "B");
@@ -70,34 +70,34 @@
template.sendBody("direct:bar", "D");
template.sendBody("direct:bar", "E");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "F");
template.sendBody("direct:bar", "G");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "H");
template.sendBody("direct:bar", "I");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:bar", "J");
template.sendBody("direct:bar", "K");
template.sendBody("direct:bar", "L");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
}
public void testWhenExchangeDoneOr() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(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)", notifier .toString());
+ assertEquals("from(direct:foo).whenDone(5).or().from(direct:bar).whenDone(7)", notifier.toString());
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "A");
template.sendBody("direct:foo", "B");
@@ -106,64 +106,64 @@
template.sendBody("direct:bar", "D");
template.sendBody("direct:bar", "E");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:bar", "G");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:bar", "I");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:bar", "J");
template.sendBody("direct:bar", "K");
template.sendBody("direct:bar", "L");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
}
public void testWhenExchangeDoneNot() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(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)", notifier .toString());
+ assertEquals("from(direct:foo).whenDone(5).not().from(direct:bar).whenDone(1)", notifier.toString());
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "A");
template.sendBody("direct:foo", "B");
template.sendBody("direct:foo", "C");
template.sendBody("direct:foo", "D");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "E");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
template.sendBody("direct:foo", "F");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
template.sendBody("direct:bar", "G");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
}
public void testWhenExchangeDoneOrFailure() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.whenDone(5)
.or().whenFailed(1)
.create();
- assertEquals("whenDone(5).or().whenFailed(1)", notifier .toString());
+ assertEquals("whenDone(5).or().whenFailed(1)", notifier.toString());
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "A");
template.sendBody("direct:foo", "B");
template.sendBody("direct:foo", "D");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
try {
template.sendBody("direct:fail", "E");
@@ -171,16 +171,16 @@
// ignore
}
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
}
public void testWhenExchangeDoneNotFailure() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.whenDone(5)
.not().whenFailed(1)
.create();
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "A");
template.sendBody("direct:foo", "B");
@@ -188,7 +188,7 @@
template.sendBody("direct:bar", "E");
template.sendBody("direct:bar", "F");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
try {
template.sendBody("direct:fail", "G");
@@ -196,15 +196,15 @@
// ignore
}
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
}
public void testWhenExchangeCompleted() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.whenCompleted(5)
.create();
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "A");
template.sendBody("direct:foo", "B");
@@ -223,118 +223,118 @@
}
// should NOT be completed as it only counts successful exchanges
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:bar", "F");
template.sendBody("direct:foo", "G");
template.sendBody("direct:bar", "H");
// now it should match
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
}
public void testWhenExchangeReceivedWithDelay() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.whenReceived(1)
.create();
long start = System.currentTimeMillis();
template.sendBody("seda:cheese", "Hello Cheese");
long end = System.currentTimeMillis();
- assertTrue("Should be faster than: " + (end-start), (end-start) < 1500);
+ assertTrue("Should be faster than: " + (end - start), (end - start) < 1500);
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
// should be quick as its when received and NOT when done
- assertEquals(true, notifier .matches(5, TimeUnit.SECONDS));
+ assertEquals(true, notifier.matches(5, TimeUnit.SECONDS));
long end2 = System.currentTimeMillis();
- assertTrue("Should be faster than: " + (end2-start), (end2-start) < 1500);
+ assertTrue("Should be faster than: " + (end2 - start), (end2 - start) < 1500);
}
public void testWhenExchangeDoneWithDelay() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.whenDone(1)
.create();
long start = System.currentTimeMillis();
template.sendBody("seda:cheese", "Hello Cheese");
long end = System.currentTimeMillis();
- assertTrue("Should be faster than: " + (end-start), (end-start) < 1500);
+ assertTrue("Should be faster than: " + (end - start), (end - start) < 1500);
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
// should NOT be quick as its when DONE
- assertEquals(true, notifier .matches(5, TimeUnit.SECONDS));
+ assertEquals(true, notifier.matches(5, TimeUnit.SECONDS));
long end2 = System.currentTimeMillis();
- assertTrue("Should be slower than: " + (end2-start), (end2-start) > 2900);
+ assertTrue("Should be slower than: " + (end2 - start), (end2 - start) > 2900);
}
public void testWhenExchangeDoneAndTimeoutWithDelay() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.whenDone(1)
.create();
template.sendBody("seda:cheese", "Hello Cheese");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
// should timeout
- assertEquals(false, notifier .matches(1, TimeUnit.SECONDS));
+ assertEquals(false, notifier.matches(1, TimeUnit.SECONDS));
// should NOT timeout
- assertEquals(true, notifier .matches(5, TimeUnit.SECONDS));
+ assertEquals(true, notifier.matches(5, TimeUnit.SECONDS));
}
public void testWhenExchangeExactlyDone() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.whenExactlyDone(5)
.create();
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "A");
template.sendBody("direct:foo", "B");
template.sendBody("direct:foo", "C");
template.sendBody("direct:bar", "D");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:bar", "E");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
template.sendBody("direct:foo", "F");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
}
public void testWhenExchangeExactlyComplete() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.whenExactlyCompleted(5)
.create();
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "A");
template.sendBody("direct:foo", "B");
template.sendBody("direct:foo", "C");
template.sendBody("direct:bar", "D");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:bar", "E");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
template.sendBody("direct:foo", "F");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
}
public void testWhenExchangeExactlyFailed() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.whenExactlyFailed(2)
.create();
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "A");
template.sendBody("direct:foo", "B");
@@ -347,58 +347,58 @@
}
template.sendBody("direct:bar", "E");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
try {
template.sendBody("direct:fail", "F");
} catch (Exception e) {
// ignore
}
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
template.sendBody("direct:bar", "G");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
try {
template.sendBody("direct:fail", "H");
} catch (Exception e) {
// ignore
}
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
}
public void testWhenAnyReceivedMatches() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.whenAnyReceivedMatches(body().contains("Camel"))
.create();
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "Hello World");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "Bye World");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:bar", "Hello Camel");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
}
public void testWhenAllReceivedMatches() throws Exception {
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.whenAllReceivedMatches(body().contains("Camel"))
.create();
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "Hello Camel");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
template.sendBody("direct:foo", "Bye Camel");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
template.sendBody("direct:bar", "Hello World");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
}
public void testWhenSatisfied() throws Exception {
@@ -407,57 +407,57 @@
MockEndpoint mock = getMockEndpoint("mock:assert");
mock.expectedBodiesReceivedInAnyOrder("Hello World", "Bye World", "Hi World");
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.from("direct:foo").whenSatisfied(mock)
.create();
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "Bye World");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "Hello World");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
// the notifier is based on direct:foo so sending to bar should not trigger match
template.sendBody("direct:bar", "Hi World");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "Hi World");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
}
public void testComplexOrCamel() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:assert");
mock.expectedBodiesReceivedInAnyOrder("Hello World", "Bye World", "Hi World");
- NotifierBuilder notifier = new NotifierBuilder(context)
+ NotifierBuilder notifier = new NotifierBuilder(context)
.from("direct:foo").whenSatisfied(mock)
.and().from("direct:bar").whenExactlyDone(5).whenAnyReceivedMatches(body().contains("Camel"))
.create();
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "Bye World");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "Hello World");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
// the notifier is based on direct:foo so sending to bar should not trigger match
template.sendBody("direct:bar", "Hi World");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:foo", "Hi World");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:bar", "Hi Camel");
- assertEquals(false, notifier .matches());
+ assertEquals(false, notifier.matches());
template.sendBody("direct:bar", "A");
template.sendBody("direct:bar", "B");
template.sendBody("direct:bar", "C");
- assertEquals(true, notifier .matches());
+ assertEquals(true, notifier.matches());
}
@Override
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java?rev=899166&r1=899165&r2=899166&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleTest.java Thu Jan 14 11:50:44 2010
@@ -76,7 +76,7 @@
public void testDateAndTimeExpressions() throws Exception {
Calendar cal = GregorianCalendar.getInstance();
- cal.set(1974, Calendar.APRIL, 20, 8,55, 47);
+ cal.set(1974, Calendar.APRIL, 20, 8, 55, 47);
cal.set(Calendar.MILLISECOND, 123);
exchange.getIn().setHeader("birthday", cal.getTime());