You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2023/07/03 13:16:53 UTC
[camel] 01/03: Output better test failure messages in MicrometerExchangeEventNotifierTest
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 5c04f63daa8523bf70af77251ff979c61362d520
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Wed Jun 28 22:24:20 2023 +0200
Output better test failure messages in MicrometerExchangeEventNotifierTest
---
components/camel-micrometer/pom.xml | 6 ++++++
.../eventnotifier/MicrometerExchangeEventNotifierTest.java | 12 ++++++------
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/components/camel-micrometer/pom.xml b/components/camel-micrometer/pom.xml
index 41ce7936b8e..07925cfe607 100644
--- a/components/camel-micrometer/pom.xml
+++ b/components/camel-micrometer/pom.xml
@@ -104,6 +104,12 @@
<version>${hamcrest-version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${assertj-version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
diff --git a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/eventnotifier/MicrometerExchangeEventNotifierTest.java b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/eventnotifier/MicrometerExchangeEventNotifierTest.java
index 61271520e63..94486512ef6 100644
--- a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/eventnotifier/MicrometerExchangeEventNotifierTest.java
+++ b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/eventnotifier/MicrometerExchangeEventNotifierTest.java
@@ -24,12 +24,12 @@ import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.support.ExpressionAdapter;
+import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.apache.camel.component.micrometer.MicrometerConstants.DEFAULT_CAMEL_ROUTES_EXCHANGES_INFLIGHT;
import static org.apache.camel.component.micrometer.MicrometerConstants.ROUTE_ID_TAG;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.assertj.core.api.Assertions.withPrecision;
public class MicrometerExchangeEventNotifierTest extends AbstractMicrometerEventNotifierTest {
@@ -54,7 +54,7 @@ public class MicrometerExchangeEventNotifierTest extends AbstractMicrometerEvent
@Override
public Object evaluate(Exchange exchange) {
try {
- assertEquals(1.0D, currentInflightExchanges(), 0.1D);
+ Assertions.assertThat(currentInflightExchanges()).isEqualTo(1.0D, withPrecision(0.1D));
Thread.sleep(SLEEP);
return exchange.getIn().getBody();
} catch (InterruptedException e) {
@@ -71,9 +71,9 @@ public class MicrometerExchangeEventNotifierTest extends AbstractMicrometerEvent
mock.assertIsSatisfied();
Timer timer = meterRegistry.find(MOCK_OUT).timer();
- assertEquals(count, timer.count());
- assertTrue(timer.mean(TimeUnit.MILLISECONDS) > SLEEP.doubleValue());
- assertEquals(0.0D, currentInflightExchanges(), 0.1D);
+ Assertions.assertThat(timer.count()).isEqualTo(count);
+ Assertions.assertThat(timer.mean(TimeUnit.MILLISECONDS)).isGreaterThan(SLEEP.doubleValue());
+ Assertions.assertThat(currentInflightExchanges()).isEqualTo(0.0D, withPrecision(0.1D));
}
private double currentInflightExchanges() {