首页>代码>Spring Boot学习(四)之web开发渲染页面 -- Freemarker博客源码分享>/springbootstudy-demo4-freemarker/src/test/java/com/xiaojingg/SpringbootstudyDemo4FreemarkerApplicationTests.java
package com.xiaojingg; import com.xiaojingg.web.HelloController; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; 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.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import static org.hamcrest.Matchers.equalTo; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringRunner.class) @SpringBootTest public class SpringbootstudyDemo4FreemarkerApplicationTests { private MockMvc mvc; @Before public void setUp() throws Exception { mvc = MockMvcBuilders.standaloneSetup( new HelloController()).build(); } @Test public void getHello() throws Exception { mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().string(equalTo("Hello World"))); } }
最近下载更多
搁浅 LV1
2021年8月4日
xiaoche117 LV17
2020年6月19日
清咿酱 LV11
2020年5月7日
guaixia163 LV13
2020年2月27日
15237736357 LV2
2019年4月12日
低调人 LV38
2019年2月23日
Zrhans LV5
2019年2月22日
sgy1143 LV7
2018年7月27日
lw19900921 LV25
2018年7月4日
TwinkleQin LV6
2018年6月26日