Class HttpClient
- java.lang.Object
-
- io.wcm.siteapi.integrationtestsupport.httpclient.HttpClient
-
public final class HttpClient extends java.lang.Object
Simple HTTP client wrapper to execute HTTP requests during integration tests. Usesjava.net.http
HTTP client internally.
-
-
Constructor Summary
Constructors Constructor Description HttpClient(IntegrationTestContextBuilder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull HttpResponse<java.lang.String>
get(@NotNull java.lang.String url)
Fetch HTTP content.@NotNull java.lang.String
getBody(@NotNull java.lang.String url)
Fetch HTTP content.
-
-
-
Constructor Detail
-
HttpClient
public HttpClient(IntegrationTestContextBuilder builder)
- Parameters:
builder
- Integration test context builder.
-
-
Method Detail
-
get
@NotNull public @NotNull HttpResponse<java.lang.String> get(@NotNull @NotNull java.lang.String url)
Fetch HTTP content. Check status code of response for success.- Parameters:
url
- URL- Returns:
- HTTP response.
-
getBody
@NotNull public @NotNull java.lang.String getBody(@NotNull @NotNull java.lang.String url)
Fetch HTTP content. Fails with exception when request does not return successfully.- Parameters:
url
- URL- Returns:
- Body string.
-
-