use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class HttpClientAnnotationHandlerTest method it_should_set_client_instance_on_meta_annotated_field.
@Test
void it_should_set_client_instance_on_meta_annotated_field() {
final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
final TestClassWithMetaAnnotationField target = new TestClassWithMetaAnnotationField();
final Field field = extractClientField(TestClassWithMetaAnnotationField.class);
final AnnotationHandler handler = newHttpClientAnnotationHandler(server);
final HttpClient client = verifyBeforeTest(target, field, handler);
verifyAfterTest(target, field, handler, client);
verifyAsyncHttpClient(client);
}
use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class HttpClientAnnotationHandlerTest method it_should_set_client_instance.
@Test
void it_should_set_client_instance() {
final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
final TestClassWithAnnotatedField target = new TestClassWithAnnotatedField();
final Field field = extractClientField(TestClassWithAnnotatedField.class);
final AnnotationHandler handler = newHttpClientAnnotationHandler(server);
final HttpClient client = verifyBeforeTest(target, field, handler);
verifyAfterTest(target, field, handler, client);
}
use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class AsyncHttpClientTest method it_should_implement_to_string.
@Test
void it_should_implement_to_string() {
EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
HttpClient client = createDefaultClient(server);
org.asynchttpclient.AsyncHttpClient internalClient = readPrivate(client, "client");
assertThat(client).hasToString("AsyncHttpClient{" + "configuration: HttpClientConfiguration{" + "followRedirect: true, " + "defaultHeaders: {}, " + "defaultCookies: []" + "}, " + "server: MockEmbeddedServer, " + "client: " + internalClient.toString() + "}");
}
use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class OkHttpClientTest method it_should_implement_to_string.
@Test
void it_should_implement_to_string() {
final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
final HttpClient client = createDefaultClient(server);
final okhttp3.OkHttpClient internalClient = readPrivate(client, "client");
assertThat(client).hasToString("OkHttpClient{" + "configuration: HttpClientConfiguration{" + "followRedirect: true, " + "defaultHeaders: {}, " + "defaultCookies: []" + "}, " + "server: MockEmbeddedServer, " + "client: " + internalClient.toString() + ", " + "destroyed: false" + "}");
}
use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class BaseHttpClientTest method it_should_create_request_and_do_not_prepend_server_url.
@Test
void it_should_create_request_and_do_not_prepend_server_url() {
final HttpClient client = createDefaultClient(server);
final String endpoint = "/foo";
final String absoluteUrl = server.getUrl() + endpoint;
final HttpMethod httpMethod = HttpMethod.POST;
final HttpRequest httpRequest = client.prepareRequest(httpMethod, absoluteUrl);
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));
}
Aggregations