Search in sources :

Example 96 with MvcResult

use of org.springframework.test.web.servlet.MvcResult in project judge by zjnu-acm.

the class ContestControllerTest method testStanding.

/**
 * Test of standing method, of class ContestController.
 *
 * @see ContestController#standing(long)
 */
@Test
public void testStanding() throws Exception {
    log.info("standing");
    long id = mockDataService.contest().getId();
    MvcResult result = mvc.perform(get("/api/contests/{id}/standing.json", id)).andExpect(request().asyncStarted()).andReturn();
    MvcResult asyncResult = mvc.perform(asyncDispatch(result)).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)).andReturn();
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 97 with MvcResult

use of org.springframework.test.web.servlet.MvcResult in project judge by zjnu-acm.

the class LanguageControllerTest method testFindOne.

/**
 * Test of findOne method, of class LanguageController.
 *
 * @see LanguageController#findOne(long)
 */
@Test
public void testFindOne() throws Exception {
    log.info("findOne");
    long id = 0;
    MvcResult result = mvc.perform(get("/api/languages/{id}.json", id)).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)).andReturn();
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 98 with MvcResult

use of org.springframework.test.web.servlet.MvcResult in project judge by zjnu-acm.

the class LanguageControllerTest method testUpdate.

/**
 * Test of update method, of class LanguageController.
 *
 * @see LanguageController#update(long, Language)
 */
@Test
public void testUpdate() throws Exception {
    log.info("update");
    long id = 0;
    Language request = Language.builder().name("mock language").sourceExtension("tmp").executableExtension("dummy").build();
    MvcResult result = mvc.perform(put("/api/languages/{id}.json", id).content(objectMapper.writeValueAsString(request)).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isNoContent()).andReturn();
}
Also used : Language(cn.edu.zjnu.acm.judge.domain.Language) MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 99 with MvcResult

use of org.springframework.test.web.servlet.MvcResult in project judge by zjnu-acm.

the class LocaleControllerTest method testFindOne.

/**
 * Test of findOne method, of class LocaleController.
 *
 * @see LocaleController#findOne(String, boolean)
 */
@Test
public void testFindOne() throws Exception {
    log.info("findOne");
    String id = "en";
    boolean support = false;
    MvcResult result = mvc.perform(get("/api/locales/{id}.json", id).param("support", Boolean.toString(support))).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)).andReturn();
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 100 with MvcResult

use of org.springframework.test.web.servlet.MvcResult in project judge by zjnu-acm.

the class MiscControllerTest method testSystemInfo.

/**
 * Test of systemInfo method, of class MiscController.
 *
 * @see MiscController#systemInfo()
 */
@Test
public void testSystemInfo() throws Exception {
    log.info("systemInfo");
    MvcResult result = mvc.perform(get("/api/misc/systemInfo.json")).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)).andReturn();
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

MvcResult (org.springframework.test.web.servlet.MvcResult)536 Test (org.junit.Test)300 Test (org.junit.jupiter.api.Test)143 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)132 ResultMatcher (org.springframework.test.web.servlet.ResultMatcher)69 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)38 MockHttpSession (org.springframework.mock.web.MockHttpSession)35 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)34 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)31 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)26 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)26 RequestBuilder (org.springframework.test.web.servlet.RequestBuilder)24 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)22 Map (java.util.Map)22 ResultActions (org.springframework.test.web.servlet.ResultActions)19 Cookie (javax.servlet.http.Cookie)18 MockMvc (org.springframework.test.web.servlet.MockMvc)17 HttpSession (jakarta.servlet.http.HttpSession)16 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 AbstractSaturnConsoleTest (com.vip.saturn.job.console.AbstractSaturnConsoleTest)15