camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r765493 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/builder/ main/java/org/apache/camel/component/dataset/ main/java/org/apache/camel/component/mock/ main/java/org/apache/camel/processor/ test/java/org/apache/camel/componen...
Date Thu, 16 Apr 2009 07:47:51 GMT
Author: davsclaus
Date: Thu Apr 16 07:47:51 2009
New Revision: 765493

URL: http://svn.apache.org/viewvc?rev=765493&view=rev
Log:
CAMEL-1535: Unit testing with mock could potential hang. Fixed spelling and some other potential
unit test failures. 

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java?rev=765493&r1=765492&r2=765493&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java
Thu Apr 16 07:47:51 2009
@@ -53,10 +53,11 @@
     }
 
     /**
-     * Returns whether a specific error handler builder has been configued or not.
+     * Returns whether a specific error handler builder has been configured or not.
      * <p/>
-     * Can be used to test if none has been configued and then install a custom error handler
builder
-     * replacing the default error handler (that would have been used as fallback).
+     * Can be used to test if none has been configured and then install a custom error handler
builder
+     * replacing the default error handler (that would have been used as fallback otherwise).
+     * <br/>
      * This is for instance used by the transacted policy to setup a TransactedErrorHandlerBuilder
      * in camel-spring.
      */

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java?rev=765493&r1=765492&r2=765493&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetConsumer.java
Thu Apr 16 07:47:51 2009
@@ -62,10 +62,10 @@
 
                 try {
                     long delay = endpoint.getProduceDelay();
-                    if (delay >= 0 && delay < 3) {
-                        // if no delay set then we must sleep at lest for 3 millis to avoid
concurrency
+                    if (delay >= 0 && delay < 4) {
+                        // if no delay set then we must sleep at lest for 4 millis to avoid
concurrency
                         // issues with extremely high throughput
-                        delay = 3;
+                        delay = 4;
                     }
                     // to allow -1 to force none delay at all
                     if (delay > 0) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java?rev=765493&r1=765492&r2=765493&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
Thu Apr 16 07:47:51 2009
@@ -727,13 +727,15 @@
             if (reporter != null) {
                 reporter.process(exchange);
             }
-
             performAssertions(exchange);
-        } catch (Exception e) {
+        } catch (Throwable e) {
+            // must catch throwable as AssertionException extends java.lang.Error
             failures.add(e);
-        }
-        if (latch != null) {
-            latch.countDown();
+        } finally {
+            // make sure latch is counted down to avoid test hanging forever
+            if (latch != null) {
+                latch.countDown();
+            }
         }
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java?rev=765493&r1=765492&r2=765493&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java
Thu Apr 16 07:47:51 2009
@@ -23,7 +23,7 @@
 /**
  * A processor which sets the body on the OUT message with an expression
  */
-public class TransformProcessor extends DelegateProcessor implements Processor {
+public class TransformProcessor extends DelegateProcessor {
     private final Expression expression;
 
     public TransformProcessor(Expression expression) {
@@ -48,6 +48,6 @@
 
     @Override
     public String toString() {
-        return "transform(" + expression + "," + processor + ")";
+        return "Transform(" + expression + (processor != null ? "," + processor : "") + ")";
     }
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java?rev=765493&r1=765492&r2=765493&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java
Thu Apr 16 07:47:51 2009
@@ -48,9 +48,9 @@
             public void configure() throws Exception {
                 //TODO: remove this once the delegate processor supports async
                 errorHandler(noErrorHandler());
-                
-                from("dataset:foo").to("seda:queue:test?size=100");
-                from("seda:queue:test?size=100").to("dataset:foo");
+
+                from("dataset:foo").to("seda:queue:test?size=200");
+                from("seda:queue:test?size=200").to("dataset:foo");
             }
         };
     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java?rev=765493&r1=765492&r2=765493&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/DirectoryCreateIssueTest.java
Thu Apr 16 07:47:51 2009
@@ -49,13 +49,12 @@
                     destinations[i] = "seda:file" + i;
 
                     from("seda:file" + i)
-                            .setHeader(Exchange.FILE_NAME,
-                                    constant("file" + i + ".txt"))
-                            .to("file://" + path + "/?append=false&noop=true", "mock:result");
+                        .setHeader(Exchange.FILE_NAME, constant("file" + i + ".txt"))
+                        .to("file://" + path + "/?append=false&noop=true", "mock:result");
                 }
 
                 from("seda:testFileCreatedAsDir")
-                        .to(destinations);
+                    .to(destinations);
             }
         };
     }
@@ -70,7 +69,7 @@
             }
         });
         // wait a while for the file creation
-        Thread.sleep(1000);
+        Thread.sleep(2000);
         assertMockEndpointsSatisfied();
 
         for (int i = 0; i < numFiles; i++) {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java?rev=765493&r1=765492&r2=765493&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java
Thu Apr 16 07:47:51 2009
@@ -24,20 +24,17 @@
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.dataset.SimpleDataSet;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * A route for simple performance testing that can be used when we suspect
  * something is wrong. Inspired by end user on forum doing this as proof of concept.
  */
 public class RoutePerformanceTest extends ContextTestSupport {
-    private static final Log LOG = LogFactory.getLog(RoutePerformanceTest.class);
 
     protected SimpleDataSet dataSet = new SimpleDataSet(1000);
 
     public void testPerformance() throws Exception {
-        long start = System.nanoTime();
+        long start = System.currentTimeMillis();
 
         MockEndpoint endpoint = getMockEndpoint("mock:results");
         endpoint.expectedMessageCount((int) dataSet.getSize());
@@ -45,10 +42,9 @@
 
         assertMockEndpointsSatisfied();
 
-        long delta = System.nanoTime() - start;
+        long delta = System.currentTimeMillis() - start;
 
-        LOG.info("Took: " + delta + " ns");
-        LOG.info("Took: " + delta / 1000000 + " millis");
+        System.out.println("RoutePerformanceTest: Took: " + delta + " ms");
     }
 
     @Override



Mime
View raw message