|
@@ -0,0 +1,52 @@
|
|
1
|
+package com.xxl.job.admin.controller;
|
|
2
|
+
|
|
3
|
+import com.xxl.job.admin.core.model.XxlJobInfo;
|
|
4
|
+import org.codehaus.jackson.map.ObjectMapper;
|
|
5
|
+import org.junit.Before;
|
|
6
|
+import org.junit.Test;
|
|
7
|
+import org.springframework.http.MediaType;
|
|
8
|
+import org.springframework.test.web.servlet.MvcResult;
|
|
9
|
+
|
|
10
|
+import javax.servlet.http.Cookie;
|
|
11
|
+
|
|
12
|
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
|
13
|
+
|
|
14
|
+public class JobInfoControllerTest extends AbstractSpringMvcTest {
|
|
15
|
+ Cookie cookie;
|
|
16
|
+
|
|
17
|
+ @Before
|
|
18
|
+ public void login() throws Exception {
|
|
19
|
+ MvcResult ret = mockMvc.perform(
|
|
20
|
+ post("/login")
|
|
21
|
+ .contentType(MediaType.APPLICATION_FORM_URLENCODED)
|
|
22
|
+ .param("userName", "admin")
|
|
23
|
+ .param("password", "123456")
|
|
24
|
+ ).andReturn();
|
|
25
|
+ cookie = ret.getResponse().getCookie("LOGIN_IDENTITY");
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ @Test
|
|
29
|
+ public void testAdd() throws Exception {
|
|
30
|
+ XxlJobInfo jobInfo = new XxlJobInfo();
|
|
31
|
+ jobInfo.setJobGroup(1);
|
|
32
|
+ jobInfo.setJobDesc("autoEnquiryStatisPerWeek");
|
|
33
|
+ jobInfo.setExecutorRouteStrategy("FIRST");
|
|
34
|
+ jobInfo.setJobCron("0 0 1 ? * MON");
|
|
35
|
+ jobInfo.setGlueType("BEAN");
|
|
36
|
+ jobInfo.setExecutorHandler("AutoEnquriy");
|
|
37
|
+ jobInfo.setExecutorBlockStrategy("SERIAL_EXECUTION");
|
|
38
|
+ jobInfo.setExecutorFailStrategy("FAIL_ALARM");
|
|
39
|
+ jobInfo.setAuthor("listening");
|
|
40
|
+
|
|
41
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
42
|
+ String jobInfoStr = mapper.writeValueAsString(jobInfo);
|
|
43
|
+ MvcResult ret = mockMvc.perform(
|
|
44
|
+ post("/jobinfo/add")
|
|
45
|
+ .contentType(MediaType.APPLICATION_FORM_URLENCODED)
|
|
46
|
+ .content(jobInfoStr)
|
|
47
|
+ .cookie(cookie)
|
|
48
|
+ ).andReturn();
|
|
49
|
+
|
|
50
|
+ System.out.println(ret.getResponse().getContentAsString());
|
|
51
|
+ }
|
|
52
|
+}
|