use of com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfiguration in project junit-servers by mjeanroy.
the class ServersTest method it_should_instantiate_server_with_configuration.
@Test
void it_should_instantiate_server_with_configuration() {
final FakeEmbeddedServerConfiguration configuration = new FakeEmbeddedServerConfigurationBuilder().build();
final EmbeddedServer<?> server = Servers.instantiate(configuration);
assertThat(server).isNotNull().isExactlyInstanceOf(FakeEmbeddedServer.class);
assertThat(server.getConfiguration()).isNotNull().isSameAs(configuration);
}
use of com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfiguration in project junit-servers by mjeanroy.
the class AbstractEmbeddedServerTest method it_should_execute_hook.
@Test
void it_should_execute_hook() {
final Hook hook = mock(Hook.class);
final FakeEmbeddedServerConfiguration configuration = new FakeEmbeddedServerConfigurationBuilder().withHook(hook).build();
server = new FakeEmbeddedServer(configuration);
server.start();
verify(hook).pre(server);
verify(hook).onStarted(server, server.getServletContext());
verify(hook, never()).post(server);
server.stop();
verify(hook).post(server);
verify(hook, times(1)).pre(server);
verify(hook, times(1)).pre(server);
}
use of com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfiguration in project junit-servers by mjeanroy.
the class AbstractEmbeddedServerTest method it_should_get_url_and_do_not_encode_custom_path.
@Test
void it_should_get_url_and_do_not_encode_custom_path() {
final FakeEmbeddedServerConfiguration configuration = new FakeEmbeddedServerConfigurationBuilder().withPath("/foo bar").build();
final FakeEmbeddedServer server = new FakeEmbeddedServer(configuration);
final String url = server.getUrl();
assertThat(url).isEqualTo(localUrl(server.getPort(), "/foo bar"));
}
use of com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfiguration in project junit-servers by mjeanroy.
the class EmbeddedServerRunnerTest method it_should_instantiate_server_from_service_loader_with_custom_configuration.
@Test
void it_should_instantiate_server_from_service_loader_with_custom_configuration() {
final FakeEmbeddedServerConfiguration configuration = new FakeEmbeddedServerConfigurationBuilder().build();
final EmbeddedServerRunner adapter = new EmbeddedServerRunner(configuration);
final EmbeddedServer<?> server = adapter.getServer();
assertThat(server).isNotNull().isExactlyInstanceOf(FakeEmbeddedServer.class);
assertThat(server.getConfiguration()).isSameAs(configuration);
}
use of com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfiguration in project junit-servers by mjeanroy.
the class JunitServerExtensionTest method it_should_initialize_extension_with_given_configuration_and_start_given_server_before_all_tests.
@Test
void it_should_initialize_extension_with_given_configuration_and_start_given_server_before_all_tests() {
final AbstractConfiguration configuration = new FakeEmbeddedServerConfiguration();
final JunitServerExtension extension = new JunitServerExtension(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().isInstanceOf(FakeEmbeddedServer.class);
assertThat(serverAdapter.getServer().getConfiguration()).isSameAs(configuration);
assertThat(serverAdapter.getServer().isStarted()).isTrue();
}
Aggregations