VelocityViewResolverTests.java 文件源码

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

项目:class-guard 作者:
@Test
public void testVelocityViewResolverWithToolbox() throws Exception {
    VelocityConfig vc = new VelocityConfig() {
        @Override
        public VelocityEngine getVelocityEngine() {
            return new TestVelocityEngine("prefix_test_suffix", new Template());
        }
    };

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.getBeanFactory().registerSingleton("configurer", vc);
    wac.refresh();

    String toolbox = "org/springframework/web/servlet/view/velocity/toolbox.xml";

    VelocityViewResolver vr = new VelocityViewResolver();
    vr.setPrefix("prefix_");
    vr.setSuffix("_suffix");
    vr.setToolboxConfigLocation(toolbox);
    vr.setApplicationContext(wac);

    View view = vr.resolveViewName("test", Locale.CANADA);
    assertEquals("Correct view class", VelocityToolboxView.class, view.getClass());
    assertEquals("Correct URL", "prefix_test_suffix", ((VelocityView) view).getUrl());
    assertEquals("Correct toolbox", toolbox, ((VelocityToolboxView) view).getToolboxConfigLocation());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号