StrutsSupportTests.java 文件源码

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

项目:spring-struts-forwardport 作者:
@Test
@SuppressWarnings("serial")
public void dispatchActionSupportWithContextLoaderPlugIn() throws ServletException {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.addMessage("test", Locale.getDefault(), "testmessage");
    final ServletContext servletContext = new MockServletContext();
    wac.setServletContext(servletContext);
    wac.refresh();
    servletContext.setAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX, wac);

    ActionServlet actionServlet = new ActionServlet() {
        @Override
        public ServletContext getServletContext() {
            return servletContext;
        }
    };
    DispatchActionSupport action = new DispatchActionSupport() {
    };
    action.setServlet(actionServlet);

    assertEquals(wac, action.getWebApplicationContext());
    assertEquals(servletContext, action.getServletContext());
    assertEquals("testmessage", action.getMessageSourceAccessor().getMessage("test"));

    action.setServlet(null);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号