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 2012/11/14 22:36:04 UTC
svn commit: r1409429 - in /camel/branches/camel-2.10.x: ./
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
Author: davsclaus
Date: Wed Nov 14 21:36:04 2012
New Revision: 1409429
URL: http://svn.apache.org/viewvc?rev=1409429&view=rev
Log:
Fixed tests
Modified:
camel/branches/camel-2.10.x/ (props changed)
camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryFilterTest.java
camel/branches/camel-2.10.x/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java
Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Merged /camel/trunk:r1409424
Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryFilterTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryFilterTest.java?rev=1409429&r1=1409428&r2=1409429&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryFilterTest.java (original)
+++ camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryFilterTest.java Wed Nov 14 21:36:04 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/branches/camel-2.10.x/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java?rev=1409429&r1=1409428&r2=1409429&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java (original)
+++ camel/branches/camel-2.10.x/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java Wed Nov 14 21:36:04 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(2200);
-
// 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() {