Search in sources :

Example 11 with FakeEmbeddedServerConfigurationBuilder

use of com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfigurationBuilder in project junit-servers by mjeanroy.

the class AbstractEmbeddedServerTest method it_should_set_environment_properties.

@Test
void it_should_set_environment_properties() {
    final String name1 = "foo";
    final String oldValue1 = "foo";
    final String newValue1 = "bar";
    System.setProperty(name1, oldValue1);
    final String name2 = "foo1";
    final String newValue2 = "bar1";
    final FakeEmbeddedServerConfiguration configuration = new FakeEmbeddedServerConfigurationBuilder().withProperty(name1, newValue1).withProperty(name2, newValue2).build();
    server = new FakeEmbeddedServer(configuration);
    server.start();
    assertThat(System.getProperty(name1)).isEqualTo(newValue1);
    assertThat(System.getProperty(name2)).isEqualTo(newValue2);
    server.stop();
    assertThat(System.getProperty(name1)).isEqualTo(oldValue1);
    assertThat(System.getProperty(name2)).isNull();
    System.clearProperty(name1);
    System.clearProperty(name2);
}
Also used : FakeEmbeddedServerConfiguration(com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfiguration) FakeEmbeddedServerConfigurationBuilder(com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfigurationBuilder) FakeEmbeddedServer(com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServer) Test(org.junit.jupiter.api.Test)

Example 12 with FakeEmbeddedServerConfigurationBuilder

use of com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfigurationBuilder in project junit-servers by mjeanroy.

the class AbstractEmbeddedServerTest method it_should_get_original_server_implementation.

@Test
void it_should_get_original_server_implementation() {
    final FakeEmbeddedServerConfiguration configuration = new FakeEmbeddedServerConfigurationBuilder().withPath("foo").build();
    final FakeEmbeddedServer server = new FakeEmbeddedServer(configuration);
    final FakeServer delegate = server.getDelegate();
    assertThat(delegate).isNotNull();
}
Also used : FakeServer(com.github.mjeanroy.junit.servers.utils.impl.FakeServer) FakeEmbeddedServerConfiguration(com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfiguration) FakeEmbeddedServerConfigurationBuilder(com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfigurationBuilder) FakeEmbeddedServer(com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServer) Test(org.junit.jupiter.api.Test)

Aggregations

FakeEmbeddedServerConfigurationBuilder (com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfigurationBuilder)12 Test (org.junit.jupiter.api.Test)12 FakeEmbeddedServer (com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServer)9 FakeEmbeddedServerConfiguration (com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfiguration)9 FakeServer (com.github.mjeanroy.junit.servers.utils.impl.FakeServer)2 FakeWorker.startWorker (com.github.mjeanroy.junit.servers.servers.FakeWorker.startWorker)1 FakeWorker.stopWorker (com.github.mjeanroy.junit.servers.servers.FakeWorker.stopWorker)1 TestUtils.localUrl (com.github.mjeanroy.junit.servers.utils.commons.TestUtils.localUrl)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.never (org.mockito.Mockito.never)1 Mockito.spy (org.mockito.Mockito.spy)1 Mockito.times (org.mockito.Mockito.times)1 Mockito.verify (org.mockito.Mockito.verify)1 Answer (org.mockito.stubbing.Answer)1