Author: davsclaus
Date: Sat Aug 30 04:03:55 2008
New Revision: 690491
URL: http://svn.apache.org/viewvc?rev=690491&view=rev
Log:
CAMEL-860: improved unit test to verift that original caused exception is on
the exchange that the DLC handles
Modified:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelTest.java
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?rev=690491&r1=690490&r2=690491&view=diff
==============================================================================
---
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 Aug 30 04:03:55 2008
@@ -36,7 +36,6 @@
public void testFirstFewAttemptsFail() throws Exception {
successEndpoint.expectedBodiesReceived(body);
successEndpoint.message(0).header(DeadLetterChannel.REDELIVERED).isEqualTo(true);
- // TODO convert to AND
successEndpoint.message(0).header(DeadLetterChannel.REDELIVERY_COUNTER).isEqualTo(1);
deadEndpoint.expectedMessageCount(0);
@@ -51,13 +50,19 @@
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);
+
deadEndpoint.message(0).header(DeadLetterChannel.REDELIVERY_COUNTER).isEqualTo(2);
successEndpoint.expectedMessageCount(0);
sendBody("direct:start", body);
assertMockEndpointsSatisifed();
+
+ Throwable t =
deadEndpoint.getExchanges().get(0).getProperty(DeadLetterChannel.EXCEPTION_CAUSE_PROPERTY,
Throwable.class);
+ assertNotNull("Should have been a cause property", t);
+ assertTrue(t instanceof RuntimeException);
+ assertEquals("Failed to process due to attempt: 3 being less than: 5",
t.getMessage());
+
+ Throwable t2 = deadEndpoint.getExchanges().get(0).getException();
+ assertEquals(t, t2);
}
@Override
@@ -77,9 +82,7 @@
if (attempt < failUntilAttempt) {
throw new RuntimeException("Failed to process due to
attempt: " + attempt
+ " being less than: " +
failUntilAttempt);
- } else {
- template.send("mock:success", exchange);
- }
+ }
}
};
@@ -90,9 +93,7 @@
.initialRedeliveryDelay(1)
.loggingLevel(LoggingLevel.DEBUG)
- ).process(processor);
- // TODO - currently process().to() results in two separate
operations which have their own error handler
- // to("mock:success");
+ ).process(processor).to("mock:success");
}
};
}