Search in sources :

Example 1 with AbstractConfiguration

use of com.github.mjeanroy.junit.servers.servers.AbstractConfiguration in project junit-servers by mjeanroy.

the class ConfigurationAnnotationHandlerTest method it_should_set_configuration_instance.

@Test
void it_should_set_configuration_instance() {
    final AbstractConfiguration configuration = new AbstractConfigurationMockBuilder().build();
    final TestClassWithAnnotatedField target = new TestClassWithAnnotatedField();
    final Field field = extractConfigurationField();
    final AnnotationHandler handler = newConfigurationAnnotationHandler(configuration);
    verifyBeforeTest(configuration, target, field, handler);
}
Also used : AbstractConfiguration(com.github.mjeanroy.junit.servers.servers.AbstractConfiguration) Field(java.lang.reflect.Field) Fields.getPrivateField(com.github.mjeanroy.junit.servers.utils.commons.Fields.getPrivateField) AbstractConfigurationMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder) ConfigurationAnnotationHandler.newConfigurationAnnotationHandler(com.github.mjeanroy.junit.servers.engine.ConfigurationAnnotationHandler.newConfigurationAnnotationHandler) Test(org.junit.jupiter.api.Test)

Example 2 with AbstractConfiguration

use of com.github.mjeanroy.junit.servers.servers.AbstractConfiguration in project junit-servers by mjeanroy.

the class ConfigurationAnnotationHandlerTest method it_should_implement_to_string.

@Test
void it_should_implement_to_string() {
    final AbstractConfiguration configuration = new AbstractConfigurationMockBuilder().build();
    final AnnotationHandler handler = newConfigurationAnnotationHandler(configuration);
    assertThat(handler).hasToString("ConfigurationAnnotationHandler{" + "annotationKlass: interface com.github.mjeanroy.junit.servers.annotations.TestServerConfiguration, " + "configuration: MockAbstractConfiguration" + "}");
}
Also used : AbstractConfiguration(com.github.mjeanroy.junit.servers.servers.AbstractConfiguration) AbstractConfigurationMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder) ConfigurationAnnotationHandler.newConfigurationAnnotationHandler(com.github.mjeanroy.junit.servers.engine.ConfigurationAnnotationHandler.newConfigurationAnnotationHandler) Test(org.junit.jupiter.api.Test)

Example 3 with AbstractConfiguration

use of com.github.mjeanroy.junit.servers.servers.AbstractConfiguration in project junit-servers by mjeanroy.

the class AnnotationsHandlerRunnerTest method it_should_process_handlers.

@Test
void it_should_process_handlers() {
    final AbstractConfiguration configuration = new AbstractConfigurationMockBuilder().build();
    final EmbeddedServer<?> embeddedServer = new EmbeddedServerMockBuilder().build();
    final FixtureClass target = new FixtureClass();
    final AnnotationsHandlerRunner adapter = new AnnotationsHandlerRunner(embeddedServer, configuration);
    verifyBeforeTest(configuration, embeddedServer, target, adapter);
    verifyAfterTest(configuration, embeddedServer, target, adapter);
}
Also used : AbstractConfiguration(com.github.mjeanroy.junit.servers.servers.AbstractConfiguration) AbstractConfigurationMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder) FixtureClass(com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass) EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with AbstractConfiguration

use of com.github.mjeanroy.junit.servers.servers.AbstractConfiguration in project junit-servers by mjeanroy.

the class ServersTest method it_should_return_configuration_as_result_of_method.

@Test
void it_should_return_configuration_as_result_of_method() {
    final AbstractConfiguration configuration = Servers.findConfiguration(FixtureClassWithConfigurationAsMethod.class);
    assertThat(configuration).isNotNull();
}
Also used : AbstractConfiguration(com.github.mjeanroy.junit.servers.servers.AbstractConfiguration) Test(org.junit.jupiter.api.Test)

Example 5 with AbstractConfiguration

use of com.github.mjeanroy.junit.servers.servers.AbstractConfiguration in project junit-servers by mjeanroy.

the class JettyServerJunit4RunnerTest method it_should_instantiate_jetty_with_default_configuration.

@Test
void it_should_instantiate_jetty_with_default_configuration() throws Exception {
    final JettyServerJunit4Runner runner = createRunner(TestClassWithConfiguration.class);
    final EmbeddedServer<?> server = (EmbeddedServer<?>) readField(runner, "server", true);
    final AbstractConfiguration conf = (AbstractConfiguration) readField(runner, "configuration", true);
    assertThat(server).isInstanceOf(EmbeddedJetty.class);
    assertThat(conf).isInstanceOf(EmbeddedJettyConfiguration.class).isNotSameAs(configuration);
}
Also used : AbstractConfiguration(com.github.mjeanroy.junit.servers.servers.AbstractConfiguration) EmbeddedServer(com.github.mjeanroy.junit.servers.servers.EmbeddedServer) EmbeddedJettyConfiguration(com.github.mjeanroy.junit.servers.jetty.EmbeddedJettyConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

AbstractConfiguration (com.github.mjeanroy.junit.servers.servers.AbstractConfiguration)19 Test (org.junit.jupiter.api.Test)18 EmbeddedServer (com.github.mjeanroy.junit.servers.servers.EmbeddedServer)8 AbstractConfigurationMockBuilder (com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder)7 EmbeddedServerMockBuilder (com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder)4 FixtureClass (com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass)4 ConfigurationAnnotationHandler.newConfigurationAnnotationHandler (com.github.mjeanroy.junit.servers.engine.ConfigurationAnnotationHandler.newConfigurationAnnotationHandler)3 EmbeddedServerRunner (com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner)2 EmbeddedJettyConfiguration (com.github.mjeanroy.junit.servers.jetty.EmbeddedJettyConfiguration)2 EmbeddedTomcatConfiguration (com.github.mjeanroy.junit.servers.tomcat.EmbeddedTomcatConfiguration)2 Fields.getPrivateField (com.github.mjeanroy.junit.servers.utils.commons.Fields.getPrivateField)2 Field (java.lang.reflect.Field)2 AnnotationsHandlerRunner (com.github.mjeanroy.junit.servers.engine.AnnotationsHandlerRunner)1 FakeEmbeddedServerConfiguration (com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfiguration)1 Annotation (java.lang.annotation.Annotation)1