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 2009/04/21 10:39:55 UTC

svn commit: r767070 - /camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelRedeliverWithDelayNotBlockingTest.java

Author: davsclaus
Date: Tue Apr 21 08:39:55 2009
New Revision: 767070

URL: http://svn.apache.org/viewvc?rev=767070&view=rev
Log:
Unit test for helping with internal API rework for better redelivery with timer

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelRedeliverWithDelayNotBlockingTest.java   (with props)

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelRedeliverWithDelayNotBlockingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelRedeliverWithDelayNotBlockingTest.java?rev=767070&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelRedeliverWithDelayNotBlockingTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelRedeliverWithDelayNotBlockingTest.java Tue Apr 21 08:39:55 2009
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Processor;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * Unit test to verify that using DLC with redelivery and delays that we are not blocking
+ * the caller thread, for instance if we have delays in miniutes.
+ *
+ * @version $Revision$
+ */
+public class DeadLetterChannelRedeliverWithDelayNotBlockingTest extends ContextTestSupport {
+
+    private static int counter;
+
+    public void testRedeliverWithDelay() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        // TODO: when we get the internal API reworked we should be able to receive in this order
+        // mock.expectedBodiesReceived("Message 2", "Message 1");
+
+        mock.expectedBodiesReceived("Message 1", "Message 2");
+        mock.expectedHeaderReceived("foo", "bar");
+
+        template.sendBody("seda:start", "Message 1");
+        template.sendBody("seda:start", "Message 2");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead").delay(1000).maximumRedeliveries(3).logStackTrace(false));
+
+                from("seda:start")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                String body = exchange.getIn().getBody(String.class);
+                                if ("Message 1".equals(body) && counter++ < 2) {
+                                    throw new IllegalArgumentException("Damn");
+                                }
+                                exchange.getIn().setHeader("foo", "bar");
+                            }
+                        }).to("mock:result");
+            }
+        };
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelRedeliverWithDelayNotBlockingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelRedeliverWithDelayNotBlockingTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date