Search in sources :

Example 1 with EmbeddedServerRunner

use of com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner in project junit-servers by mjeanroy.

the class HttpClientParameterResolverFunctionTest method setUp.

@BeforeEach
void setUp() {
    resolver = HttpClientParameterResolverFunction.getInstance();
    adapter = new EmbeddedServerRunner(new EmbeddedServerMockBuilder().build());
}
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 2 with EmbeddedServerRunner

use of com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner in project junit-servers by mjeanroy.

the class JettyServerExtensionTest method it_should_start_server_with_default_configuration_before_all_tests.

@Test
void it_should_start_server_with_default_configuration_before_all_tests() {
    final JettyServerExtension extension = new JettyServerExtension();
    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()).isNotNull().isExactlyInstanceOf(EmbeddedJetty.class);
    assertThat(serverAdapter.getServer().isStarted()).isTrue();
}
Also used : EmbeddedServerRunner(com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner) Test(org.junit.jupiter.api.Test)

Example 3 with EmbeddedServerRunner

use of com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner in project junit-servers by mjeanroy.

the class JettyServerExtensionTest method it_should_start_jetty_server_using_given_configuration_before_all_tests.

@Test
void it_should_start_jetty_server_using_given_configuration_before_all_tests() {
    final EmbeddedJettyConfiguration configuration = EmbeddedJettyConfiguration.defaultConfiguration();
    final JettyServerExtension extension = new JettyServerExtension(configuration);
    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()).isNotNull().isExactlyInstanceOf(EmbeddedJetty.class);
    assertThat(serverAdapter.getServer().getConfiguration()).isSameAs(configuration);
    assertThat(serverAdapter.getServer().isStarted()).isTrue();
}
Also used : EmbeddedServerRunner(com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner) EmbeddedJettyConfiguration(com.github.mjeanroy.junit.servers.jetty.EmbeddedJettyConfiguration) Test(org.junit.jupiter.api.Test)

Example 4 with EmbeddedServerRunner

use of com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner in project junit-servers by mjeanroy.

the class JunitServerExtensionTest method it_should_inject_annotated_field_before_each_test.

@Test
void it_should_inject_annotated_field_before_each_test() {
    final JunitServerExtension extension = new JunitServerExtension();
    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);
    extension.beforeEach(context);
    final AnnotationsHandlerRunner annotationsAdapter = store.get("annotationsAdapter", AnnotationsHandlerRunner.class);
    assertThat(annotationsAdapter).isNotNull();
    assertThat(testInstance.server).isNotNull().isSameAs(serverAdapter.getServer());
    assertThat(testInstance.configuration).isNotNull().isSameAs(serverAdapter.getServer().getConfiguration());
    assertThat(testInstance.client).isNotNull();
}
Also used : FixtureClass(com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass) EmbeddedServerRunner(com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner) AnnotationsHandlerRunner(com.github.mjeanroy.junit.servers.engine.AnnotationsHandlerRunner) Test(org.junit.jupiter.api.Test)

Example 5 with EmbeddedServerRunner

use of com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner in project junit-servers by mjeanroy.

the class TomcatServerExtensionTest method it_should_start_given_tomcat_server_before_all_tests.

@Test
void it_should_start_given_tomcat_server_before_all_tests() {
    final EmbeddedTomcat tomcat = new EmbeddedTomcatMockBuilder().build();
    final TomcatServerExtension extension = new TomcatServerExtension(tomcat);
    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(tomcat);
    assertThat(serverAdapter.getServer().isStarted()).isTrue();
}
Also used : EmbeddedServerRunner(com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner) EmbeddedTomcat(com.github.mjeanroy.junit.servers.tomcat.EmbeddedTomcat) EmbeddedTomcatMockBuilder(com.github.mjeanroy.junit.servers.tomcat.tests.builders.EmbeddedTomcatMockBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

EmbeddedServerRunner (com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner)23 Test (org.junit.jupiter.api.Test)16 FixtureClass (com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass)10 EmbeddedServerMockBuilder (com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 AnnotationsHandlerRunner (com.github.mjeanroy.junit.servers.engine.AnnotationsHandlerRunner)2 AbstractConfiguration (com.github.mjeanroy.junit.servers.servers.AbstractConfiguration)2 ParameterContext (org.junit.jupiter.api.extension.ParameterContext)2 EmbeddedJetty (com.github.mjeanroy.junit.servers.jetty.EmbeddedJetty)1 EmbeddedJettyConfiguration (com.github.mjeanroy.junit.servers.jetty.EmbeddedJettyConfiguration)1 EmbeddedJettyMockBuilder (com.github.mjeanroy.junit.servers.jetty.tests.EmbeddedJettyMockBuilder)1 EmbeddedTomcat (com.github.mjeanroy.junit.servers.tomcat.EmbeddedTomcat)1 EmbeddedTomcatConfiguration (com.github.mjeanroy.junit.servers.tomcat.EmbeddedTomcatConfiguration)1 EmbeddedTomcatMockBuilder (com.github.mjeanroy.junit.servers.tomcat.tests.builders.EmbeddedTomcatMockBuilder)1 FakeEmbeddedServerConfiguration (com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfiguration)1 Parameter (java.lang.reflect.Parameter)1