camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1024123 - in /camel/trunk: camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteAllTasksTest.java components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTest.xml
Date Tue, 19 Oct 2010 05:52:39 GMT
Author: davsclaus
Date: Tue Oct 19 05:52:38 2010
New Revision: 1024123

URL: http://svn.apache.org/viewvc?rev=1024123&view=rev
Log:
Fixed test

Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteAllTasksTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTest.xml

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteAllTasksTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteAllTasksTest.java?rev=1024123&r1=1024122&r2=1024123&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteAllTasksTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteAllTasksTest.java
Tue Oct 19 05:52:38 2010
@@ -17,9 +17,11 @@
 package org.apache.camel.processor;
 
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
 import org.apache.camel.ShutdownRunningTask;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -30,11 +32,12 @@ import org.apache.camel.component.mock.M
 public class ShutdownCompleteAllTasksTest extends ContextTestSupport {
 
     private static String url = "file:target/pending";
+    private static AtomicInteger counter = new AtomicInteger();
 
     @Override
     protected void setUp() throws Exception {
-        super.setUp();
         deleteDirectory("target/pending");
+        super.setUp();
 
         template.sendBodyAndHeader(url, "A", Exchange.FILE_NAME, "a.txt");
         template.sendBodyAndHeader(url, "B", Exchange.FILE_NAME, "b.txt");
@@ -53,7 +56,7 @@ public class ShutdownCompleteAllTasksTes
         MockEndpoint bar = getMockEndpoint("mock:bar");
         bar.expectedMinimumMessageCount(1);
 
-        // wait 20 seconds to give more time for slowe servers
+        // wait 20 seconds to give more time for slow servers
         bar.await(20, TimeUnit.SECONDS);
 
         int batch = bar.getReceivedExchanges().get(0).getProperty(Exchange.BATCH_SIZE, int.class);
@@ -61,8 +64,8 @@ public class ShutdownCompleteAllTasksTes
         // shutdown during processing
         context.stop();
 
-        // should route all 5
-        assertEquals("Should complete all messages", batch, bar.getReceivedCounter());
+        // should route all
+        assertEquals("Should complete all messages", batch, counter.get());
     }
 
     @Override
@@ -74,12 +77,19 @@ public class ShutdownCompleteAllTasksTes
                 from(url).routeId("foo").noAutoStartup()
                     // let it complete all tasks during shutdown
                     .shutdownRunningTask(ShutdownRunningTask.CompleteAllTasks)
-                    .delay(1000).to("seda:foo");
-
-                from("seda:foo").to("mock:bar");
+                    .delay(1000)
+                    .process(new MyProcessor())
+                    .to("mock:bar");
             }
             // END SNIPPET: e1
         };
     }
 
+    public static class MyProcessor implements Processor {
+
+        public void process(Exchange exchange) throws Exception {
+            counter.incrementAndGet();
+        }
+    }
+
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTest.xml?rev=1024123&r1=1024122&r2=1024123&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTest.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTest.xml
Tue Oct 19 05:52:38 2010
@@ -22,6 +22,8 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
+    <bean id="myProcessor" class="org.apache.camel.processor.ShutdownCompleteAllTasksTest$MyProcessor"/>
+
     <bean id="shutdown" class="org.apache.camel.impl.DefaultShutdownStrategy">
         <!-- give it 30 sec to shutdown -->
         <property name="timeout" value="30"/>
@@ -30,16 +32,13 @@
     <!-- START SNIPPET: e1 -->
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         <!-- let this route complete all its pending messages when asked to shutdown -->
-        <route id="foo" autoStartup="false" startupOrder="1" shutdownRunningTask="CompleteAllTasks">
+        <route id="foo" autoStartup="false" shutdownRunningTask="CompleteAllTasks">
             <from uri="file:target/pending"/>
             <delay><constant>1000</constant></delay>
-            <to uri="seda:foo"/>
-        </route>
-
-        <route startupOrder="2">
-            <from uri="seda:foo"/>
+            <process ref="myProcessor"/>
             <to uri="mock:bar"/>
         </route>
+
     </camelContext>
     <!-- END SNIPPET: e1 -->
 



Mime
View raw message