Search in sources :

Example 16 with HttpRequest

use of com.github.mjeanroy.junit.servers.client.HttpRequest in project junit-servers by mjeanroy.

the class BaseHttpClientTest method it_should_create_request.

@Test
void it_should_create_request() {
    final HttpClient client = createDefaultClient(server);
    final String endpoint = "/foo";
    final HttpMethod httpMethod = HttpMethod.POST;
    final HttpRequest httpRequest = client.prepareRequest(httpMethod, endpoint);
    assertThat(httpRequest.getMethod()).isEqualTo(httpMethod);
    assertThat(httpRequest.getEndpoint()).isNotNull();
    assertThat(httpRequest.getEndpoint().getScheme()).isEqualTo(scheme);
    assertThat(httpRequest.getEndpoint().getHost()).isEqualTo(host);
    assertThat(httpRequest.getEndpoint().getPort()).isEqualTo(port);
    assertThat(httpRequest.getEndpoint().getPath()).isEqualTo(path + endpoint);
    assertThat(httpRequest.getEndpoint().toString()).isEqualTo(url(scheme, host, port, path + endpoint));
}
Also used : HttpRequest(com.github.mjeanroy.junit.servers.client.HttpRequest) HttpClient(com.github.mjeanroy.junit.servers.client.HttpClient) HttpMethod(com.github.mjeanroy.junit.servers.client.HttpMethod) Test(org.junit.jupiter.api.Test)

Aggregations

HttpRequest (com.github.mjeanroy.junit.servers.client.HttpRequest)16 Test (org.junit.jupiter.api.Test)11 HttpClient (com.github.mjeanroy.junit.servers.client.HttpClient)9 HttpMethod (com.github.mjeanroy.junit.servers.client.HttpMethod)5 HttpResponse (com.github.mjeanroy.junit.servers.client.HttpResponse)4 Pair (com.github.mjeanroy.junit.servers.utils.commons.Pair)3 WireMockTest (com.github.mjeanroy.junit.servers.utils.jupiter.WireMockTest)2 Cookie (com.github.mjeanroy.junit.servers.client.Cookie)1 HttpHeader (com.github.mjeanroy.junit.servers.client.HttpHeader)1 HttpUrl (com.github.mjeanroy.junit.servers.client.HttpUrl)1