0
我正在使用Spring MVC测试框架对我的Spring控制器进行集成测试。以下是我的Controller
及其Test
当前使用的代码。如何在Spring MVC测试框架中测试静态资源的配置
@RequestMapping("/login")
public ModelAndView goLogin(){
ModelAndView mv = new ModelAndView("login");
mv.addObject("loginForm", new loginForm());
return mv;
}
@Test
public void goLoginPage() throws Exception{
this.mockMvc.perform(get("/login")).andExpect(status().isOk())
.andExpect(forwardedUrl("/WEB-INF/template/default.jsp"))
.andExpect(model().attribute("loginForm", any(loginForm.class)));
}
我使用Apache Tiles
作为视图框架。以下是loginForm
页面的布局配置代码。
<definition name="login" template="/WEB-INF/template/default.jsp">
<put-attribute name="title" value="Login - Spring Web Testing"></put-attribute>
<put-attribute name="header" value="/WEB-INF/tile/header.jsp"></put-attribute>
<put-attribute name="body" value="/WEB-INF/tile/login_body.jsp"></put-attribute>
<put-list-attribute name="javascripts">
<add-attribute value="/static/script/jquery-2.1.4.js"></add-attribute>
</put-list-attribute>
<put-list-attribute name="stylesheets">
<add-attribute value="/static/style/general.css" />
</put-list-attribute>
</definition>
如何测试如果Apache Tiles
配置Javascript
和stylesheet
文件的配置是否正确?如果没有找到文件,则会发生错误。