diff --git a/.gitignore b/.gitignore index 349ebac4..7a08712c 100644 --- a/.gitignore +++ b/.gitignore @@ -118,3 +118,4 @@ basedir/ /phoenix_ddos_handle.iml /src/main/resources/git.properties /.run/ +/rule.xml diff --git a/src/test/java/com/dispose/test/dev/controller/ErrorControllerTest.java b/src/test/java/com/dispose/test/dev/controller/ErrorControllerTest.java new file mode 100644 index 00000000..ddca9c4e --- /dev/null +++ b/src/test/java/com/dispose/test/dev/controller/ErrorControllerTest.java @@ -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); + } +}