SimpleUrlHandlerMappingTests.java 文件源码

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

项目:spring4-understanding 作者:
@Test
public void handlerBeanNotFound() throws Exception {
    MockServletContext sc = new MockServletContext("");
    XmlWebApplicationContext root = new XmlWebApplicationContext();
    root.setServletContext(sc);
    root.setConfigLocations(new String[] {"/org/springframework/web/servlet/handler/map1.xml"});
    root.refresh();
    XmlWebApplicationContext wac = new XmlWebApplicationContext();
    wac.setParent(root);
    wac.setServletContext(sc);
    wac.setNamespace("map2err");
    wac.setConfigLocations(new String[] {"/org/springframework/web/servlet/handler/map2err.xml"});
    try {
        wac.refresh();
        fail("Should have thrown NoSuchBeanDefinitionException");
    }
    catch (FatalBeanException ex) {
        NoSuchBeanDefinitionException nestedEx = (NoSuchBeanDefinitionException) ex.getCause();
        assertEquals("mainControlle", nestedEx.getBeanName());
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号