camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1409424 - in /camel/trunk: camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryFilterTest.java tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java
Date Wed, 14 Nov 2012 21:33:25 GMT
Author: davsclaus
Date: Wed Nov 14 21:33:24 2012
New Revision: 1409424

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

Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryFilterTest.java
    camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryFilterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryFilterTest.java?rev=1409424&r1=1409423&r2=1409424&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryFilterTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryFilterTest.java
Wed Nov 14 21:33:24 2012
@@ -19,6 +19,8 @@ package org.apache.camel.component.file;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
@@ -32,7 +34,7 @@ import org.apache.camel.impl.JndiRegistr
 public class FileConsumerDirectoryFilterTest extends ContextTestSupport {
 
     private final String fileUrl = "file://target/directoryfilter/?recursive=true&filter=#myFilter";
-    private final List<String> names = new ArrayList<String>();
+    private final Set<String> names = new TreeSet<String>();
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -65,12 +67,15 @@ public class FileConsumerDirectoryFilter
 
         // check names
         assertEquals(4, names.size());
-        Collections.sort(names);
-        assertEquals("okDir", names.get(0));
+        // copy to list so its easier to index
+        List<String> list = new ArrayList<String>(names);
+        Collections.sort(list);
+
+        assertEquals("okDir", list.get(0));
         // windows or unix paths
-        assertTrue(names.get(0), names.get(1).equals("okDir/hello.txt") || names.get(1).equals("okDir\\hello.txt"));
-        assertEquals("skipDir", names.get(2));
-        assertEquals("skipDir2", names.get(3));
+        assertTrue(list.get(0), list.get(1).equals("okDir/hello.txt") || list.get(1).equals("okDir\\hello.txt"));
+        assertEquals("skipDir", list.get(2));
+        assertEquals("skipDir2", list.get(3));
     }
 
     protected RouteBuilder createRouteBuilder() throws Exception {

Modified: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java?rev=1409424&r1=1409423&r2=1409424&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java
(original)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java
Wed Nov 14 21:33:24 2012
@@ -18,6 +18,8 @@ package org.apache.camel.itest.async;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
@@ -30,6 +32,8 @@ import org.junit.Test;
  */
 public class HttpAsyncCallbackTest extends HttpAsyncTestSupport {
 
+    private static final CountDownLatch LATCH = new CountDownLatch(3);
+
     @Test
     public void testAsyncAndSyncAtSameTimeWithHttp() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
@@ -46,13 +50,11 @@ public class HttpAsyncCallbackTest exten
         template.asyncCallbackRequestBody(url, "Hadrian", callback);
         template.asyncCallbackRequestBody(url, "Willem", callback);
 
-        // give on completion time to complete properly before we do assertions on its size
-        // TODO: improve MockEndpoint.assertIsSatisfied(long) to make this sleep unnecessary
-        Thread.sleep(3000);
-
         // END SNIPPET: e3
         assertMockEndpointsSatisfied();
 
+        assertTrue("Should get 3 callbacks", LATCH.await(10, TimeUnit.SECONDS));
+
         // assert that we got all the correct data in our callback
         assertEquals(3, callback.getData().size());
         assertTrue("Claus is missing", callback.getData().contains("Hello Claus"));
@@ -74,6 +76,8 @@ public class HttpAsyncCallbackTest exten
             // this method is invoked when the exchange was a success and we can get the
response
             String body = exchange.getOut().getBody(String.class);
             data.add(body);
+
+            LATCH.countDown();
         }
 
         public List<String> getData() {



Mime
View raw message