Search in sources :

Example 1 with EmbeddedJettyMockBuilder

use of com.github.mjeanroy.junit.servers.jetty.tests.EmbeddedJettyMockBuilder in project junit-servers by mjeanroy.

the class JettyServerJunit4RuleTest method it_should_create_rule_with_server.

@Test
void it_should_create_rule_with_server() throws Throwable {
    final EmbeddedJettyConfiguration config = new EmbeddedJettyConfigurationMockBuilder().build();
    final EmbeddedJetty jetty = new EmbeddedJettyMockBuilder().withConfiguration(config).build();
    final JettyServerJunit4Rule rule = createRule(jetty);
    assertThat(rule.getServer()).isSameAs(jetty);
    assertThat(rule.getScheme()).isEqualTo(jetty.getScheme());
    assertThat(rule.getHost()).isEqualTo(jetty.getHost());
    assertThat(rule.getPort()).isEqualTo(jetty.getPort());
    assertThat(rule.getPath()).isEqualTo(jetty.getPath());
    assertThat(rule.getUrl()).isEqualTo(jetty.getUrl());
    verify(jetty, never()).start();
    verify(jetty, never()).stop();
    evaluateRule(rule);
    InOrder inOrder = Mockito.inOrder(jetty);
    inOrder.verify(jetty).start();
    inOrder.verify(jetty).stop();
}
Also used : EmbeddedJettyConfigurationMockBuilder(com.github.mjeanroy.junit.servers.jetty.tests.EmbeddedJettyConfigurationMockBuilder) EmbeddedJetty(com.github.mjeanroy.junit.servers.jetty.EmbeddedJetty) InOrder(org.mockito.InOrder) EmbeddedJettyMockBuilder(com.github.mjeanroy.junit.servers.jetty.tests.EmbeddedJettyMockBuilder) EmbeddedJettyConfiguration(com.github.mjeanroy.junit.servers.jetty.EmbeddedJettyConfiguration) Test(org.junit.jupiter.api.Test)

Example 2 with EmbeddedJettyMockBuilder

use of com.github.mjeanroy.junit.servers.jetty.tests.EmbeddedJettyMockBuilder 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

EmbeddedJetty (com.github.mjeanroy.junit.servers.jetty.EmbeddedJetty)2 EmbeddedJettyMockBuilder (com.github.mjeanroy.junit.servers.jetty.tests.EmbeddedJettyMockBuilder)2 Test (org.junit.jupiter.api.Test)2 EmbeddedServerRunner (com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner)1 EmbeddedJettyConfiguration (com.github.mjeanroy.junit.servers.jetty.EmbeddedJettyConfiguration)1 EmbeddedJettyConfigurationMockBuilder (com.github.mjeanroy.junit.servers.jetty.tests.EmbeddedJettyConfigurationMockBuilder)1 InOrder (org.mockito.InOrder)1