activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r530995 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/component/mock/MockEndpoint.java main/java/org/apache/camel/processor/DeadLetterChannel.java test/java/org/apache/camel/processor/DeadLetterChannelTest.java
Date Sat, 21 Apr 2007 08:32:03 GMT
Author: jstrachan
Date: Sat Apr 21 01:32:02 2007
New Revision: 530995

URL: http://svn.apache.org/viewvc?view=rev&rev=530995
Log:
added some more expectations to the tests

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java?view=diff&rev=530995&r1=530994&r2=530995
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
Sat Apr 21 01:32:02 2007
@@ -46,7 +46,7 @@
     private static final transient Log log = LogFactory.getLog(MockEndpoint.class);
     private int expectedCount = -1;
     private Map<Integer, Processor<Exchange>> processors = new HashMap<Integer,
Processor<Exchange>>();
-    private List<Exchange> exchangesReceived = new ArrayList<Exchange>();
+    private List<Exchange> receivedExchanges = new ArrayList<Exchange>();
     private List<Throwable> failures = new ArrayList<Throwable>();
     private List<Runnable> tests = new ArrayList<Runnable>();
     private CountDownLatch latch;
@@ -168,7 +168,7 @@
             public void run() {
                 int counter = 0;
                 for (Object expectedBody : bodies) {
-                    Exchange exchange = getExchangesReceived().get(counter++);
+                    Exchange exchange = getReceivedExchanges().get(counter++);
                     assertTrue("No exchange received for counter: " + counter, exchange !=
null);
 
                     Object actualBody = exchange.getIn().getBody();
@@ -224,7 +224,7 @@
     public AssertionClause allMessages() {
         AssertionClause clause = new AssertionClause() {
             public void run() {
-                List<Exchange> list = getExchangesReceived();
+                List<Exchange> list = getReceivedExchanges();
                 int index = 0;
                 for (Exchange exchange : list) {
                     applyAssertionOn(MockEndpoint.this, index++, exchange);
@@ -241,7 +241,7 @@
     public Exchange assertExchangeReceived(int index) {
         int count = getReceivedCounter();
         assertTrue("Not enough messages received. Was: " + count, count > index);
-        return getExchangesReceived().get(index);
+        return getReceivedExchanges().get(index);
     }
 
     // Properties
@@ -251,11 +251,11 @@
     }
 
     public int getReceivedCounter() {
-        return getExchangesReceived().size();
+        return getReceivedExchanges().size();
     }
 
-    public List<Exchange> getExchangesReceived() {
-        return exchangesReceived;
+    public List<Exchange> getReceivedExchanges() {
+        return receivedExchanges;
     }
 
     public int getExpectedCount() {
@@ -282,7 +282,7 @@
         try {
             log.debug(getEndpointUri() + " >>>> " + exchange);
 
-            exchangesReceived.add(exchange);
+            receivedExchanges.add(exchange);
 
             Processor<Exchange> processor = processors.get(getReceivedCounter());
             if (processor != null) {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java?view=diff&rev=530995&r1=530994&r2=530995
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
Sat Apr 21 01:32:02 2007
@@ -19,6 +19,7 @@
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
+import org.apache.camel.Message;
 import org.apache.camel.impl.ServiceSupport;
 import org.apache.camel.util.ServiceHelper;
 import org.apache.commons.logging.Log;
@@ -117,15 +118,14 @@
      * Increments the redelivery counter and adds the redelivered flag if the message has
been redelivered
      */
     protected int incrementRedeliveryCounter(E exchange) {
-        Integer counter = exchange.getProperty(REDELIVERY_COUNTER, Integer.class);
+        Message in = exchange.getIn();
+        Integer counter = in.getHeader(REDELIVERY_COUNTER, Integer.class);
         int next = 1;
         if (counter != null) {
             next = counter + 1;
         }
-        exchange.setProperty(REDELIVERY_COUNTER, next);
-        if (next > 1) {
-            exchange.setProperty(REDELIVERED, true);
-        }
+        in.setHeader(REDELIVERY_COUNTER, next);
+            in.setHeader(REDELIVERED, true);
         return next;
     }
 

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelTest.java?view=diff&rev=530995&r1=530994&r2=530995
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelTest.java
Sat Apr 21 01:32:02 2007
@@ -36,8 +36,10 @@
 
     public void testFirstFewAttemptsFail() throws Exception {
         successEndpoint.expectedBodiesReceived(body);
-        //successEndpoint.message(0).header(DeadLetterChannel.REDELIVERED).isEqualTo(true);
-        
+        successEndpoint.message(0).header(DeadLetterChannel.REDELIVERED).isEqualTo(true);
+        // TODO convert to AND
+        successEndpoint.message(0).header(DeadLetterChannel.REDELIVERY_COUNTER).isEqualTo(1);
+
         deadEndpoint.expectedMessageCount(0);
 
         send("direct:start", body);
@@ -49,6 +51,9 @@
         failUntilAttempt = 5;
 
         deadEndpoint.expectedBodiesReceived(body);
+        deadEndpoint.message(0).header(DeadLetterChannel.REDELIVERED).isEqualTo(true);
+        // TODO convert to AND
+        deadEndpoint.message(0).header(DeadLetterChannel.REDELIVERY_COUNTER).isEqualTo(2);
         successEndpoint.expectedMessageCount(0);
 
         send("direct:start", body);
@@ -67,7 +72,7 @@
     protected RouteBuilder createRouteBuilder() {
         final Processor<Exchange> processor = new Processor<Exchange>() {
             public void process(Exchange exchange) {
-                Integer counter = exchange.getProperty(DeadLetterChannel.REDELIVERY_COUNTER,
Integer.class);
+                Integer counter = exchange.getIn().getHeader(DeadLetterChannel.REDELIVERY_COUNTER,
Integer.class);
                 int attempt = (counter == null) ? 1 : counter + 1;
                 if (attempt < failUntilAttempt) {
                     throw new RuntimeException("Failed to process due to attempt: " + attempt
+ " being less than: " + failUntilAttempt);



Mime
View raw message