protected void process(String data) throws Exception { IInjectorProvider delegate = getOrCreateInjectorProvider().getDelegate(); if (delegate instanceof IRegistryConfigurator) { IRegistryConfigurator registryConfigurator = (IRegistryConfigurator) delegate; registryConfigurator.setupRegistry(); try { ScenarioProcessor processor = delegate.getInjector().getInstance(processorClass); String preProcessed = processor.preProcess(data); if (preProcessed == null) { throw new AssumptionViolatedException("Input is filtered by the pre processing step: " + data); } doProcess(preProcessed, processor); } finally { registryConfigurator.restoreRegistry(); } } }
@Override public void beforeTestExecution(ExtensionContext context) throws Exception { IInjectorProvider injectorProvider = getOrCreateInjectorProvider(context); if (injectorProvider instanceof IRegistryConfigurator) { final IRegistryConfigurator registryConfigurator = (IRegistryConfigurator) injectorProvider; registryConfigurator.setupRegistry(); } if (injectorProvider != null) { Injector injector = injectorProvider.getInjector(); if (injector != null) injector.injectMembers(context.getRequiredTestInstance()); } }
@Override public void afterTestExecution(ExtensionContext context) throws Exception { IInjectorProvider injectorProvider = getOrCreateInjectorProvider(context); if (injectorProvider instanceof IRegistryConfigurator) { final IRegistryConfigurator registryConfigurator = (IRegistryConfigurator) injectorProvider; registryConfigurator.restoreRegistry(); } }
@Override protected Statement childrenInvoker(final RunNotifier notifier) { return new Statement() { @Override public void evaluate() throws Throwable { WrappingInjectorProvider wrapped = getOrCreateInjectorProvider(); wrapped.setupRegistry(); try { prepareChildren(notifier); } finally { wrapped.restoreRegistry(); } IInjectorProvider delegate = wrapped.getDelegate(); if (delegate instanceof IRegistryConfigurator) { IRegistryConfigurator registryConfigurator = (IRegistryConfigurator) delegate; registryConfigurator.setupRegistry(); try { runChildren(notifier); } finally { registryConfigurator.restoreRegistry(); } } else { runChildren(notifier); } } }; }
public WrappingInjectorProvider(IInjectorProvider delegate) { this.delegate = delegate; stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); this.injector = createInjector(); if (delegate instanceof IRegistryConfigurator) { ((IRegistryConfigurator) delegate).setupRegistry(); } registerFactory(injector); stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); if (delegate instanceof IRegistryConfigurator) { ((IRegistryConfigurator) delegate).restoreRegistry(); } }