public static JTesterBeanFactory initSpringContext(Class testClazz, ApplicationContextFactory contextFactory) {
JTesterBeanFactory beanFactory = (JTesterBeanFactory) TestedObject.getSpringBeanFactory();
if (beanFactory != null) {
return beanFactory;
}
SpringApplicationContext annotation = AnnotationUtils.getClassLevelAnnotation(SpringApplicationContext.class,
testClazz);
if (annotation == null) {
return null;
}
long startTime = System.currentTimeMillis();
String[] locations = annotation.value();
boolean ignoreNoSuchBean = annotation.ignoreNoSuchBean();
JTesterSpringContext context = contextFactory.createApplicationContext(Arrays.asList(locations),
ignoreNoSuchBean);
context.refresh();
long duration = System.currentTimeMillis() - startTime;