Search in sources :

Example 11 with AbstractConfiguration

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

the class ConfigurationAnnotationHandlerTest method it_should_support_server_annotation.

@Test
void it_should_support_server_annotation() {
    final AbstractConfiguration configuration = new AbstractConfigurationMockBuilder().build();
    final AnnotationHandler handler = newConfigurationAnnotationHandler(configuration);
    final Field field = extractConfigurationField();
    final Annotation annotation = readAnnotation(field);
    assertThat(handler.support(annotation)).isTrue();
}
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) Annotation(java.lang.annotation.Annotation) Test(org.junit.jupiter.api.Test)

Example 12 with AbstractConfiguration

use of com.github.mjeanroy.junit.servers.servers.AbstractConfiguration 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();
}
Also used : AbstractConfiguration(com.github.mjeanroy.junit.servers.servers.AbstractConfiguration) FixtureClass(com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass) EmbeddedServerRunner(com.github.mjeanroy.junit.servers.engine.EmbeddedServerRunner) FakeEmbeddedServerConfiguration(com.github.mjeanroy.junit.servers.utils.impl.FakeEmbeddedServerConfiguration) Test(org.junit.jupiter.api.Test)

Example 13 with AbstractConfiguration

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

the class ServersTest method it_should_return_null_without_configuration_field.

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

Example 14 with AbstractConfiguration

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

the class AnnotationsHandlerRuleTest method it_should_implement_to_string.

@Test
void it_should_implement_to_string() {
    final AbstractConfiguration configuration = new AbstractConfigurationMockBuilder().build();
    final EmbeddedServer<?> embeddedServer = new EmbeddedServerMockBuilder().build();
    final FixtureClass target = new FixtureClass();
    final AnnotationsHandlerRule rule = new AnnotationsHandlerRule(target, embeddedServer, configuration);
    assertThat(rule).hasToString("AnnotationsHandlerRule{" + "target: FixtureClass, " + "annotationHandlers: AnnotationsHandlerRunner{" + "handlers: [" + "ServerAnnotationHandler{" + "annotationKlass: interface com.github.mjeanroy.junit.servers.annotations.TestServer, " + "server: MockEmbeddedServer" + "}, " + "ConfigurationAnnotationHandler{" + "annotationKlass: interface com.github.mjeanroy.junit.servers.annotations.TestServerConfiguration, " + "configuration: MockAbstractConfiguration" + "}, " + "HttpClientAnnotationHandler{" + "annotationKlass: interface com.github.mjeanroy.junit.servers.annotations.TestHttpClient, " + "server: MockEmbeddedServer" + "}" + "]" + "}" + "}");
}
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 15 with AbstractConfiguration

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

the class AnnotationsHandlerRuleTest 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 AnnotationsHandlerRule rule = new AnnotationsHandlerRule(target, embeddedServer, configuration);
    verifyBeforeTest(configuration, embeddedServer, target, rule);
    verifyAfterTest(configuration, embeddedServer, target, rule);
}
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)

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