Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/content/docs/docs/quickstart/java-junit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,15 @@ public WireMockRule wireMockRule = new WireMockRule(8089); // No-args constructo
Now you're ready to write a test case like this:

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

...

@Test
public void exampleTest() {
public void exampleTest() throws Exception {
// Setup the WireMock mapping stub for the test
stubFor(post("/my/resource")
.withHeader("Content-Type", containing("xml"))
Expand All @@ -104,9 +105,10 @@ public void exampleTest() {
// Setup HTTP POST request (with HTTP Client embedded in Java 11+)
final HttpClient client = HttpClient.newBuilder().build();
final HttpRequest request = HttpRequest.newBuilder()
.uri(wiremockServer.url("/my/resource"))
.uri(URI.create(wireMockRule.url("/my/resource")))
.header("Content-Type", "text/xml")
.POST().build();
.POST(HttpRequest.BodyPublishers.noBody())
.build();

// Send the request and receive the response
final HttpResponse<String> response =
Expand Down