use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class EmbeddedServerRunnerTest method it_should_get_client_with_custom_configuration.
@Test
public void it_should_get_client_with_custom_configuration() {
final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
final EmbeddedServerRunner adapter = new EmbeddedServerRunner(server);
final HttpClientConfiguration configuration = new HttpClientConfiguration.Builder().disableFollowRedirect().build();
final HttpClient client = adapter.getClient(configuration);
assertThat(client).isNotNull();
assertThat(client.getConfiguration()).isSameAs(configuration);
}
use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class EmbeddedServerRunnerTest method it_should_get_client_of_given_strategy.
@Test
void it_should_get_client_of_given_strategy() {
final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
final EmbeddedServerRunner adapter = new EmbeddedServerRunner(server);
final HttpClientStrategy strategy = HttpClientStrategy.OK_HTTP3;
final HttpClient client = adapter.getClient(strategy);
assertThat(client).isNotNull();
}
use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class EmbeddedServerRunnerTest method it_should_get_client_with_given_strategy_custom_configuration_and_return_previous_one_with_same_configuration.
@Test
public void it_should_get_client_with_given_strategy_custom_configuration_and_return_previous_one_with_same_configuration() {
final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
final EmbeddedServerRunner adapter = new EmbeddedServerRunner(server);
final HttpClientStrategy strategy = HttpClientStrategy.OK_HTTP3;
final HttpClientConfiguration configuration1 = new HttpClientConfiguration.Builder().build();
final HttpClientConfiguration configuration2 = new HttpClientConfiguration.Builder().build();
final HttpClient client1 = adapter.getClient(strategy, configuration1);
final HttpClient client2 = adapter.getClient(strategy, configuration2);
assertThat(client1).isSameAs(client2);
}
use of com.github.mjeanroy.junit.servers.client.HttpClient in project junit-servers by mjeanroy.
the class EmbeddedServerRunnerTest method it_should_get_client_and_do_not_return_previous_one_with_different_configuration.
@Test
public void it_should_get_client_and_do_not_return_previous_one_with_different_configuration() {
final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
final EmbeddedServerRunner adapter = new EmbeddedServerRunner(server);
final HttpClientConfiguration configuration1 = new HttpClientConfiguration.Builder().build();
final HttpClientConfiguration configuration2 = new HttpClientConfiguration.Builder().disableFollowRedirect().build();
final HttpClient client1 = adapter.getClient(configuration1);
final HttpClient client2 = adapter.getClient(configuration2);
assertThat(client1).isNotSameAs(client2);
assertThat(client1.getConfiguration()).isSameAs(configuration1);
assertThat(client2.getConfiguration()).isSameAs(configuration2);
}
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_super_class.
@Test
void it_should_set_client_instance_on_super_class() {
final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
final TestInheritedClassWithAnnotatedField target = new TestInheritedClassWithAnnotatedField();
final Field field = extractClientField(TestInheritedClassWithAnnotatedField.class);
final AnnotationHandler handler = newHttpClientAnnotationHandler(server);
final HttpClient client = verifyBeforeTest(target, field, handler);
verifyAfterTest(target, field, handler, client);
}
Aggregations