You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/12/21 00:34:29 UTC

(camel) 01/02: CAMEL-20225: converted tests to use StopWatch

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 342983e652687e2122e5dc9a9289a288565e6834
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Dec 20 16:56:11 2023 -0300

    CAMEL-20225: converted tests to use StopWatch
---
 .../camel/component/cxf/CxfOneWayRouteTest.java    |  5 +--
 ...sruptorReconfigureWithBlockingProducerTest.java |  5 +--
 .../camel/impl/DefaultConsumerTemplateTest.java    |  5 +--
 .../impl/DefaultProducerTemplateAsyncTest.java     | 41 +++++++++++-----------
 .../language/XPathRouteConcurrentBigTest.java      |  7 ++--
 ...eadLetterChannelRedeliveryDelayPatternTest.java |  5 +--
 .../camel/processor/DelayInterceptorTest.java      |  5 +--
 .../camel/processor/RoutePerformanceCountTest.java |  5 +--
 .../apache/camel/processor/ThrottlerDslTest.java   |  5 +--
 .../camel/processor/enricher/PollEnricherTest.java |  5 +--
 .../resequencer/ResequencerEngineTest.java         |  6 ++--
 11 files changed, 52 insertions(+), 42 deletions(-)

diff --git a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfOneWayRouteTest.java b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfOneWayRouteTest.java
index 82c194e99fe..6602f8fe473 100644
--- a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfOneWayRouteTest.java
+++ b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfOneWayRouteTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.cxf;
 
 import java.io.ByteArrayOutputStream;
+import java.time.Duration;
 
 import jakarta.xml.ws.Service;
 
@@ -83,8 +84,8 @@ public class CxfOneWayRouteTest extends CamelSpringTestSupport {
         client.greetMeOneWay("lemac");
 
         // may need to wait until the oneway call completes
-        long waitUntil = System.currentTimeMillis() + 10000;
-        while (!bindingDone && System.currentTimeMillis() < waitUntil) {
+        long waitUntil = System.nanoTime() + Duration.ofMillis(10000).toMillis();
+        while (!bindingDone && System.nanoTime() < waitUntil) {
             Thread.sleep(1000);
         }
 
diff --git a/components/camel-disruptor/src/test/java/org/apache/camel/component/disruptor/DisruptorReconfigureWithBlockingProducerTest.java b/components/camel-disruptor/src/test/java/org/apache/camel/component/disruptor/DisruptorReconfigureWithBlockingProducerTest.java
index 4178200efd7..c31c59afe06 100644
--- a/components/camel-disruptor/src/test/java/org/apache/camel/component/disruptor/DisruptorReconfigureWithBlockingProducerTest.java
+++ b/components/camel-disruptor/src/test/java/org/apache/camel/component/disruptor/DisruptorReconfigureWithBlockingProducerTest.java
@@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit5.CamelTestSupport;
+import org.apache.camel.util.StopWatch;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
@@ -35,7 +36,7 @@ public class DisruptorReconfigureWithBlockingProducerTest extends CamelTestSuppo
         getMockEndpoint("mock:a").expectedMessageCount(20);
         getMockEndpoint("mock:b").expectedMinimumMessageCount(10);
 
-        long beforeStart = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         ProducerThread producerThread = new ProducerThread();
         producerThread.start();
 
@@ -54,7 +55,7 @@ public class DisruptorReconfigureWithBlockingProducerTest extends CamelTestSuppo
         // If the reconfigure does not correctly hold back the producer thread on this request,
         // it will take approximately 20*200=4000 ms.
         // be on the safe side and check that it was at least faster than 2 seconds.
-        assertTrue((System.currentTimeMillis() - beforeStart) < 2000, "Reconfigure of Disruptor blocked");
+        assertTrue(watch.taken() < 2000, "Reconfigure of Disruptor blocked");
 
         //Wait and check that the producer has produced all messages without throwing an exception
         assertTrue(producerThread.checkResult());
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultConsumerTemplateTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultConsumerTemplateTest.java
index 263a3554a61..7c6005e806b 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultConsumerTemplateTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultConsumerTemplateTest.java
@@ -25,6 +25,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.engine.DefaultConsumerTemplate;
 import org.apache.camel.support.DefaultExchange;
+import org.apache.camel.util.StopWatch;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -100,10 +101,10 @@ public class DefaultConsumerTemplateTest extends ContextTestSupport {
 
     @Test
     public void testConsumeReceiveTimeout() throws Exception {
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         Exchange out = consumer.receive("seda:foo", 1000);
         assertNull(out);
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertTrue(delta < 1500, "Should take about 1 sec: " + delta);
 
         template.sendBody("seda:foo", "Hello");
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java
index 7105766dd9c..809ef19a115 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java
@@ -27,6 +27,7 @@ import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.support.DefaultExchange;
+import org.apache.camel.util.StopWatch;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -40,7 +41,7 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
         Exchange exchange = new DefaultExchange(context);
         exchange.getIn().setBody("Hello");
 
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         Future<Exchange> future = template.asyncSend("direct:start", exchange);
 
         // you can do other stuff
@@ -49,7 +50,7 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
 
         Exchange result = future.get();
 
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertEquals("Hello World", result.getIn().getBody());
         assertTrue(delta > 50, "Should take longer than: " + delta);
 
@@ -63,22 +64,22 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
                 exchange.getIn().setBody("Hello");
             }
         });
-        long start = System.currentTimeMillis();
 
+        StopWatch watch = new StopWatch();
         // you can do other stuff
         String echo = template.requestBody("direct:echo", "Hi", String.class);
         assertEquals("HiHi", echo);
 
         Exchange result = future.get();
 
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertEquals("Hello World", result.getIn().getBody());
         assertTrue(delta > 50, "Should take longer than: " + delta);
     }
 
     @Test
     public void testRequestAsyncBody() throws Exception {
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         Future<Object> future = template.asyncRequestBody("direct:start", "Hello");
 
         // you can do other stuff
@@ -88,14 +89,14 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
         // we can use extract body to convert to expect body type
         String result = template.extractFutureBody(future, String.class);
 
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertEquals("Hello World", result);
         assertTrue(delta > 50, "Should take longer than: " + delta);
     }
 
     @Test
     public void testRequestAsyncBodyType() throws Exception {
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         Future<String> future = template.asyncRequestBody("direct:start", "Hello", String.class);
 
         // you can do other stuff
@@ -106,7 +107,7 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
         // handle know its type
         String result = future.get();
 
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertEquals("Hello World", result);
         assertTrue(delta > 50, "Should take longer than: " + delta);
     }
@@ -117,7 +118,7 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
         mock.expectedBodiesReceived("Hello World");
         mock.expectedHeaderReceived("foo", 123);
 
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         Future<Object> future = template.asyncRequestBodyAndHeader("direct:start", "Hello", "foo", 123);
 
         // you can do other stuff
@@ -129,7 +130,7 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
 
         assertMockEndpointsSatisfied();
 
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertEquals("Hello World", result);
         assertTrue(delta > 50, "Should take longer than: " + delta);
     }
@@ -140,7 +141,7 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
         mock.expectedBodiesReceived("Hello World");
         mock.expectedHeaderReceived("foo", 123);
 
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         Future<String> future = template.asyncRequestBodyAndHeader("direct:start", "Hello", "foo", 123, String.class);
 
         // you can do other stuff
@@ -153,7 +154,7 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
 
         assertMockEndpointsSatisfied();
 
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertEquals("Hello World", result);
         assertTrue(delta > 50, "Should take longer than: " + delta);
     }
@@ -168,7 +169,7 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
         Map<String, Object> headers = new HashMap<>();
         headers.put("foo", 123);
         headers.put("bar", "cheese");
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         Future<Object> future = template.asyncRequestBodyAndHeaders("direct:start", "Hello", headers);
 
         // you can do other stuff
@@ -180,7 +181,7 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
 
         assertMockEndpointsSatisfied();
 
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertEquals("Hello World", result);
         assertTrue(delta > 50, "Should take longer than: " + delta);
     }
@@ -195,7 +196,7 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
         Map<String, Object> headers = new HashMap<>();
         headers.put("foo", 123);
         headers.put("bar", "cheese");
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         Future<String> future = template.asyncRequestBodyAndHeaders("direct:start", "Hello", headers, String.class);
 
         // you can do other stuff
@@ -208,7 +209,7 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
 
         assertMockEndpointsSatisfied();
 
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertEquals("Hello World", result);
         assertTrue(delta > 50, "Should take longer than: " + delta);
     }
@@ -218,7 +219,7 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
         Exchange exchange = new DefaultExchange(context);
         exchange.getIn().setBody("Hello");
 
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         Future<Object> future = template.asyncRequestBody("direct:error", exchange);
 
         // you can do other stuff
@@ -231,13 +232,13 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
 
         assertEquals("Damn forced by unit test", e.getCause().getMessage());
 
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertTrue(delta > 50, "Should take longer than: " + delta);
     }
 
     @Test
     public void testRequestAsyncBodyErrorWhenProcessing() throws Exception {
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         Future<Object> future = template.asyncRequestBody("direct:error", "Hello");
 
         // you can do other stuff
@@ -250,7 +251,7 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
 
         assertEquals("Damn forced by unit test", e.getCause().getMessage());
 
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertTrue(delta > 50, "Should take longer than: " + delta);
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/XPathRouteConcurrentBigTest.java b/core/camel-core/src/test/java/org/apache/camel/language/XPathRouteConcurrentBigTest.java
index e71298e9cc3..9f5cd798e00 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/XPathRouteConcurrentBigTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/XPathRouteConcurrentBigTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.language;
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.StopWatch;
 import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,7 +51,7 @@ public class XPathRouteConcurrentBigTest extends ContextTestSupport {
         int forResult = (messageCount * 2 / 3) + messageCount % 3;
         int forOther = messageCount - forResult;
 
-        long now = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
 
         // give more time on slow servers
         getMockEndpoint("mock:result").setResultWaitTime(30000);
@@ -75,11 +76,11 @@ public class XPathRouteConcurrentBigTest extends ContextTestSupport {
             }
         }
 
-        LOG.info("Sent {} messages in {} ms", messageCount, System.currentTimeMillis() - now);
+        LOG.info("Sent {} messages in {} ms", messageCount, watch.taken());
 
         assertMockEndpointsSatisfied();
 
-        LOG.info("Processed {} messages in {} ms", messageCount, System.currentTimeMillis() - now);
+        LOG.info("Processed {} messages in {} ms", messageCount, watch.taken());
     }
 
     @Override
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelRedeliveryDelayPatternTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelRedeliveryDelayPatternTest.java
index 9aafecda946..c7a5543dffa 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelRedeliveryDelayPatternTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelRedeliveryDelayPatternTest.java
@@ -21,6 +21,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.util.StopWatch;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -40,9 +41,9 @@ public class DeadLetterChannelRedeliveryDelayPatternTest extends ContextTestSupp
         MockEndpoint mock = getMockEndpoint("mock:error");
         mock.expectedMessageCount(1);
 
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         template.sendBody("direct:start", "Hello World");
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertTrue(delta > 1000, "Should be slower");
 
         assertMockEndpointsSatisfied();
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/DelayInterceptorTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/DelayInterceptorTest.java
index b4ca2fddeb4..dac9aa39ed8 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/DelayInterceptorTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/DelayInterceptorTest.java
@@ -20,6 +20,7 @@ import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.StopWatch;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -31,11 +32,11 @@ public class DelayInterceptorTest extends ContextTestSupport {
 
     @Test
     public void testDelayer() throws Exception {
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         for (int i = 0; i < 10; i++) {
             template.sendBody("direct:start", "Message #" + i);
         }
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertTrue(delta > 100, "Should not be that fast to run: " + delta);
         // some OS boxes are slow
         assertTrue(delta < 5000, "Should not take that long to run: " + delta);
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceCountTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceCountTest.java
index 5e3a24e4bb9..668475b138b 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceCountTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceCountTest.java
@@ -23,6 +23,7 @@ import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.StopWatch;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -35,14 +36,14 @@ public class RoutePerformanceCountTest extends ContextTestSupport {
 
     @Test
     public void testSendMessages() throws Exception {
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
 
         for (int i = 0; i < size; i++) {
             template.sendBody(url, "Message " + i);
         }
         assertEquals(size, processor.getCounter());
 
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         log.info("RoutePerformanceCountTest: Sent: {} Took: {} ms", size, delta);
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerDslTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerDslTest.java
index bb34216469a..f93f7cd7424 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerDslTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerDslTest.java
@@ -22,6 +22,7 @@ import java.util.concurrent.Executors;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.util.StopWatch;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.DisabledOnOs;
 import org.junit.jupiter.api.condition.OS;
@@ -40,7 +41,7 @@ public class ThrottlerDslTest extends ContextTestSupport {
 
         ExecutorService executor = Executors.newFixedThreadPool(messageCount);
 
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         for (int i = 0; i < messageCount; i++) {
             executor.execute(() -> template.sendBodyAndHeader("direct:start", "payload", "ThrottleCount", 1));
         }
@@ -51,7 +52,7 @@ public class ThrottlerDslTest extends ContextTestSupport {
         // now assert that they have actually been throttled
         long minimumTime = messageCount * INTERVAL;
         // add a little slack
-        long delta = System.currentTimeMillis() - start + 200;
+        long delta = watch.taken() + 200;
         assertTrue(delta >= minimumTime, "Should take at least " + minimumTime + "ms, was: " + delta);
         executor.shutdownNow();
     }
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java
index c7b1e60519e..d59010c78fe 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/PollEnricherTest.java
@@ -22,6 +22,7 @@ import org.apache.camel.ExchangePattern;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.util.StopWatch;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
@@ -85,7 +86,7 @@ public class PollEnricherTest extends ContextTestSupport {
             }
         });
 
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         mock.expectedBodiesReceived("test:blah");
 
         t.start();
@@ -93,7 +94,7 @@ public class PollEnricherTest extends ContextTestSupport {
         // should take approx 1 sec to complete as the other thread is sending a
         // bit later and we wait
         mock.assertIsSatisfied();
-        long delta = System.currentTimeMillis() - start;
+        long delta = watch.taken();
         assertTrue(delta > 150, "Should take approx 0.25 sec: was " + delta);
     }
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/resequencer/ResequencerEngineTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/resequencer/ResequencerEngineTest.java
index d1fd0efe6f9..a5067fed295 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/resequencer/ResequencerEngineTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/resequencer/ResequencerEngineTest.java
@@ -22,6 +22,7 @@ import java.util.Random;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.TestSupport;
+import org.apache.camel.util.StopWatch;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.DisabledIf;
@@ -101,7 +102,7 @@ class ResequencerEngineTest extends TestSupport {
         Random random = new Random(System.currentTimeMillis());
         StringBuilder sb = new StringBuilder(4000);
         sb.append("Input sequence: ");
-        long millis = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         for (int i = input; i > 0; i--) {
             int r = random.nextInt(i);
             int next = list.remove(r);
@@ -117,9 +118,8 @@ class ResequencerEngineTest extends TestSupport {
         for (int i = 0; i < input; i++) {
             sb.append(buffer.take()).append(" ");
         }
-        millis = System.currentTimeMillis() - millis;
         log.info(sb.toString());
-        log.info("Duration = {} ms", millis);
+        log.info("Duration = {} ms", watch.taken());
     }
 
     @DisabledIf(value = "isIgnoreLoadTests",