Search in sources :

Example 1 with EmbeddedTomcatMockBuilder

use of com.github.mjeanroy.junit.servers.tomcat.tests.builders.EmbeddedTomcatMockBuilder 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)

Example 2 with EmbeddedTomcatMockBuilder

use of com.github.mjeanroy.junit.servers.tomcat.tests.builders.EmbeddedTomcatMockBuilder in project junit-servers by mjeanroy.

the class TomcatServerJunit4RuleTest method it_should_create_rule_with_server.

@Test
void it_should_create_rule_with_server() throws Throwable {
    final EmbeddedTomcatConfiguration config = mock(EmbeddedTomcatConfiguration.class);
    final EmbeddedTomcat tomcat = new EmbeddedTomcatMockBuilder().withConfiguration(config).build();
    final TomcatServerJunit4Rule rule = createRule(tomcat);
    assertThat(rule.getServer()).isSameAs(tomcat);
    assertThat(rule.getScheme()).isEqualTo(tomcat.getScheme());
    assertThat(rule.getHost()).isEqualTo(tomcat.getHost());
    assertThat(rule.getPort()).isEqualTo(tomcat.getPort());
    assertThat(rule.getPath()).isEqualTo(tomcat.getPath());
    assertThat(rule.getUrl()).isEqualTo(tomcat.getUrl());
    verify(tomcat, never()).start();
    verify(tomcat, never()).stop();
    evaluateRule(rule);
    InOrder inOrder = inOrder(tomcat);
    inOrder.verify(tomcat).start();
    inOrder.verify(tomcat).stop();
}
Also used : InOrder(org.mockito.InOrder) EmbeddedTomcat(com.github.mjeanroy.junit.servers.tomcat.EmbeddedTomcat) EmbeddedTomcatConfiguration(com.github.mjeanroy.junit.servers.tomcat.EmbeddedTomcatConfiguration) EmbeddedTomcatMockBuilder(com.github.mjeanroy.junit.servers.tomcat.tests.builders.EmbeddedTomcatMockBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

EmbeddedTomcat (com.github.mjeanroy.junit.servers.tomcat.EmbeddedTomcat)2 EmbeddedTomcatMockBuilder (com.github.mjeanroy.junit.servers.tomcat.tests.builders.EmbeddedTomcatMockBuilder)2 Test (org.junit.jupiter.api.Test)2 EmbeddedServerRunner (com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner)1 EmbeddedTomcatConfiguration (com.github.mjeanroy.junit.servers.tomcat.EmbeddedTomcatConfiguration)1 InOrder (org.mockito.InOrder)1