Fixed test
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bae0c7e1 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bae0c7e1 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bae0c7e1 Branch: refs/heads/camel-2.11.x Commit: bae0c7e1ff7a4589b08f602891bb6944d2142581 Parents: ae23e20 Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Sep 10 12:08:50 2013 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Sep 10 12:09:17 2013 +0200 ---------------------------------------------------------------------- .../dataformat/zipfile/ZipFileDataFormatTest.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/bae0c7e1/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java ---------------------------------------------------------------------- diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java index b16daeb..889e480 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java @@ -21,10 +21,12 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.util.concurrent.TimeUnit; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import org.apache.camel.Exchange; +import org.apache.camel.builder.NotifyBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelTestSupport; @@ -102,6 +104,8 @@ public class ZipFileDataFormatTest extends CamelTestSupport { @Test public void testZipToFileWithoutFileName() throws Exception { + NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create(); + String[] files = TEST_DIR.list(); assertTrue(files == null || files.length == 0); @@ -112,6 +116,9 @@ public class ZipFileDataFormatTest extends CamelTestSupport { assertMockEndpointsSatisfied(); + // use builder to ensure the exchange is fully done before we check for file exists + assertTrue(notify.matches(5, TimeUnit.SECONDS)); + Exchange exchange = mock.getReceivedExchanges().get(0); File file = new File(TEST_DIR, exchange.getIn().getMessageId() + ".zip"); assertTrue(file.exists()); @@ -120,6 +127,8 @@ public class ZipFileDataFormatTest extends CamelTestSupport { @Test public void testZipToFileWithFileName() throws Exception { + NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create(); + MockEndpoint mock = getMockEndpoint("mock:zipToFile"); mock.expectedMessageCount(1); @@ -130,7 +139,10 @@ public class ZipFileDataFormatTest extends CamelTestSupport { // just make sure the file is created mock.assertIsSatisfied(); - + + // use builder to ensure the exchange is fully done before we check for file exists + assertTrue(notify.matches(5, TimeUnit.SECONDS)); + assertTrue(file.exists()); assertTrue(ObjectHelper.equalByteArray(getZippedText("poem.txt"), getBytes(file))); }