junit mocktio request打桩

2023-12-25 14:51:36
  1. Controller下request组装参数
HttpServletRequest request = new MockHttpServletRequest();
((MockHttpServletRequest) request).addHeader("router","login");
((MockHttpServletRequest) request).addParameter("test","wwww");
  1. 非Controller下request组装参数
Mock
HttpServletRequest request;

@Before
public void init(){
    Mockito.when(request.getParameter("version")).thenReturn("1.24.0");
    Process next = processSinked.next("login", request);
}

文章来源:https://blog.csdn.net/luohaihua_20/article/details/135198111
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。