Search in sources :

Example 21 with EmbeddedServerRunner

use of com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner 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 22 with EmbeddedServerRunner

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

the class JunitServerExtensionTest method it_should_stop_server_after_all_tests.

@Test
void it_should_stop_server_after_all_tests() {
    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.afterAll(context);
    assertThat(store.isEmpty()).isTrue();
    assertThat(serverAdapter.getServer().isStarted()).isFalse();
}
Also used : FixtureClass(com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass) EmbeddedServerRunner(com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner) Test(org.junit.jupiter.api.Test)

Example 23 with EmbeddedServerRunner

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

the class JettyServerExtensionTest method it_should_start_given_jetty_server_before_all_tests.

@Test
void it_should_start_given_jetty_server_before_all_tests() {
    final EmbeddedJetty jetty = new EmbeddedJettyMockBuilder().build();
    final JettyServerExtension extension = new JettyServerExtension(jetty);
    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(jetty);
    assertThat(serverAdapter.getServer().isStarted()).isTrue();
}
Also used : EmbeddedJetty(com.github.mjeanroy.junit.servers.jetty.EmbeddedJetty) EmbeddedServerRunner(com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner) EmbeddedJettyMockBuilder(com.github.mjeanroy.junit.servers.jetty.tests.EmbeddedJettyMockBuilder) 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