I'm writing some integration tests for a Spring Boot application written in Kotlin. To stub some HTTP requests, I'm using WireMock via spring-cloud-contract-wiremock
as dependency.
Some anonymized sample code from an integration test:
@SpringBootTest
@AutoConfigureMockMvc
@AutoConfigureWireMock
class MyIntegrationTest {
@Test
fun `some test`() {
mockEndpoint("url", 500, someResponseBodyInJson)
mockMvc.perform(
MockMvcRequestBuilders
.post("url")
.contentType(MediaType.APPLICATION_JSON.toString())
.content(someRequestBodyInJson)
)
.andExpect(MockMvcResultMatchers.status().isInternalServerError)
}
private fun mockEndpoint(url: String, responseCode: Int, responseBody: String) {
stubFor(
WireMock.post(url).willReturn(
WireMock.aResponse()
.withStatus(responseCode)
.withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString())
.withBody(responseBody)
)
)
}
}
While running these tests on my local machine, everything is working fine. On the CI/CD environment it's failing though with the following error:
java.lang.IllegalStateException: No Server ALPNProcessors!
at wiremock.org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory.<init>(ALPNServerConnectionFactory.java:52)
I did some searching and figured out is has to do with Jetty missing some things on the class path. I added the following dependency testImplementation("org.eclipse.jetty:jetty-alpn-server:11.0.7")
, but the tests are still failing. The alpn-boot
extension should not be necessary as JDK 11 is being used.
Anyone able to help me solve this? Do I need another dependency or am I looking in the wrong direction?