use of com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass in project junit-servers by mjeanroy.
the class JunitServerExtensionTest method it_should_reset_injected_http_client_after_each_test.
@Test
void it_should_reset_injected_http_client_after_each_test() {
final JunitServerExtension extension = new JunitServerExtension();
final FixtureClass testInstance = new FixtureClass();
final FakeExtensionContext context = new FakeExtensionContext(testInstance);
extension.beforeAll(context);
extension.beforeEach(context);
final HttpClient client = testInstance.client;
final FakeStore store = context.getSingleStore();
extension.afterEach(context);
assertThat(store.get("annotationsAdapter")).isNull();
assertThat(testInstance.client).isNull();
assertThat(client.isDestroyed()).isTrue();
}
use of com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass in project junit-servers by mjeanroy.
the class JunitServerExtensionTest method it_should_start_server_before_all_tests.
@Test
void it_should_start_server_before_all_tests() {
final JunitServerExtension extension = new JunitServerExtension();
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();
assertThat(serverAdapter.getServer().isStarted()).isTrue();
}
use of com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass 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" + "}" + "]" + "}" + "}");
}
use of com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass 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);
}
use of com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass in project junit-servers by mjeanroy.
the class JunitServerExtensionTest method it_should_resolve_configuration_parameter.
@Test
void it_should_resolve_configuration_parameter() throws Exception {
final FixtureClass testInstance = new FixtureClass();
final FakeExtensionContext context = new FakeExtensionContext(testInstance);
final JunitServerExtension extension = initializeExtension(context);
final FakeStore store = context.getSingleStore();
final EmbeddedServerRunner serverAdapter = store.get("serverAdapter", EmbeddedServerRunner.class);
final ParameterContext parameterContext = createParameterContext("method_configuration", AbstractConfiguration.class);
final Object result = extension.resolveParameter(parameterContext, context);
assertThat(result).isNotNull().isSameAs(serverAdapter.getServer().getConfiguration());
}
Aggregations