-
Bug
-
Resolution: Done
-
Major
-
2.7.5.ER3
-
None
-
False
-
None
-
False
-
-
-
-
---
com.redhat.quarkus.platform:quarkus-platform-bom brings in transitive dependencies:
+- org.testcontainers:testcontainers:jar:1.16.3:test | +- junit:junit:jar:4.13.2:test | | \- org.hamcrest:hamcrest-core:jar:1.3:test
\- io.rest-assured:rest-assured:jar:4.4.0:test +- org.hamcrest:hamcrest:jar:2.1:test
These two may cause a collision, e.g. when testcontainers are on the classpath and org.hamcrest.Matchers.containsStringIgnoringCase is used in a test.
pom.xml:
... <dependency> <groupId>org.testcontainers</groupId> <artifactId>testcontainers</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <scope>test</scope> </dependency> ...
test:
package org.acme; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.containsStringIgnoringCase; import org.junit.jupiter.api.Test; import io.quarkus.test.junit.QuarkusTest; @QuarkusTest public class GreetingResourceTest { @Test public void testHelloEndpoint() { given() .when().get("/hello") .then() .statusCode(200) .body(containsStringIgnoringCase("Hello from RESTEasy Reactive")); } }
(See reproducer.)
The test fails on dependency collision:
[ERROR] org.acme.GreetingResourceTest.testHelloEndpoint Time elapsed: 1.592 s <<< ERROR!
java.lang.NoSuchMethodError: 'org.hamcrest.Matcher org.hamcrest.core.StringContains.containsStringIgnoringCase(java.lang.String)'
at org.acme.GreetingResourceTest.testHelloEndpoint(GreetingResourceTest.java:19)
In this simple case, a workaround is easy (reorder dependencies, exclude), but IMO the BOM should handle that instead.