use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class HttpClientAnnotationHandlerTest method verifyBeforeTest.
private static HttpClient verifyBeforeTest(Object target, Field field, AnnotationHandler handler) {
handler.before(target, field);
final HttpClient client = readPrivate(target, "client");
assertThat(client).isNotNull();
assertThat(client.isDestroyed()).isFalse();
return client;
}
use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class ServerRuleTest method it_should_destroy_http_client_when_rule_stop.
@Test
void it_should_destroy_http_client_when_rule_stop() {
final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
final ServerRule rule = createRule(server);
final HttpClient client = rule.getClient();
assertThat(client).isNotNull();
assertThat(client.isDestroyed()).isFalse();
rule.after();
assertThat(client.isDestroyed()).isTrue();
}
use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class ServerRuleTest method it_should_get_http_client.
@Test
void it_should_get_http_client() {
final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
final ServerRule rule = createRule(server);
final HttpClient client = rule.getClient();
assertThat(client).isNotNull();
assertThat(client).isSameAs(rule.getClient());
assertThat(client.isDestroyed()).isFalse();
}
use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class HttpClientParameterResolverFunctionTest method it_should_resolve_http_client_with_given_configuration_on_meta_annotation.
@Test
public void it_should_resolve_http_client_with_given_configuration_on_meta_annotation() throws Exception {
final ParameterContext parameterContext = extractParameterContext("method_with_meta_annotation");
final Object result = resolver.resolve(parameterContext, adapter);
assertThat(result).isInstanceOf(HttpClient.class);
final HttpClient httpClient = (HttpClient) result;
assertThat(httpClient.getConfiguration()).isNotNull();
assertThat(httpClient.getConfiguration().isFollowRedirect()).isFalse();
}
use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class HttpClientParameterResolverFunctionTest method it_should_resolve_http_client_with_given_configuration.
@Test
public void it_should_resolve_http_client_with_given_configuration() throws Exception {
final ParameterContext parameterContext = extractParameterContext("method_with_annotation_and_configuration_factory");
final Object result = resolver.resolve(parameterContext, adapter);
assertThat(result).isInstanceOf(HttpClient.class);
final HttpClient httpClient = (HttpClient) result;
assertThat(httpClient.getConfiguration()).isNotNull();
assertThat(httpClient.getConfiguration().isFollowRedirect()).isFalse();
}
Aggregations