Author: davsclaus
Date: Sat Jul  9 13:38:14 2011
New Revision: 1144669

URL: http://svn.apache.org/viewvc?rev=1144669&view=rev
Log:
CAMEL-4201: Added time it took to execute the test method being logged, when 
using the test kits.

Modified:
    
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
    
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
    
camel/trunk/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java

Modified: 
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java?rev=1144669&r1=1144668&r2=1144669&view=diff
==============================================================================
--- 
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
 (original)
+++ 
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
 Sat Jul  9 13:38:14 2011
@@ -45,6 +45,8 @@ import org.apache.camel.management.JmxSy
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.spi.Language;
 import org.apache.camel.spring.CamelBeanPostProcessor;
+import org.apache.camel.util.StopWatch;
+import org.apache.camel.util.TimeUtils;
 
 /**
  * A useful base class which creates a {@link org.apache.camel.CamelContext} 
with some routes
@@ -60,6 +62,7 @@ public abstract class CamelTestSupport e
     private boolean useRouteBuilder = true;
     private Service camelContextService;
     private final DebugBreakpoint breakpoint = new DebugBreakpoint();
+    private final StopWatch watch = new StopWatch();
 
     /**
      * Use the RouteBuilder or not
@@ -153,11 +156,19 @@ public abstract class CamelTestSupport e
         log.debug("Routing Rules are: " + context.getRoutes());
 
         assertValidContext(context);
+
+        // only start timing after all the setup
+        watch.restart();
     }
 
     @Override
     protected void tearDown() throws Exception {
-        log.info("Testing done: " + this);
+        long time = watch.stop();
+
+        
log.info("********************************************************************************");
+        log.info("Testing done: " + getTestMethodName() + "(" + 
getClass().getName() + ")");
+        log.info("Took: " + TimeUtils.printDuration(time) + " ("  + time + " 
millis)");
+        
log.info("********************************************************************************");
 
         log.debug("tearDown test: " + getName());
         if (consumer != null) {

Modified: 
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java?rev=1144669&r1=1144668&r2=1144669&view=diff
==============================================================================
--- 
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
 (original)
+++ 
camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
 Sat Jul  9 13:38:14 2011
@@ -46,6 +46,8 @@ import org.apache.camel.management.JmxSy
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.spi.Language;
 import org.apache.camel.spring.CamelBeanPostProcessor;
+import org.apache.camel.util.StopWatch;
+import org.apache.camel.util.TimeUtils;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -68,6 +70,7 @@ public abstract class CamelTestSupport e
     private static final AtomicBoolean INIT = new AtomicBoolean();
     private boolean useRouteBuilder = true;
     private final DebugBreakpoint breakpoint = new DebugBreakpoint();
+    private final StopWatch watch = new StopWatch();
 
     /**
      * Use the RouteBuilder or not
@@ -148,6 +151,9 @@ public abstract class CamelTestSupport e
             doSetUp();
             doPostSetup();
         }
+
+        // only start timing after all the setup
+        watch.restart();
     }
 
     /**
@@ -219,8 +225,11 @@ public abstract class CamelTestSupport e
 
     @After
     public void tearDown() throws Exception {
+        long time = watch.stop();
+
         
log.info("********************************************************************************");
         log.info("Testing done: " + getTestMethodName() + "(" + 
getClass().getName() + ")");
+        log.info("Took: " + TimeUtils.printDuration(time) + " ("  + time + " 
millis)");
         
log.info("********************************************************************************");
 
         if (isCreateCamelContextPerClass()) {

Modified: 
camel/trunk/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java?rev=1144669&r1=1144668&r2=1144669&view=diff
==============================================================================
--- 
camel/trunk/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java
 (original)
+++ 
camel/trunk/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java
 Sat Jul  9 13:38:14 2011
@@ -46,13 +46,13 @@ import org.apache.camel.management.JmxSy
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.spi.Language;
 import org.apache.camel.spring.CamelBeanPostProcessor;
+import org.apache.camel.util.StopWatch;
+import org.apache.camel.util.TimeUtils;
 import org.junit.AfterClass;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterMethod;
-import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.BeforeTest;
 
 /**
  * A useful base class which creates a {@link org.apache.camel.CamelContext} 
with some routes
@@ -70,6 +70,7 @@ public abstract class CamelTestSupport e
     private static final AtomicBoolean INIT = new AtomicBoolean();
     private boolean useRouteBuilder = true;
     private final DebugBreakpoint breakpoint = new DebugBreakpoint();
+    private final StopWatch watch = new StopWatch();
 
     /**
      * Use the RouteBuilder or not
@@ -143,6 +144,9 @@ public abstract class CamelTestSupport e
             // test is per test so always setup
             doSetUp();
         }
+
+        // only start timing after all the setup
+        watch.restart();
     }
 
     protected void doSetUp() throws Exception {
@@ -200,8 +204,11 @@ public abstract class CamelTestSupport e
 
     @AfterMethod
     public void tearDown() throws Exception {
+        long time = watch.stop();
+
         
log.info("********************************************************************************");
         log.info("Testing done: " + getTestMethodName() + "(" + 
getClass().getName() + ")");
+        log.info("Took: " + TimeUtils.printDuration(time) + " ("  + time + " 
millis)");
         
log.info("********************************************************************************");
 
         if (isCreateCamelContextPerClass()) {


Reply via email to