From dbc758d8896d4aaad4c9601c856120297e920eef Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Thu, 22 Jun 2017 09:02:32 +0200 Subject: [PATCH] no-jira: remove empty tests, use standard logger --- .../SpringInitDestroyVerficationTest.java | 61 ++++++++----------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/src/test/java/org/olat/test/SpringInitDestroyVerficationTest.java b/src/test/java/org/olat/test/SpringInitDestroyVerficationTest.java index efb45ee6fad..5642482fdfd 100644 --- a/src/test/java/org/olat/test/SpringInitDestroyVerficationTest.java +++ b/src/test/java/org/olat/test/SpringInitDestroyVerficationTest.java @@ -34,6 +34,8 @@ import java.util.Map; import org.junit.Test; import org.olat.core.configuration.Destroyable; import org.olat.core.configuration.Initializable; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.GenericBeanDefinition; @@ -50,6 +52,8 @@ import org.springframework.web.context.support.XmlWebApplicationContext; */ public class SpringInitDestroyVerficationTest extends OlatTestCase { + private static final OLog log = Tracing.createLoggerFor(SpringInitDestroyVerficationTest.class); + @Test public void testInitMethodCalls() { XmlWebApplicationContext context = (XmlWebApplicationContext)applicationContext; @@ -67,46 +71,35 @@ public class SpringInitDestroyVerficationTest extends OlatTestCase { beanDef.getInitMethodName().equals("init")); } } catch (NoSuchBeanDefinitionException e) { - System.out.println("testInitMethodCalls: Error while trying to analyze bean with name: "+beanName +" :"+e); + log.error("testInitMethodCalls: Error while trying to analyze bean with name: "+beanName +" :"+e); } catch (Exception e) { - System.out.println("testInitMethodCalls: Error while trying to analyze bean with name: "+beanName +" :"+e); + log.error("testInitMethodCalls: Error while trying to analyze bean with name: "+beanName +" :"+e); } } } - @Test - public void testDestroyMethodCalls() { - XmlWebApplicationContext context = (XmlWebApplicationContext)applicationContext; - ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); - - - Map<String, Destroyable> beans = applicationContext.getBeansOfType(Destroyable.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 Destroyable does not have the required destroy-method attribute or the method name is not destroy!", - beanDef.getDestroyMethodName()); - if (beanDef.getDestroyMethodName() != null) { - assertTrue("Spring Bean ("+beanName+") of type Destroyable does not have the required destroy-method attribute or the method name is not destroy!", - beanDef.getDestroyMethodName().equals("destroy")); - } - } catch (NoSuchBeanDefinitionException e) { - System.out.println("testDestroyMethodCalls: Error while trying to analyze bean with name: "+beanName +" :"+e); - } catch (Exception e) { - System.out.println("testDestroyMethodCalls: Error while trying to analyze bean with name: "+beanName +" :"+e); - } - } - } + @Test + public void testDestroyMethodCalls() { + XmlWebApplicationContext context = (XmlWebApplicationContext)applicationContext; + ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); - @Test - public void testAnnotatedInitMethodCalls() { - //TODO implement init methods annoteded with postconstruct annotation - } - @Test - public void testAnnotatedDestroyMethodCalls() { - //TODO implement destroy methods annoteded with predestroy annotation + Map<String, Destroyable> beans = applicationContext.getBeansOfType(Destroyable.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 Destroyable does not have the required destroy-method attribute or the method name is not destroy!", + beanDef.getDestroyMethodName()); + if (beanDef.getDestroyMethodName() != null) { + assertTrue("Spring Bean ("+beanName+") of type Destroyable does not have the required destroy-method attribute or the method name is not destroy!", + beanDef.getDestroyMethodName().equals("destroy")); + } + } catch (NoSuchBeanDefinitionException e) { + log.error("testDestroyMethodCalls: Error while trying to analyze bean with name: "+beanName +" :"+e); + } catch (Exception e) { + log.error("testDestroyMethodCalls: Error while trying to analyze bean with name: "+beanName +" :"+e); + } } - + } } -- GitLab