/** * Implements behavior from: org.junit.runners.Parameterized$TestClassRunnerForParameters * org.eclipse.xtext.testing.XtextRunner */ @Override public Object createTest() throws Exception { Object object; // Functionality of // org.junit.runners.Parameterized$TestClassRunnerForParameters if (fieldsAreAnnotated()) { object = createTestUsingFieldInjection(); } else { object = createTestUsingConstructorInjection(); } // Functionality of org.eclipse.xtext.testing.XtextRunner IInjectorProvider injectorProvider = getOrCreateInjectorProvider(); if (injectorProvider != null) { Injector injector = injectorProvider.getInjector(); if (injector != null) injector.injectMembers(object); } return object; }
public static IInjectorProvider getOrCreateInjectorProvider(ExtensionContext context) { InjectWith injectWith = context.getRequiredTestClass().getAnnotation(InjectWith.class); if (injectWith != null) { Class<? extends IInjectorProvider> klass = injectWith.value(); IInjectorProvider injectorProvider = injectorProviderClassCache.get(klass); if (injectorProvider == null) { try { injectorProvider = klass.newInstance(); injectorProviderClassCache.put(klass, injectorProvider); } catch (Exception e) { throwUncheckedException(e); } } return injectorProvider; } return null; }
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(); } } }
public static IInjectorProvider getOrCreateInjectorProvider(TestClass testClass) { InjectWith injectWith = testClass.getJavaClass().getAnnotation(InjectWith.class); if (injectWith != null) { Class<? extends IInjectorProvider> klass = injectWith.value(); IInjectorProvider injectorProvider = injectorProviderClassCache.get(klass); if (injectorProvider == null) { try { injectorProvider = klass.newInstance(); injectorProviderClassCache.put(klass, injectorProvider); } catch (Exception e) { throwUncheckedException(e); } } return injectorProvider; } return null; }
public static IInjectorProvider getInjectorProvider(ExtensionContext context) { InjectWith injectWith = context.getRequiredTestClass().getAnnotation(InjectWith.class); if (injectWith != null) { return injectorProviderClassCache.get(injectWith.value()); } return null; }
public static IInjectorProvider createInjectorProvider(ExtensionContext context) { InjectWith injectWith = context.getRequiredTestClass().getAnnotation(InjectWith.class); if (injectWith != null) { try { return injectWith.value().newInstance(); } catch (Exception e) { throwUncheckedException(e); } } return null; }
@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); } } }; }
@Override protected void process(String data) throws Exception { IInjectorProvider delegate = getOrCreateInjectorProvider().getDelegate(); ScenarioProcessor processor = delegate.getInjector().getInstance(getProcessorClass()); String preProcessed = processor.preProcess(data); if (preProcessed == null) { throw new AssumptionViolatedException("Input is filtered by the pre processing step: " + data); } doProcess(preProcessed, processor); }
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(); } }
public static WrappingInjectorProvider wrap(IInjectorProvider delegate) { WrappingInjectorProvider result = cachedInjectors.get(delegate); if (result == null) { result = new WrappingInjectorProvider(delegate); cachedInjectors.put(delegate, result); } return result; }
public static IInjectorProvider getInjectorProvider(TestClass testClass) { InjectWith injectWith = testClass.getJavaClass().getAnnotation(InjectWith.class); if (injectWith != null) { return injectorProviderClassCache.get(injectWith.value()); } return null; }
public static IInjectorProvider createInjectorProvider(TestClass testClass) { InjectWith injectWith = testClass.getJavaClass().getAnnotation(InjectWith.class); if (injectWith != null) { try { return injectWith.value().newInstance(); } catch (Exception e) { throwUncheckedException(e); } } return null; }
protected IInjectorProvider getOrCreateInjectorProvider(ExtensionContext context) { return InjectorProviders.getOrCreateInjectorProvider(context); }
protected IInjectorProvider getInjectorProvider(ExtensionContext context) { return InjectorProviders.getInjectorProvider(context); }
protected IInjectorProvider createInjectorProvider(ExtensionContext context) { return InjectorProviders.createInjectorProvider(context); }
public IInjectorProvider getDelegate() { return delegate; }