Search in sources :

Example 1 with InjectWith

use of org.eclipse.xtext.junit4.InjectWith in project xtext-eclipse by eclipse.

the class InjectorProviders method getOrCreateInjectorProvider.

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.getDeclaredConstructor().newInstance();
                injectorProviderClassCache.put(klass, injectorProvider);
            } catch (Exception e) {
                throwUncheckedException(e);
            }
        }
        return injectorProvider;
    }
    return null;
}
Also used : InjectWith(org.eclipse.xtext.junit4.InjectWith) IInjectorProvider(org.eclipse.xtext.junit4.IInjectorProvider)

Aggregations

IInjectorProvider (org.eclipse.xtext.junit4.IInjectorProvider)1 InjectWith (org.eclipse.xtext.junit4.InjectWith)1