Search in sources :

Example 46 with EmbeddedServerMockBuilder

use of com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder in project junit-servers by mjeanroy.

the class AnnotationsHandlerRuleTest method it_should_process_handlers.

@Test
void it_should_process_handlers() {
    final AbstractConfiguration configuration = new AbstractConfigurationMockBuilder().build();
    final EmbeddedServer<?> embeddedServer = new EmbeddedServerMockBuilder().build();
    final FixtureClass target = new FixtureClass();
    final AnnotationsHandlerRule rule = new AnnotationsHandlerRule(target, embeddedServer, configuration);
    verifyBeforeTest(configuration, embeddedServer, target, rule);
    verifyAfterTest(configuration, embeddedServer, target, rule);
}
Also used : AbstractConfiguration(com.github.mjeanroy.junit.servers.servers.AbstractConfiguration) AbstractConfigurationMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder) FixtureClass(com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass) EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) Test(org.junit.jupiter.api.Test)

Example 47 with EmbeddedServerMockBuilder

use of com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder in project junit-servers by mjeanroy.

the class ServerRuleTest method it_should_get_server_url.

@Test
void it_should_get_server_url() {
    final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().withScheme("http").withHost("localhost").withPort(8080).withPath("/").build();
    final ServerRule rule = createRule(server);
    final String result = rule.getUrl();
    assertThat(result).isEqualTo("http://localhost:8080/");
    verify(server).getUrl();
}
Also used : EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) Test(org.junit.jupiter.api.Test)

Example 48 with EmbeddedServerMockBuilder

use of com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder in project junit-servers by mjeanroy.

the class ServerRuleTest method it_should_restart_server.

@Test
void it_should_restart_server() {
    final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
    final ServerRule rule = createRule(server);
    rule.restart();
    verify(server).restart();
}
Also used : EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) Test(org.junit.jupiter.api.Test)

Example 49 with EmbeddedServerMockBuilder

use of com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder in project junit-servers by mjeanroy.

the class ServerRuleTest method it_should_get_new_http_client_if_it_has_been_destroyed.

@Test
void it_should_get_new_http_client_if_it_has_been_destroyed() {
    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();
    client.destroy();
    final HttpClient newClient = rule.getClient();
    assertThat(newClient).isNotNull();
    assertThat(newClient).isNotSameAs(client);
    assertThat(newClient.isDestroyed()).isFalse();
}
Also used : HttpClient(com.github.mjeanroy.junit.servers.client.HttpClient) EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) Test(org.junit.jupiter.api.Test)

Example 50 with EmbeddedServerMockBuilder

use of com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder in project junit-servers by mjeanroy.

the class ServerRuleTest method it_should_check_if_server_is_started.

@Test
void it_should_check_if_server_is_started() {
    final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
    final ServerRule rule = createRule(server);
    assertThat(rule.isStarted()).isFalse();
    rule.start();
    assertThat(rule.isStarted()).isTrue();
    verify(server, times(2)).isStarted();
}
Also used : EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

EmbeddedServerMockBuilder (com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder)56 Test (org.junit.jupiter.api.Test)52 HttpClient (com.github.mjeanroy.junit.servers.client.HttpClient)22 OkHttpClient (com.github.mjeanroy.junit.servers.client.impl.okhttp3.OkHttpClient)12 HttpClientConfiguration (com.github.mjeanroy.junit.servers.client.HttpClientConfiguration)6 HttpClientStrategy (com.github.mjeanroy.junit.servers.client.HttpClientStrategy)6 Field (java.lang.reflect.Field)6 HttpClientAnnotationHandler.newHttpClientAnnotationHandler (com.github.mjeanroy.junit.servers.engine.HttpClientAnnotationHandler.newHttpClientAnnotationHandler)5 BaseHttpClientTest (com.github.mjeanroy.junit.servers.client.impl.BaseHttpClientTest)4 EmbeddedServerRunner (com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner)4 AbstractConfiguration (com.github.mjeanroy.junit.servers.servers.AbstractConfiguration)4 AbstractConfigurationMockBuilder (com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder)4 FixtureClass (com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass)4 FakeEmbeddedServerConfigurationBuilder (com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfigurationBuilder)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 TestHttpClient (com.github.mjeanroy.junit.servers.annotations.TestHttpClient)3 ServerAnnotationHandler.newServerAnnotationHandler (com.github.mjeanroy.junit.servers.engine.ServerAnnotationHandler.newServerAnnotationHandler)3 Fields.getPrivateField (com.github.mjeanroy.junit.servers.utils.commons.Fields.getPrivateField)2 Annotation (java.lang.annotation.Annotation)2 ApacheHttpClient.defaultApacheHttpClient (com.github.mjeanroy.junit.servers.client.impl.apache.ApacheHttpClient.defaultApacheHttpClient)1