Search in sources :

Example 11 with HttpClientConfiguration

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

the class BaseHttpClientTest method testRequestWithDefaultHeaderObject.

@Test
void testRequestWithDefaultHeaderObject() {
    final String name = "X-Custom-Header";
    final String value = "FooBar";
    final HttpHeader header = HttpHeader.header(name, value);
    final HttpClientConfiguration configuration = new HttpClientConfiguration.Builder().addDefaultHeader(header).build();
    stubDefaultRequest(ENDPOINT);
    testRequestHeader(createCustomClient(configuration), name, value, rq -> {
    });
}
Also used : HttpHeader(com.github.mjeanroy.junit.servers.client.HttpHeader) EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) HttpRequestBodies.multipartBuilder(com.github.mjeanroy.junit.servers.client.HttpRequestBodies.multipartBuilder) HttpClientConfiguration(com.github.mjeanroy.junit.servers.client.HttpClientConfiguration) WireMockTest(com.github.mjeanroy.junit.servers.utils.jupiter.WireMockTest) Test(org.junit.jupiter.api.Test)

Example 12 with HttpClientConfiguration

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

the class BaseHttpClientTest method testRequestWithDefaultHeader.

@Test
void testRequestWithDefaultHeader() {
    final String name = "X-Custom-Header";
    final String value = "FooBar";
    final HttpClientConfiguration configuration = new HttpClientConfiguration.Builder().addDefaultHeader(name, value).build();
    stubDefaultRequest(ENDPOINT);
    testRequestHeader(createCustomClient(configuration), name, value, rq -> {
    });
}
Also used : EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) HttpRequestBodies.multipartBuilder(com.github.mjeanroy.junit.servers.client.HttpRequestBodies.multipartBuilder) HttpClientConfiguration(com.github.mjeanroy.junit.servers.client.HttpClientConfiguration) WireMockTest(com.github.mjeanroy.junit.servers.utils.jupiter.WireMockTest) Test(org.junit.jupiter.api.Test)

Example 13 with HttpClientConfiguration

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

the class BaseHttpClientTest method it_should_create_client_with_custom_configuration.

@Test
void it_should_create_client_with_custom_configuration() {
    final HttpClientConfiguration configuration = new HttpClientConfiguration.Builder().disableFollowRedirect().build();
    final HttpClient client = createCustomClient(configuration, server);
    assertThat(client).isNotNull();
    final EmbeddedServer<?> server = readPrivate(client, "server");
    assertThat(server).isNotNull().isSameAs(this.server);
    checkInternalHttpClient(configuration, client);
}
Also used : EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) HttpClient(com.github.mjeanroy.junit.servers.client.HttpClient) HttpClientConfiguration(com.github.mjeanroy.junit.servers.client.HttpClientConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

HttpClientConfiguration (com.github.mjeanroy.junit.servers.client.HttpClientConfiguration)13 EmbeddedServerMockBuilder (com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder)11 Test (org.junit.jupiter.api.Test)11 HttpClient (com.github.mjeanroy.junit.servers.client.HttpClient)7 OkHttpClient (com.github.mjeanroy.junit.servers.client.impl.okhttp3.OkHttpClient)6 HttpClientStrategy (com.github.mjeanroy.junit.servers.client.HttpClientStrategy)4 HttpRequestBodies.multipartBuilder (com.github.mjeanroy.junit.servers.client.HttpRequestBodies.multipartBuilder)4 FakeEmbeddedServerConfigurationBuilder (com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfigurationBuilder)4 WireMockTest (com.github.mjeanroy.junit.servers.utils.jupiter.WireMockTest)4 TestHttpClient (com.github.mjeanroy.junit.servers.annotations.TestHttpClient)1 HttpHeader (com.github.mjeanroy.junit.servers.client.HttpHeader)1 ToStringBuilder (com.github.mjeanroy.junit.servers.commons.lang.ToStringBuilder)1 AsyncHttpClient (com.ning.http.client.AsyncHttpClient)1 AsyncHttpClientConfig (com.ning.http.client.AsyncHttpClientConfig)1