Richard Gill
12/23/2024, 12:10 PM@Rule
public WireMockRule wireMockRule = new WireMockRule(8089); // No-args constructor defaults to port 8080
Should be just:
@Rule
public WireMockRule wireMockRule;
(the documented code seems to blow up)
also, in this line:
.uri(wiremockServer.url("/my/resource"))
what's wiremockServer ? where do i instantiate that? does the @Rule not take care of that for me?
also, when my code reaches
stubFor(post("/my/resource")
It just blows up at that very point with a connection refused to http://localhost:8080
i don't quite know what i'm doing wrong - is that particular bit in the documentation correct?Lee Turner
12/23/2024, 12:16 PMLee Turner
12/23/2024, 12:17 PMRichard Gill
12/23/2024, 12:26 PMLee Turner
12/23/2024, 12:28 PM3.x.x
spring boot project then it is probably worth looking at jUnit 5 (junit jupiter) for testing. We have just adopted a spring boot integration project wicch provides much better support - especially for Jetty 12 (which is what Spring Boot 3.x.x ships with)Lee Turner
12/23/2024, 12:29 PMLee Turner
12/23/2024, 12:29 PMLee Turner
12/23/2024, 12:29 PMRichard Gill
12/23/2024, 12:31 PMLee Turner
12/23/2024, 12:33 PMRichard Gill
12/23/2024, 1:01 PM@WireMockTest
public class MockServerTest {
@Test
public void testMockServer(WireMockRunTimeInfo wireMockRuntimeInfo) {
stubFor(get("/do/ping").willReturn(ok()));
}
}
Richard Gill
12/23/2024, 1:02 PMRichard Gill
12/23/2024, 1:04 PMLee Turner
12/23/2024, 1:07 PMLee Turner
12/23/2024, 1:07 PMLee Turner
12/23/2024, 1:08 PMRichard Gill
12/23/2024, 1:33 PM@WireMockTest
Richard Gill
12/23/2024, 1:34 PMLee Turner
12/23/2024, 1:34 PMRichard Gill
12/23/2024, 1:35 PMRichard Gill
12/23/2024, 1:36 PMLee Turner
12/23/2024, 1:36 PMRichard Gill
12/23/2024, 1:38 PMLee Turner
12/23/2024, 1:54 PMRichard Gill
12/23/2024, 1:57 PMLee Turner
12/23/2024, 2:05 PM3.4.1
and wiremock 3.10.0
and the tests seem to pass fine.Lee Turner
12/23/2024, 2:07 PMHttpServerFactory
implementation. This is as a result of some changes that went into 3.10.0
but I don't know why it isn't finding an implementation.Lee Turner
12/23/2024, 2:08 PM3.9.2
and see if that worksLee Turner
12/23/2024, 2:11 PMRichard Gill
12/23/2024, 2:14 PMLee Turner
12/23/2024, 2:14 PMRichard Gill
12/23/2024, 2:17 PMRichard Gill
12/23/2024, 2:17 PMLee Turner
12/23/2024, 2:24 PMRichard Gill
12/23/2024, 2:53 PMRichard Gill
12/23/2024, 3:25 PMRichard Gill
12/23/2024, 3:26 PMLee Turner
12/23/2024, 3:30 PMlocalhost
?
Normally the tests just assume localhost and stub a url off of that I think. Pretty much like this example - https://github.com/wiremock/wiremock-examples/blob/main/spring-boot/spring-boot-3/[…]mockexamples/wiremockjetty12/PeopleInSpaceIntegrationTests.javaRichard Gill
12/23/2024, 3:34 PMLee Turner
12/23/2024, 3:40 PM// Bind the WireMock server to this IP address locally. Defaults to the loopback adaptor.
.bindAddress("192.168.1.111")
If you are specifying a name (dns) for the base url, that would still need to be configured locally to point to 127.0.0.1. You would then run into trouble if you wanted to run the same test in a CI server or someone else on their machine who didn't have the same local config for the dns name