use of com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass 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);
}
use of com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass in project junit-servers by mjeanroy.
the class JunitServerExtensionTest method it_should_resolve_http_client_parameter_with_custom_strategy.
@Test
void it_should_resolve_http_client_parameter_with_custom_strategy() throws Exception {
final FixtureClass testInstance = new FixtureClass();
final FakeExtensionContext context = new FakeExtensionContext(testInstance);
final JunitServerExtension extension = initializeExtension(context);
final ParameterContext parameterContext = createParameterContext("method_http_client_custom", HttpClient.class);
final Object result = extension.resolveParameter(parameterContext, context);
assertThat(result).isNotNull().isExactlyInstanceOf(NingAsyncHttpClient.class);
}
use of com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass in project junit-servers by mjeanroy.
the class JunitServerExtensionTest method verifySupportsParameter.
private void verifySupportsParameter(String methodName, Class<?> klass) throws Exception {
final JunitServerExtension extension = new JunitServerExtension();
final FixtureClass testInstance = new FixtureClass();
final FakeExtensionContext context = new FakeExtensionContext(testInstance);
extension.beforeAll(context);
final Method method = getClass().getMethod(methodName, klass);
final Parameter parameter = method.getParameters()[0];
final ParameterContext parameterContext = new FakeParameterContext(parameter);
assertThat(extension.supportsParameter(parameterContext, context)).isTrue();
}
use of com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass in project junit-servers by mjeanroy.
the class JunitServerExtensionTest method it_should_inject_annotated_field_before_each_test.
@Test
void it_should_inject_annotated_field_before_each_test() {
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);
extension.beforeEach(context);
final AnnotationsHandlerRunner annotationsAdapter = store.get("annotationsAdapter", AnnotationsHandlerRunner.class);
assertThat(annotationsAdapter).isNotNull();
assertThat(testInstance.server).isNotNull().isSameAs(serverAdapter.getServer());
assertThat(testInstance.configuration).isNotNull().isSameAs(serverAdapter.getServer().getConfiguration());
assertThat(testInstance.client).isNotNull();
}
use of com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass in project junit-servers by mjeanroy.
the class JunitServerExtensionTest method it_should_resolve_http_client_parameter_with_auto_strategy.
@Test
void it_should_resolve_http_client_parameter_with_auto_strategy() throws Exception {
final FixtureClass testInstance = new FixtureClass();
final FakeExtensionContext context = new FakeExtensionContext(testInstance);
final JunitServerExtension extension = initializeExtension(context);
final ParameterContext parameterContext = createParameterContext("method_http_client", HttpClient.class);
final Object result = extension.resolveParameter(parameterContext, context);
assertThat(result).isNotNull().isInstanceOf(HttpClient.class);
}
Aggregations