ViewResolverTests.java 文件源码

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

项目:spring4-understanding 作者:
@Test
public void testCacheRemoval() throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    wac.refresh();
    InternalResourceViewResolver vr = new InternalResourceViewResolver();
    vr.setViewClass(JstlView.class);
    vr.setApplicationContext(wac);

    View view = vr.resolveViewName("example1", Locale.getDefault());
    View cached = vr.resolveViewName("example1", Locale.getDefault());
    if (view != cached) {
        fail("Caching doesn't work");
    }

    vr.removeFromCache("example1", Locale.getDefault());
    cached = vr.resolveViewName("example1", Locale.getDefault());
    if (view == cached) {
        // the chance of having the same reference (hashCode) twice if negligible).
        fail("View wasn't removed from cache");
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号