parent
e9baad7115
commit
2c0c60e292
|
@ -118,3 +118,4 @@ basedir/
|
|||
/phoenix_ddos_handle.iml
|
||||
/src/main/resources/git.properties
|
||||
/.run/
|
||||
/rule.xml
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package com.dispose.test.dev.controller;
|
||||
|
||||
import com.dispose.test.dev.Global.InitTestEnvironment;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* The type Error controller test.
|
||||
*/
|
||||
@AutoConfigureMockMvc
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@Transactional
|
||||
@Rollback
|
||||
@Slf4j
|
||||
public class ErrorControllerTest extends InitTestEnvironment {
|
||||
/**
|
||||
* The Mock mvc.
|
||||
*/
|
||||
@Resource
|
||||
private MockMvc mockMvc;
|
||||
|
||||
/**
|
||||
* A 1 not exist controller test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a1_notExistControllerTest() throws Exception {
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.get("/controller/unexists"))
|
||||
.andExpect(status().isNotFound())
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
log.debug("result: {}", ret);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue