Author: davsclaus
Date: Wed Oct 8 11:53:14 2008
New Revision: 702966
URL: http://svn.apache.org/viewvc?rev=702966&view=rev
Log:
CAMEL-951: Builder must be public to let the fluent builder works.
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/DefaultAggregationCollection.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/DefaultAggregatorCollectionTest.java
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java?rev=702966&r1=702965&r2=702966&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
Wed Oct 8 11:53:14 2008
@@ -27,6 +27,7 @@
import org.apache.camel.builder.ValueBuilder;
import static org.apache.camel.builder.ExpressionBuilder.bodyExpression;
import static org.apache.camel.builder.ExpressionBuilder.headerExpression;
+import static org.apache.camel.builder.ExpressionBuilder.propertyExpression;
/**
* A builder of assertions on message exchanges
@@ -63,6 +64,14 @@
}
/**
+ * Returns a predicate and value builder for property on an exchange
+ */
+ public ValueBuilder<Exchange> property(String name) {
+ Expression<Exchange> expression = propertyExpression(name);
+ return new PredicateValueBuilder(expression);
+ }
+
+ /**
* Returns a predicate and value builder for the inbound body on an
exchange
*/
public PredicateValueBuilder body() {
@@ -111,7 +120,9 @@
}
-
+ /**
+ * Public class needed for fluent builders
+ */
public class PredicateValueBuilder extends ValueBuilder<Exchange> {
public PredicateValueBuilder(Expression<Exchange> expression) {
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java?rev=702966&r1=702965&r2=702966&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
Wed Oct 8 11:53:14 2008
@@ -157,10 +157,11 @@
validateExchangePropertyIsExpectedType(property, type, value);
}
if (value != null) {
- // avoid the NULLPointException
+ // avoid the NullPointException
getProperties().put(name, value);
- } else { // if the value is null , we just remove the key from the map
- if (name != null) {
+ } else {
+ // if the value is null , we just remove the key from the map
+ if (name != null) {
getProperties().remove(name);
}
}
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/DefaultAggregationCollection.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/DefaultAggregationCollection.java?rev=702966&r1=702965&r2=702966&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/DefaultAggregationCollection.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/DefaultAggregationCollection.java
Wed Oct 8 11:53:14 2008
@@ -58,6 +58,7 @@
Object correlationKey = correlationExpression.evaluate(exchange);
Exchange oldExchange = map.get(correlationKey);
Exchange newExchange = exchange;
+
if (oldExchange != null) {
Integer count = oldExchange.getProperty(Exchange.AGGREGATED_COUNT,
Integer.class);
if (count == null) {
@@ -70,13 +71,17 @@
// the strategy may just update the old exchange and return it
if (newExchange != oldExchange) {
- LOG.debug("put exchange:" + newExchange + " for key:" +
correlationKey);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("put exchange:" + newExchange + " for key:" +
correlationKey);
+ }
if (oldExchange == null) {
- newExchange.setProperty(Exchange.AGGREGATED_COUNT, new
Integer(1));
+ newExchange.setProperty(Exchange.AGGREGATED_COUNT,
Integer.valueOf(1));
}
map.put(correlationKey, newExchange);
}
+
onAggregation(correlationKey, newExchange);
+
return true;
}
Modified:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/DefaultAggregatorCollectionTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/DefaultAggregatorCollectionTest.java?rev=702966&r1=702965&r2=702966&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/DefaultAggregatorCollectionTest.java
(original)
+++
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/DefaultAggregatorCollectionTest.java
Wed Oct 8 11:53:14 2008
@@ -17,6 +17,7 @@
package org.apache.camel.processor.aggregator;
import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -32,6 +33,10 @@
// we expect 4 messages grouped by the latest message only
result.expectedMessageCount(4);
result.expectedBodiesReceived("Message 1d", "Message 2b", "Message
3c", "Message 4");
+ result.message(0).property(Exchange.AGGREGATED_COUNT).isEqualTo(4);
+ result.message(1).property(Exchange.AGGREGATED_COUNT).isEqualTo(2);
+ result.message(2).property(Exchange.AGGREGATED_COUNT).isEqualTo(3);
+ result.message(3).property(Exchange.AGGREGATED_COUNT).isEqualTo(1);
// then we sent all the message at once
template.sendBodyAndHeader("direct:start", "Message 1a", "id", "1");