|
|
@ -20,48 +20,31 @@ import cn.escheduler.api.enums.Status; |
|
|
|
import cn.escheduler.api.utils.Result; |
|
|
|
import cn.escheduler.api.utils.Result; |
|
|
|
import cn.escheduler.common.utils.JSONUtils; |
|
|
|
import cn.escheduler.common.utils.JSONUtils; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Before; |
|
|
|
|
|
|
|
import org.junit.Ignore; |
|
|
|
|
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.runner.RunWith; |
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest; |
|
|
|
|
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.test.context.junit4.SpringRunner; |
|
|
|
|
|
|
|
import org.springframework.test.web.servlet.MockMvc; |
|
|
|
|
|
|
|
import org.springframework.test.web.servlet.MvcResult; |
|
|
|
import org.springframework.test.web.servlet.MvcResult; |
|
|
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
|
|
|
|
|
|
|
import org.springframework.util.LinkedMultiValueMap; |
|
|
|
import org.springframework.util.LinkedMultiValueMap; |
|
|
|
import org.springframework.util.MultiValueMap; |
|
|
|
import org.springframework.util.MultiValueMap; |
|
|
|
import org.springframework.web.context.WebApplicationContext; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; |
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; |
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; |
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; |
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; |
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; |
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
|
|
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
/** |
|
|
|
@RunWith(SpringRunner.class) |
|
|
|
* queue controller test |
|
|
|
@SpringBootTest |
|
|
|
*/ |
|
|
|
public class QueueControllerTest { |
|
|
|
public class QueueControllerTest extends AbstractControllerTest{ |
|
|
|
private static Logger logger = LoggerFactory.getLogger(QueueControllerTest.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private MockMvc mockMvc; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private static Logger logger = LoggerFactory.getLogger(QueueControllerTest.class); |
|
|
|
private WebApplicationContext webApplicationContext; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
|
|
|
|
public void setUp() { |
|
|
|
|
|
|
|
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void queryList() throws Exception { |
|
|
|
public void queryList() throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(get("/queue/list") |
|
|
|
MvcResult mvcResult = mockMvc.perform(get("/queue/list") |
|
|
|
.header("sessionId", "d199af92-d8e0-4f1b-bacb-5b3414567e5c")) |
|
|
|
.header(SESSION_ID, sessionId)) |
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andReturn(); |
|
|
|
.andReturn(); |
|
|
@ -81,7 +64,7 @@ public class QueueControllerTest { |
|
|
|
paramsMap.add("pageSize","20"); |
|
|
|
paramsMap.add("pageSize","20"); |
|
|
|
|
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(get("/queue/list-paging") |
|
|
|
MvcResult mvcResult = mockMvc.perform(get("/queue/list-paging") |
|
|
|
.header("sessionId", "d4541e0d-0349-4f05-9c68-300176cd3c91") |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
|
.params(paramsMap)) |
|
|
|
.params(paramsMap)) |
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
@ -95,11 +78,11 @@ public class QueueControllerTest { |
|
|
|
public void createQueue() throws Exception { |
|
|
|
public void createQueue() throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
paramsMap.add("queue","ait111134"); |
|
|
|
paramsMap.add("queue","ait"); |
|
|
|
paramsMap.add("queueName","aitName1"); |
|
|
|
paramsMap.add("queueName","ait"); |
|
|
|
|
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/queue/create") |
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/queue/create") |
|
|
|
.header("sessionId", "d4541e0d-0349-4f05-9c68-300176cd3c91") |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
|
.params(paramsMap)) |
|
|
|
.params(paramsMap)) |
|
|
|
.andExpect(status().isCreated()) |
|
|
|
.andExpect(status().isCreated()) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
@ -107,6 +90,8 @@ public class QueueControllerTest { |
|
|
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
|
|
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
|
|
|
// Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
|
|
|
|
// Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
|
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -118,7 +103,7 @@ public class QueueControllerTest { |
|
|
|
paramsMap.add("queueName","aitName"); |
|
|
|
paramsMap.add("queueName","aitName"); |
|
|
|
|
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/queue/update") |
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/queue/update") |
|
|
|
.header("sessionId", "d4541e0d-0349-4f05-9c68-300176cd3c91") |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
|
.params(paramsMap)) |
|
|
|
.params(paramsMap)) |
|
|
|
.andExpect(status().isCreated()) |
|
|
|
.andExpect(status().isCreated()) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
@ -136,7 +121,7 @@ public class QueueControllerTest { |
|
|
|
paramsMap.add("queueName","aitName"); |
|
|
|
paramsMap.add("queueName","aitName"); |
|
|
|
|
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/queue/verify-queue") |
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/queue/verify-queue") |
|
|
|
.header("sessionId", "d4541e0d-0349-4f05-9c68-300176cd3c91") |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
|
.params(paramsMap)) |
|
|
|
.params(paramsMap)) |
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
|
|
|