From efdb99f8cecc4afb592afad79c761081d5d5cf22 Mon Sep 17 00:00:00 2001 From: lee <4766465@qq.com> Date: Wed, 18 Dec 2024 13:27:00 +0800 Subject: [PATCH] init --- xxl-job/xxl-job-admin/src/test/java/com/xxl/job/admin/controller/JobInfoControllerTest.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 50 insertions(+), 0 deletions(-) diff --git a/xxl-job/xxl-job-admin/src/test/java/com/xxl/job/admin/controller/JobInfoControllerTest.java b/xxl-job/xxl-job-admin/src/test/java/com/xxl/job/admin/controller/JobInfoControllerTest.java new file mode 100644 index 0000000..49bf8ae --- /dev/null +++ b/xxl-job/xxl-job-admin/src/test/java/com/xxl/job/admin/controller/JobInfoControllerTest.java @@ -0,0 +1,50 @@ +package com.xxl.job.admin.controller; + +import com.xxl.job.admin.service.LoginService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; + +import javax.servlet.http.Cookie; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; + +public class JobInfoControllerTest extends AbstractSpringMvcTest { + private static Logger logger = LoggerFactory.getLogger(JobInfoControllerTest.class); + + private Cookie cookie; + + @BeforeEach + public void login() throws Exception { + MvcResult ret = mockMvc.perform( + post("/login") + .contentType(MediaType.APPLICATION_FORM_URLENCODED) + .param("userName", "admin") + .param("password", "123456") + ).andReturn(); + cookie = ret.getResponse().getCookie(LoginService.LOGIN_IDENTITY_KEY); + } + + @Test + public void testAdd() throws Exception { + MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>(); + parameters.add("jobGroup", "1"); + parameters.add("triggerStatus", "-1"); + + MvcResult ret = mockMvc.perform( + post("/jobinfo/pageList") + .contentType(MediaType.APPLICATION_FORM_URLENCODED) + //.content(paramsJson) + .params(parameters) + .cookie(cookie) + ).andReturn(); + + logger.info(ret.getResponse().getContentAsString()); + } + +} -- Gitblit v1.9.3