How do I connect StaticListableBeanFactory with ClassPathXmlApplicationContext?

Posted by Aaron Digulla on Stack Overflow See other posts from Stack Overflow or by Aaron Digulla
Published on 2010-06-09T11:33:55Z Indexed on 2010/06/09 11:52 UTC
Read the original article Hit count: 200

Filed under:
|
|
|

In the setup of my test cases, I have this code:

    ApplicationContext context = new ClassPathXmlApplicationContext(
            "spring/common.xml"
    );
    StaticListableBeanFactory testBeanFactory = new StaticListableBeanFactory();

How do I connect the two in such a way that tests can register beans in the testBeanFactory during setup and the rest of the application uses them instead of the ones defined in common.xml?

Note: I need to mix a static (common.xml) and a dynamic configuration. I can't use XML for the latter because that would mean to write > 1000 XML files.

© Stack Overflow or respective owner

Related posts about java

Related posts about unit-testing