camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r722828 - /activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/
Date Wed, 03 Dec 2008 10:04:17 GMT
Author: davsclaus
Date: Wed Dec  3 02:04:11 2008
New Revision: 722828

URL: http://svn.apache.org/viewvc?rev=722828&view=rev
Log:
CAMEL-966: Getting rid of some sleeps to speed up testing

Modified:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/BeanToFileTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAsyncRouteTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExpressionTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentRefTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileExchangeTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileMEPInOutTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProduceAppendTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProduceTempPrefixTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProducerExpressionTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameStrategyTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/MoveFilesToDirectoryTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/ToFileRouteTest.java

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/BeanToFileTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/BeanToFileTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/BeanToFileTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/BeanToFileTest.java
Wed Dec  3 02:04:11 2008
@@ -17,11 +17,11 @@
 package org.apache.camel.component.file;
 
 import java.io.File;
-
 import javax.naming.Context;
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.IOConverter;
 import org.apache.camel.util.jndi.JndiContext;
 
@@ -31,10 +31,12 @@
 public class BeanToFileTest extends ContextTestSupport {
 
     public void testBeanToFile() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+
         template.sendBody("direct:in", "World");
 
-        // give Camel time to create the file
-        Thread.sleep(1000);
+        assertMockEndpointsSatisfied();
 
         File file = new File("target/BeanToFileTest.txt");
         file = file.getAbsoluteFile();
@@ -53,7 +55,7 @@
                 from("direct:in").
                     to("bean:myBean").
                     setHeader(FileComponent.HEADER_FILE_NAME, constant("BeanToFileTest.txt")).
-                    to("file://target/?append=false");
+                    to("file://target/?append=false", "mock:result");
             }
         };
     }

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java
Wed Dec  3 02:04:11 2008
@@ -18,63 +18,51 @@
 
 import java.io.File;
 
-import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.TestSupport;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.component.mock.MockEndpoint;
 
 /**
- * @author Albert Moraal
  * @version $Revision$
  */
-public class DirectoryCreateIssueTest extends TestSupport {
-    private CamelContext context;
-    private ProducerTemplate template;
+public class DirectoryCreateIssueTest extends ContextTestSupport {
+
+    private final int numFiles = 10;
+    private final String path = "target/a/b/c/d/e/f/g/h";
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        context = new DefaultCamelContext();
-        context.start();
-        template = context.createProducerTemplate();
+        deleteDirectory("target/a");
     }
 
     @Override
-    protected void tearDown() throws Exception {
-        context.stop();
-        super.tearDown();
-    }
-
-    public void testFileCreatedAsDir() throws Exception {
-        log.debug("testFileCreatedAsDir");
-        final String path = "target/a/b/c/d/e/f/g/h";
-        final int numFiles = 10;
-
-        context.addRoutes(
-            new RouteBuilder() {
-                @Override
-                public void configure() {
-                    String[] destinations = new String[numFiles];
-                    for (int i = 0; i < numFiles; i++) {
-                        destinations[i] = "seda:file" + i;
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                String[] destinations = new String[numFiles];
+                for (int i = 0; i < numFiles; i++) {
+                    destinations[i] = "seda:file" + i;
 
-                        from("seda:file" + i)
+                    from("seda:file" + i)
                             .setHeader(FileComponent.HEADER_FILE_NAME,
-                                constant("file" + i + ".txt"))
-                            .to("file://" + path + "/?append=false&noop=true");
-                    }
+                                    constant("file" + i + ".txt"))
+                            .to("file://" + path + "/?append=false&noop=true", "mock:result");
+                }
 
-                    from("seda:testFileCreatedAsDir")
+                from("seda:testFileCreatedAsDir")
                         .to(destinations);
-                }
             }
-        );
+        };
+    }
 
-        deleteDirectory(new File("a"));
+    public void testFileCreatedAsDir() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(numFiles);
 
         template.send("seda:testFileCreatedAsDir", new Processor() {
             public void process(Exchange exchange) {
@@ -83,8 +71,7 @@
             }
         });
 
-        // must sleep for some time to make sure runs on all platforms
-        Thread.sleep(8 * 1000);
+        assertMockEndpointsSatisfied();
 
         for (int i = 0; i < numFiles; i++) {
             assertTrue((new File(path + "/file" + i + ".txt")).isFile());

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAsyncRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAsyncRouteTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAsyncRouteTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAsyncRouteTest.java
Wed Dec  3 02:04:11 2008
@@ -70,7 +70,7 @@
         // Release the async processing thread so that the exchange completes
         // and the file gets deleted.
         processingLatch.countDown();
-        Thread.sleep(500);
+        Thread.sleep(100);
         assertFalse("File should not exist", file.getAbsoluteFile().exists());
 
         result.assertIsSatisfied();

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
Wed Dec  3 02:04:11 2008
@@ -54,7 +54,7 @@
         FileConsumer consumer = createFileConsumer("file://target/foo/bar?consumer.recursive=true");
         assertEquals("The recurisive should be true", consumer.isRecursive(), true);
         try {
-            consumer = createFileConsumer("file://target/foo/bar?consumer.recursiv=true");
+            createFileConsumer("file://target/foo/bar?consumer.recursiv=true");
             fail("Expect a configure exception here");
         } catch (Exception ex) {
             assertTrue("Get the wrong exception type here", ex instanceof ResolveEndpointFailedException);

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExpressionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExpressionTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExpressionTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExpressionTest.java
Wed Dec  3 02:04:11 2008
@@ -50,7 +50,7 @@
         assertMockEndpointsSatisfied();
 
         // give time for consumer to rename file
-        Thread.sleep(1000);
+        Thread.sleep(100);
 
         String id = mock.getExchanges().get(0).getIn().getMessageId();
         File file = new File("target/filelanguage/" + id + ".bak");
@@ -66,7 +66,7 @@
         assertMockEndpointsSatisfied();
 
         // give time for consumer to rename file
-        Thread.sleep(1000);
+        Thread.sleep(100);
 
         String id = mock.getExchanges().get(0).getIn().getMessageId();
         File file = new File("target/filelanguage/backup-" + id + "-report2.bak");
@@ -82,7 +82,7 @@
         assertMockEndpointsSatisfied();
 
         // give time for consumer to rename file
-        Thread.sleep(1000);
+        Thread.sleep(100);
 
         File file = new File("target/filelanguage/backup/123.txt");
         file = file.getAbsoluteFile();
@@ -97,7 +97,7 @@
         assertMockEndpointsSatisfied();
 
         // give time for consumer to rename file
-        Thread.sleep(1000);
+        Thread.sleep(100);
 
         File file = new File("target/backup/report4.txt.bak");
         file = file.getAbsoluteFile();
@@ -113,7 +113,7 @@
         assertMockEndpointsSatisfied();
 
         // give time for consumer to rename file
-        Thread.sleep(1000);
+        Thread.sleep(100);
 
         File file = new File("target/filelanguage/123");
         file = file.getAbsoluteFile();

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFailureHandledTest.java
Wed Dec  3 02:04:11 2008
@@ -48,7 +48,7 @@
         mock.assertIsSatisfied();
 
         // sleep otherwise the file assertions below could fail
-        Thread.sleep(500);
+        Thread.sleep(100);
 
         asserFiles("paris.txt");
     }
@@ -64,7 +64,7 @@
         mock.assertIsSatisfied();
 
         // sleep otherwise the file assertions below could fail
-        Thread.sleep(500);
+        Thread.sleep(100);
 
         asserFiles("london.txt");
     }
@@ -80,7 +80,7 @@
         mock.assertIsSatisfied();
 
         // sleep otherwise the file assertions below could fail
-        Thread.sleep(500);
+        Thread.sleep(100);
 
         asserFiles("madrid.txt");
     }

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentRefTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentRefTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentRefTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentRefTest.java
Wed Dec  3 02:04:11 2008
@@ -62,7 +62,7 @@
 
         assertMockEndpointsSatisfied();
 
-        Thread.sleep(1000);
+        Thread.sleep(100);
 
         // reset mock and set new expectations
         mock.reset();

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentTest.java
Wed Dec  3 02:04:11 2008
@@ -51,7 +51,7 @@
 
         assertMockEndpointsSatisfied();
 
-        Thread.sleep(1000);
+        Thread.sleep(100);
 
         // reset mock and set new expectations
         mock.reset();

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileExchangeTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileExchangeTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileExchangeTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileExchangeTest.java
Wed Dec  3 02:04:11 2008
@@ -69,7 +69,6 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-
         file = new File(FileExchangeTest.class.getResource("FileExchangeTest.class").getFile());
     }
 }
\ No newline at end of file

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileMEPInOutTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileMEPInOutTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileMEPInOutTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileMEPInOutTest.java
Wed Dec  3 02:04:11 2008
@@ -37,14 +37,11 @@
         template.requestBodyAndHeader("direct:in", "Hello World", FileComponent.HEADER_FILE_NAME,
             "FileMEPInOutTest.txt");
 
-        // give Camel time to create the file
-        Thread.sleep(1000);
+        assertMockEndpointsSatisfied();
 
         File file = new File("target/FileMEPInOutTest.txt");
         file = file.getAbsoluteFile();
         assertEquals("Hello World", IOConverter.toString(file));
-
-        mock.assertIsSatisfied();
     }
 
     protected RouteBuilder createRouteBuilder() throws Exception {

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProduceAppendTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProduceAppendTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProduceAppendTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProduceAppendTest.java
Wed Dec  3 02:04:11 2008
@@ -20,6 +20,7 @@
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.IOConverter;
 
 /**
@@ -28,22 +29,26 @@
 public class FileProduceAppendTest extends ContextTestSupport {
 
     public void testAppendText() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+
         template.sendBody("direct:start", " World");
 
-        // give time to write to file
-        Thread.sleep(1000);
+        assertMockEndpointsSatisfied();
 
         String body = IOConverter.toString(new File("target/test-file-append/hello.txt").getAbsoluteFile());
         assertEquals("Hello World", body);
     }
 
     public void testAppendFile() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+
         // create a file with some content we want to append to the existing file
         File in = new File("target/test-file-append/world.txt").getAbsoluteFile();
         template.sendBody("direct:start", in);
 
-        // give time to write to file
-        Thread.sleep(1000);
+        assertMockEndpointsSatisfied();
 
         String body = IOConverter.toString(new File("target/test-file-append/hello.txt").getAbsoluteFile());
         assertEquals("Hello World", body);
@@ -55,8 +60,6 @@
         deleteDirectory("target/test-file-append");
         template.sendBodyAndHeader("file://target/test-file-append", "Hello", FileComponent.HEADER_FILE_NAME,
"hello.txt");
         template.sendBodyAndHeader("file://target/test-file-append", " World", FileComponent.HEADER_FILE_NAME,
"world.txt");
-        // give time to write files
-        Thread.sleep(1000);
     }
 
     @Override
@@ -65,7 +68,7 @@
             public void configure() {
                 from("direct:start")
                     .setHeader(FileComponent.HEADER_FILE_NAME, constant("hello.txt"))
-                    .to("file://target/test-file-append?append=true");
+                    .to("file://target/test-file-append?append=true", "mock:result");
             }
         };
     }

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProduceTempPrefixTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProduceTempPrefixTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProduceTempPrefixTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProduceTempPrefixTest.java
Wed Dec  3 02:04:11 2008
@@ -52,8 +52,6 @@
 
         template.sendBodyAndHeader("direct:a", "Hello World", FileComponent.HEADER_FILE_NAME,
"hello.txt");
 
-        Thread.sleep(250);
-
         File file = new File("target/tempandrename/hello.txt");
         // use absolute file to let unittest pass on all platforms
         file = file.getAbsoluteFile();

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProducerExpressionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProducerExpressionTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProducerExpressionTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProducerExpressionTest.java
Wed Dec  3 02:04:11 2008
@@ -47,14 +47,12 @@
         template.sendBodyAndHeader("file://target/filelanguage", "Hello World",
             FileComponent.HEADER_FILE_NAME, "${bean:myguidgenerator}.bak");
 
-        Thread.sleep(500);
         assertFileExists("target/filelanguage/123.bak");
     }
 
     public void testProduceBeanByExpression() throws Exception {
         template.sendBody("file://target/filelanguage?expression=${bean:myguidgenerator}.bak",
"Hello World");
 
-        Thread.sleep(500);
         assertFileExists("target/filelanguage/123.bak");
     }
 
@@ -62,7 +60,6 @@
         template.sendBodyAndHeader("file://target/filelanguage", "Hello World",
             FileComponent.HEADER_FILE_NAME, "myfile-${date:now:yyyyMMdd}.txt");
 
-        Thread.sleep(500);
         String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
         assertFileExists("target/filelanguage/myfile-" + date + ".txt");
     }
@@ -70,7 +67,6 @@
     public void testProducerDateByExpression() throws Exception {
         template.sendBody("file://target/filelanguage?expression=myfile-${date:now:yyyyMMdd}.txt",
"Hello World");
 
-        Thread.sleep(500);
         String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
         assertFileExists("target/filelanguage/myfile-" + date + ".txt");
     }
@@ -79,7 +75,6 @@
         String expression = "../filelanguageinbox/myfile-${bean:myguidgenerator.guid}-${date:now:yyyyMMdd}.txt";
         template.sendBody("file://target/filelanguage?expression=" + expression, "Hello World");
 
-        Thread.sleep(500);
         String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
         assertFileExists("target/filelanguageinbox/myfile-123-" + date + ".txt");
     }
@@ -88,7 +83,6 @@
         template.sendBodyAndHeader("file://target/filelanguage?expression=myfile-${in.header.foo}.txt",
             "Hello World", "foo", "abc");
 
-        Thread.sleep(500);
         assertFileExists("target/filelanguage/myfile-abc.txt");
     }
 
@@ -100,7 +94,6 @@
         template.sendBodyAndHeader("file://target/filelanguage?expression=mybirthday-${date:in.header.birthday:yyyyMMdd}.txt",
             "Hello World", "birthday", date);
 
-        Thread.sleep(500);
         assertFileExists("target/filelanguage/mybirthday-19740420.txt");
     }
 

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameStrategyTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameStrategyTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameStrategyTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileProducerRenameStrategyTest.java
Wed Dec  3 02:04:11 2008
@@ -48,7 +48,7 @@
         mock.assertIsSatisfied();
 
         // sleep to let the file consumer do its renaming
-        Thread.sleep(500);
+        Thread.sleep(100);
 
         // content of file should be Hello Paris
         String content = IOConverter.toString(new File("./target/done/paris.txt"));
@@ -75,7 +75,7 @@
         mock.assertIsSatisfied();
 
         // sleep to let the file consumer do its renaming
-        Thread.sleep(500);
+        Thread.sleep(100);
 
         // content of file should be Hello London
         String content = IOConverter.toString(new File("./target/done/london.txt"));

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/MoveFilesToDirectoryTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/MoveFilesToDirectoryTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/MoveFilesToDirectoryTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/MoveFilesToDirectoryTest.java
Wed Dec  3 02:04:11 2008
@@ -41,13 +41,13 @@
         result.setResultWaitTime(5000);
 
         // now lets wait a bit and move that file
-        Thread.sleep(2000);
+        Thread.sleep(1000);
 
         // lets delete the output directory
         deleteDirectory(outputDirectory);
 
         // now lets wait a bit for it to be polled
-        Thread.sleep(2000);
+        Thread.sleep(1000);
 
         File file = new File(inputDirectory + "/" + fileName);
 
@@ -66,7 +66,7 @@
         assertFileExists(newFile);
 
         // now lets wait for multiple polls to check we only process it once
-        Thread.sleep(3000);
+        Thread.sleep(2000);
 
         assertMockEndpointsSatisfied();
     }

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/ToFileRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/ToFileRouteTest.java?rev=722828&r1=722827&r2=722828&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/ToFileRouteTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/ToFileRouteTest.java
Wed Dec  3 02:04:11 2008
@@ -22,6 +22,7 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.JndiRegistry;
 
 /**
@@ -31,10 +32,12 @@
 
     // START SNIPPET: e1
     public void testToFile() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+
         template.sendBody("seda:reports", "This is a great report");
 
-        // give time for the file to be written before assertions
-        Thread.sleep(1000);
+        assertMockEndpointsSatisfied();
 
         // assert the file exists
         File file = new File("target/test-reports/report.txt");
@@ -54,7 +57,7 @@
             public void configure() throws Exception {
                 // the reports from the seda queue is processed by our processor
                 // before they are written to files in the target/reports directory
-                from("seda:reports").processRef("processReport").to("file://target/test-reports");
+                from("seda:reports").processRef("processReport").to("file://target/test-reports",
"mock:result");
             }
         };
     }



Mime
View raw message