XmlWebApplicationContextTests.java 文件源码

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

项目:spring4-understanding 作者:
@Test
@SuppressWarnings("resource")
public void withoutMessageSource() throws Exception {
    MockServletContext sc = new MockServletContext("");
    XmlWebApplicationContext wac = new XmlWebApplicationContext();
    wac.setParent(root);
    wac.setServletContext(sc);
    wac.setNamespace("testNamespace");
    wac.setConfigLocations(new String[] {"/org/springframework/web/context/WEB-INF/test-servlet.xml"});
    wac.refresh();
    try {
        wac.getMessage("someMessage", null, Locale.getDefault());
        fail("Should have thrown NoSuchMessageException");
    }
    catch (NoSuchMessageException ex) {
        // expected;
    }
    String msg = wac.getMessage("someMessage", null, "default", Locale.getDefault());
    assertTrue("Default message returned", "default".equals(msg));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号