Author: gtully
Date: Fri Nov 14 07:29:44 2008
New Revision: 714032

URL: http://svn.apache.org/viewvc?rev=714032&view=rev
Log:
CAMEL-1090 fix reporting of duration in log message, used for DataSet

Added:
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java
   (with props)
Modified:
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThroughputLogger.java

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThroughputLogger.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThroughputLogger.java?rev=714032&r1=714031&r2=714032&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThroughputLogger.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThroughputLogger.java
 Fri Nov 14 07:29:44 2008
@@ -123,9 +123,10 @@
         double rate = messagesPerSecond(groupSize, groupStartTime, time);
         double average = messagesPerSecond(receivedCount, startTime, time);
 
+        long duration = time - groupStartTime;
         groupStartTime = time;
 
-        return getAction() + ": " + receivedCount + " messages so far. Last 
group took: " + (time - groupStartTime)
+        return getAction() + ": " + receivedCount + " messages so far. Last 
group took: " + (duration)
                 + " millis which is: " + numberFormat.format(rate)
                 + " messages per second. average: " + 
numberFormat.format(average);
     }

Added: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java?rev=714032&view=auto
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java
 (added)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java
 Fri Nov 14 07:29:44 2008
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.processor;
+
+import junit.framework.TestCase;
+
+public class ThroughPutLoggerTest extends TestCase {
+    public void testLogStringDurationIsNotZero() throws Exception {
+        ThroughputLogger underTest = new ThroughputLogger(10);
+        for (int i=0; i<25; i++) {
+            underTest.process(null);
+        }
+        String message = (String) underTest.logMessage(null);
+        assertTrue("consumed 20 :" + message, message.contains("20"));
+        assertTrue("no 'took: 0' :" + message, !message.contains("took: 0"));
+    }
+}

Propchange: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThroughPutLoggerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date


Reply via email to