Search in sources :

Example 51 with EmbeddedServerMockBuilder

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

the class ConfigurationParameterResolverFunctionTest method setUp.

@BeforeEach
void setUp() {
    resolver = ConfigurationResolverFunction.getInstance();
    server = new EmbeddedServerMockBuilder().build();
    adapter = new EmbeddedServerRunner(server);
}
Also used : EmbeddedServerRunner(com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner) EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 52 with EmbeddedServerMockBuilder

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

the class EmbeddedServerParameterResolverFunctionTest method setUp.

@BeforeEach
void setUp() {
    resolver = EmbeddedServerParameterResolverFunction.getInstance();
    server = new EmbeddedServerMockBuilder().build();
    adapter = new EmbeddedServerRunner(server);
}
Also used : EmbeddedServerRunner(com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner) EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 53 with EmbeddedServerMockBuilder

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

the class JunitServerExtensionTest method it_should_initialize_extension_with_given_server_and_start_given_server_before_all_tests.

@Test
void it_should_initialize_extension_with_given_server_and_start_given_server_before_all_tests() {
    final EmbeddedServer<?> server = new EmbeddedServerMockBuilder().build();
    final JunitServerExtension extension = new JunitServerExtension(server);
    final FixtureClass testInstance = new FixtureClass();
    final FakeExtensionContext context = new FakeExtensionContext(testInstance);
    extension.beforeAll(context);
    final FakeStore store = context.getSingleStore();
    final EmbeddedServerRunner serverAdapter = store.get("serverAdapter", EmbeddedServerRunner.class);
    assertThat(serverAdapter).isNotNull();
    assertThat(serverAdapter.getServer()).isSameAs(server);
    assertThat(serverAdapter.getServer().isStarted()).isTrue();
}
Also used : FixtureClass(com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass) EmbeddedServerRunner(com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner) EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) Test(org.junit.jupiter.api.Test)

Example 54 with EmbeddedServerMockBuilder

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

the class NingAsyncHttpClientTest 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 AsyncHttpClient internalClient = readPrivate(client, "client");
    assertThat(client).hasToString("NingAsyncHttpClient{" + "configuration: HttpClientConfiguration{" + "followRedirect: true, " + "defaultHeaders: {}, " + "defaultCookies: []" + "}, " + "server: MockEmbeddedServer, " + "client: " + internalClient.toString() + "}");
}
Also used : NingAsyncHttpClient.defaultAsyncHttpClient(com.github.mjeanroy.junit.servers.client.impl.ning.NingAsyncHttpClient.defaultAsyncHttpClient) AsyncHttpClient(com.ning.http.client.AsyncHttpClient) HttpClient(com.github.mjeanroy.junit.servers.client.HttpClient) NingAsyncHttpClient.newAsyncHttpClient(com.github.mjeanroy.junit.servers.client.impl.ning.NingAsyncHttpClient.newAsyncHttpClient) EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) NingAsyncHttpClient.defaultAsyncHttpClient(com.github.mjeanroy.junit.servers.client.impl.ning.NingAsyncHttpClient.defaultAsyncHttpClient) AsyncHttpClient(com.ning.http.client.AsyncHttpClient) NingAsyncHttpClient.newAsyncHttpClient(com.github.mjeanroy.junit.servers.client.impl.ning.NingAsyncHttpClient.newAsyncHttpClient) Test(org.junit.jupiter.api.Test) BaseHttpClientTest(com.github.mjeanroy.junit.servers.client.impl.BaseHttpClientTest)

Example 55 with EmbeddedServerMockBuilder

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

the class ApacheHttpClientTest 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 CloseableHttpClient internalClient = readPrivate(client, "client");
    assertThat(client).hasToString("ApacheHttpClient{" + "configuration: HttpClientConfiguration{" + "followRedirect: true, " + "defaultHeaders: {}, " + "defaultCookies: []" + "}, " + "server: MockEmbeddedServer, " + "client: " + internalClient.toString() + ", " + "destroyed: false" + "}");
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) ApacheHttpClient.defaultApacheHttpClient(com.github.mjeanroy.junit.servers.client.impl.apache.ApacheHttpClient.defaultApacheHttpClient) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) ApacheHttpClient.newApacheHttpClient(com.github.mjeanroy.junit.servers.client.impl.apache.ApacheHttpClient.newApacheHttpClient) HttpClient(com.github.mjeanroy.junit.servers.client.HttpClient) EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) Test(org.junit.jupiter.api.Test) BaseHttpClientTest(com.github.mjeanroy.junit.servers.client.impl.BaseHttpClientTest)

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