From 56912fc2f8e0895a537d43b4fcc50e76fa4afc92 Mon Sep 17 00:00:00 2001 From: Sai Chandu Vallaboju Date: Fri, 3 Jul 2026 14:14:11 -0400 Subject: [PATCH] Fix Java JUnit quickstart HTTP client example --- src/content/docs/docs/quickstart/java-junit.mdx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/content/docs/docs/quickstart/java-junit.mdx b/src/content/docs/docs/quickstart/java-junit.mdx index 79cfea47..7f65c345 100644 --- a/src/content/docs/docs/quickstart/java-junit.mdx +++ b/src/content/docs/docs/quickstart/java-junit.mdx @@ -86,6 +86,7 @@ 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; @@ -93,7 +94,7 @@ 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")) @@ -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 response =