use of core.framework.test.inject.TestBeanFactory in project core-ng-project by neowu.
the class AbstractTestModule method configure.
public final void configure(TestBeanFactory beanFactory) {
logger.info("initialize test context");
context = new ModuleContext(beanFactory, new MockFactoryImpl());
logger.info("initialize application");
initialize();
context.config.validate();
((TestBeanFactory) context.beanFactory).validateOverrideBindings();
}
use of core.framework.test.inject.TestBeanFactory in project core-ng-project by neowu.
the class IntegrationExtension method postProcessTestInstance.
@Override
public void postProcessTestInstance(Object testInstance, ExtensionContext context) {
ExtensionContext.Store store = context.getRoot().getStore(ExtensionContext.Namespace.GLOBAL);
Class<?> testClass = context.getRequiredTestClass();
TestBeanFactory beanFactory = store.getOrComputeIfAbsent(TestBeanFactory.class, key -> createTestBeanFactory(testClass, store), TestBeanFactory.class);
beanFactory.inject(testInstance);
}
use of core.framework.test.inject.TestBeanFactory in project core-ng-project by neowu.
the class IntegrationExtension method createTestBeanFactory.
private TestBeanFactory createTestBeanFactory(Class<?> testClass, ExtensionContext.Store store) {
Boolean initialized = store.get(KEY_INITIALIZED, Boolean.class);
if (Boolean.TRUE.equals(initialized))
throw new Error("test context failed to initialize, please check error message from previous integration test");
store.put(KEY_INITIALIZED, true);
Context context = findContext(testClass);
TestBeanFactory beanFactory = new TestBeanFactory();
try {
AbstractTestModule module = context.module().getConstructor().newInstance();
module.configure(beanFactory);
} catch (ReflectiveOperationException e) {
throw new Error("failed to create test context", e);
}
return beanFactory;
}
Aggregations