Class BeanUtilsTestContextInjectionExecutionListener

  • All Implemented Interfaces:
    org.springframework.core.Ordered, org.springframework.test.context.TestExecutionListener

    public class BeanUtilsTestContextInjectionExecutionListener
    extends org.springframework.test.context.support.AbstractTestExecutionListener
    This listener will inject the ApplicationContext from the TestContext into BeanUtils so that it can locate beans inside the test context instead of using DefaultLocatorFactory. If BeanUtils uses DefaultLocatorFactory, it will start up another Spring context hierarchy inside the tests causing duplicate beans.
    • Field Summary

      • Fields inherited from interface org.springframework.core.Ordered

        HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void beforeTestMethod​(org.springframework.test.context.TestContext testContext)  
      • Methods inherited from class org.springframework.test.context.support.AbstractTestExecutionListener

        afterTestClass, afterTestMethod, beforeTestClass, getOrder, prepareTestInstance
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BeanUtilsTestContextInjectionExecutionListener

        public BeanUtilsTestContextInjectionExecutionListener()
    • Method Detail

      • beforeTestMethod

        public void beforeTestMethod​(org.springframework.test.context.TestContext testContext)
                              throws java.lang.Exception
        Specified by:
        beforeTestMethod in interface org.springframework.test.context.TestExecutionListener
        Overrides:
        beforeTestMethod in class org.springframework.test.context.support.AbstractTestExecutionListener
        Throws:
        java.lang.Exception