use of org.olat.core.configuration.Initializable in project OpenOLAT by OpenOLAT.
the class SpringInitDestroyVerficationTest method testInitMethodCalls.
@Test
public void testInitMethodCalls() {
XmlWebApplicationContext context = (XmlWebApplicationContext) applicationContext;
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
Map<String, Initializable> beans = applicationContext.getBeansOfType(Initializable.class);
for (Iterator<String> iterator = beans.keySet().iterator(); iterator.hasNext(); ) {
String beanName = iterator.next();
try {
GenericBeanDefinition beanDef = (GenericBeanDefinition) beanFactory.getBeanDefinition(beanName);
assertNotNull("Spring Bean (" + beanName + ") of type Initializable does not have the required init-method attribute or the method name is not init!", beanDef.getInitMethodName());
if (beanDef.getDestroyMethodName() != null) {
assertTrue("Spring Bean (" + beanName + ") of type Initializable does not have the required init-method attribute or the method name is not init!", beanDef.getInitMethodName().equals("init"));
}
} catch (NoSuchBeanDefinitionException e) {
log.error("testInitMethodCalls: Error while trying to analyze bean with name: " + beanName + " :" + e);
} catch (Exception e) {
log.error("testInitMethodCalls: Error while trying to analyze bean with name: " + beanName + " :" + e);
}
}
}
use of org.olat.core.configuration.Initializable in project openolat by klemens.
the class SpringInitDestroyVerficationTest method testInitMethodCalls.
@Test
public void testInitMethodCalls() {
XmlWebApplicationContext context = (XmlWebApplicationContext) applicationContext;
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
Map<String, Initializable> beans = applicationContext.getBeansOfType(Initializable.class);
for (Iterator<String> iterator = beans.keySet().iterator(); iterator.hasNext(); ) {
String beanName = iterator.next();
try {
GenericBeanDefinition beanDef = (GenericBeanDefinition) beanFactory.getBeanDefinition(beanName);
assertNotNull("Spring Bean (" + beanName + ") of type Initializable does not have the required init-method attribute or the method name is not init!", beanDef.getInitMethodName());
if (beanDef.getDestroyMethodName() != null) {
assertTrue("Spring Bean (" + beanName + ") of type Initializable does not have the required init-method attribute or the method name is not init!", beanDef.getInitMethodName().equals("init"));
}
} catch (NoSuchBeanDefinitionException e) {
log.error("testInitMethodCalls: Error while trying to analyze bean with name: " + beanName + " :" + e);
} catch (Exception e) {
log.error("testInitMethodCalls: Error while trying to analyze bean with name: " + beanName + " :" + e);
}
}
}
Aggregations