提交 | 用户 | 时间
|
e7c126
|
1 |
package com.xxl.job.admin.controller; |
H |
2 |
|
|
3 |
import com.xxl.job.admin.service.LoginService; |
|
4 |
import org.junit.jupiter.api.BeforeEach; |
|
5 |
import org.junit.jupiter.api.Test; |
|
6 |
import org.slf4j.Logger; |
|
7 |
import org.slf4j.LoggerFactory; |
|
8 |
import org.springframework.http.MediaType; |
|
9 |
import org.springframework.test.web.servlet.MvcResult; |
|
10 |
import org.springframework.util.LinkedMultiValueMap; |
|
11 |
import org.springframework.util.MultiValueMap; |
|
12 |
|
|
13 |
import javax.servlet.http.Cookie; |
|
14 |
|
|
15 |
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; |
|
16 |
|
|
17 |
public class JobInfoControllerTest extends AbstractSpringMvcTest { |
|
18 |
private static Logger logger = LoggerFactory.getLogger(JobInfoControllerTest.class); |
|
19 |
|
|
20 |
private Cookie cookie; |
|
21 |
|
|
22 |
@BeforeEach |
|
23 |
public void login() throws Exception { |
|
24 |
MvcResult ret = mockMvc.perform( |
|
25 |
post("/login") |
|
26 |
.contentType(MediaType.APPLICATION_FORM_URLENCODED) |
|
27 |
.param("userName", "admin") |
|
28 |
.param("password", "123456") |
|
29 |
).andReturn(); |
|
30 |
cookie = ret.getResponse().getCookie(LoginService.LOGIN_IDENTITY_KEY); |
|
31 |
} |
|
32 |
|
|
33 |
@Test |
|
34 |
public void testAdd() throws Exception { |
|
35 |
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>(); |
|
36 |
parameters.add("jobGroup", "1"); |
|
37 |
parameters.add("triggerStatus", "-1"); |
|
38 |
|
|
39 |
MvcResult ret = mockMvc.perform( |
|
40 |
post("/jobinfo/pageList") |
|
41 |
.contentType(MediaType.APPLICATION_FORM_URLENCODED) |
|
42 |
//.content(paramsJson) |
|
43 |
.params(parameters) |
|
44 |
.cookie(cookie) |
|
45 |
).andReturn(); |
|
46 |
|
|
47 |
logger.info(ret.getResponse().getContentAsString()); |
|
48 |
} |
|
49 |
|
|
50 |
} |