use of com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfigurationBuilder 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.FakeEmbeddedServerConfigurationBuilder in project junit-servers by mjeanroy.
the class AbstractEmbeddedServerTest method it_should_get_url_with_custom_path.
@Test
void it_should_get_url_with_custom_path() {
final FakeEmbeddedServer server = new FakeEmbeddedServer(new FakeEmbeddedServerConfigurationBuilder().withPath("/foo").build());
assertThat(server.getUrl()).isEqualTo(localUrl(server.getPort(), "/foo"));
}
use of com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfigurationBuilder in project junit-servers by mjeanroy.
the class AbstractEmbeddedServerTest method it_should_execute_hook_before_doStop.
@Test
void it_should_execute_hook_before_doStop() {
final Hook hook = mock(Hook.class);
final FakeEmbeddedServerConfiguration configuration = new FakeEmbeddedServerConfigurationBuilder().withHook(hook).build();
final Answer<Object> ensureIsStillStartedAnswer = invocation -> {
FakeEmbeddedServer server = invocation.getArgument(0);
assertThat(server).isNotNull();
assertThat(server.getNbStop()).isZero();
return null;
};
doAnswer(ensureIsStillStartedAnswer).when(hook).post(any(EmbeddedServer.class));
server = spy(new FakeEmbeddedServer(configuration));
server.start();
assertThat(server.isStarted()).isTrue();
verify(hook, never()).post(any(EmbeddedServer.class));
server.stop();
assertThat(server.isStarted()).isFalse();
assertThat(server.getNbStop()).isEqualTo(1);
}
use of com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfigurationBuilder in project junit-servers by mjeanroy.
the class AbstractEmbeddedServerTest method it_should_have_custom_configuration.
@Test
void it_should_have_custom_configuration() {
final String path = "/foo";
final int port = 8080;
final String webapp = "/foo/bar";
final FakeEmbeddedServerConfiguration configuration = new FakeEmbeddedServerConfigurationBuilder().withPath(path).withPort(port).withWebapp(webapp).build();
server = new FakeEmbeddedServer(configuration);
assertThat(server.getConfiguration()).isSameAs(configuration);
}
use of com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfigurationBuilder in project junit-servers by mjeanroy.
the class ServerRuleTest 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 ServerRule rule = createRule(configuration);
final EmbeddedServer<?> server = rule.getServer();
assertThat(server).isNotNull().isExactlyInstanceOf(FakeEmbeddedServer.class);
assertThat(server.getConfiguration()).isSameAs(configuration);
}
Aggregations