CamelSpringTestContextLoader.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:Camel 作者:
/**
 *  Modeled after the Spring implementation in {@link AbstractGenericContextLoader},
 *  this method creates and refreshes the application context while providing for
 *  processing of additional Camel specific post-refresh actions.  We do not provide the
 *  pre-post hooks for customization seen in {@link AbstractGenericContextLoader} because
 *  they probably are unnecessary for 90+% of users.
 *  <p/>
 *  For some functionality, we cannot use {@link org.springframework.test.context.TestExecutionListener} because we need
 *  to both produce the desired outcome during application context loading, and also cleanup
 *  after ourselves even if the test class never executes.  Thus the listeners, which
 *  only run if the application context is successfully initialized are insufficient to
 *  provide the behavior described above.
 */
@Override
public ApplicationContext loadContext(String... locations) throws Exception {

    Class<?> testClass = getTestClass();

    if (LOG.isDebugEnabled()) {
        LOG.debug("Loading ApplicationContext for locations [" + StringUtils.arrayToCommaDelimitedString(locations) + "].");
    }

    try {
        GenericApplicationContext context = createContext(testClass, null);
        loadBeanDefinitions(context, locations);
        return loadContext(context, testClass);
    } finally {
        cleanup(testClass);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号