package com.example.test;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
//首先指定Junit的Runner
@RunWith(SpringJUnit4ClassRunner.class)
// 指明配置文件所在
@ContextConfiguration(locations = {"classpath:applicationContext.xml","classpath:spring-mvc.xml"})
@WebAppConfiguration
public class MockMvcTest {
@Autowired
private WebApplicationContext webApplicationContext;
private MockMvc mockMvc;
@Before
public void setUp() throws Exception {
mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();
}
// @Test
// public void testHelloController1() throws Exception {
// mockMvc.perform(MockMvcRequestBuilders.get("/hello")
// .accept(MediaType.APPLICATION_JSON))
// .andExpect(status().isOk())
// .andDo(MockMvcResultHandlers.print());
// }
@Test
public void testStudentController() throws Exception {
// mockMvc.perform(MockMvcRequestBuilders.get("/toHello"))
// .andExpect(status().isOk())
// .andDo(MockMvcResultHandlers.print());
mockMvc.perform(MockMvcRequestBuilders.get("/list"))
.andExpect(status().isOk())
.andDo(MockMvcResultHandlers.print());
// mockMvc.perform(MockMvcRequestBuilders.get("/toAdd"))
// .andExpect(status().isOk())
// .andDo(MockMvcResultHandlers.print());
//
// mockMvc.perform(MockMvcRequestBuilders.post("/add").param("name", "XH")
// .param("niceName", "XH1995").param("age", "24"))
// .andExpect(status().isFound())
// .andDo(MockMvcResultHandlers.print());
//
// mockMvc.perform(MockMvcRequestBuilders.get("/show").param("id", "145"))
// .andExpect(status().isOk())
// .andDo(MockMvcResultHandlers.print());
//
// mockMvc.perform(MockMvcRequestBuilders.get("/toEdit").param("id", "145"))
// .andExpect(status().isOk())
// .andDo(MockMvcResultHandlers.print());
//
// mockMvc.perform(MockMvcRequestBuilders.post("/edit").param("id", "145")
// .param("name", "Tom123").param("niceName", "Tom123").param("age", "24"))
// .andExpect(status().isFound())
// .andDo(MockMvcResultHandlers.print());
//
// mockMvc.perform(MockMvcRequestBuilders.get("/delete").param("id", "146"))
// .andExpect(status().isFound())
// .andDo(MockMvcResultHandlers.print());
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
spring+springmvc+hibernate+thymeleaf 练习demo项目源码
共58个文件
java:11个
class:11个
xml:10个
需积分: 10 9 下载量 55 浏览量
2017-11-27
15:00:06
上传
评论
收藏 135KB RAR 举报
温馨提示
spring+springmvc+hibernate+ thymeleaf 框架组合练习学习做的一个完整的精简的小demo项目源码
资源推荐
资源详情
资源评论
收起资源包目录
spring-springmvc-hibernate-thymeleaf.rar (58个子文件)
spring-springmvc-hibernate-thymeleaf
.project 1KB
src
test
java
main
webapp
WEB-INF
lib
web.xml 2KB
templates
edit.html 2KB
detail.html 750B
hello.html 57B
list.html 1KB
add.html 1KB
index.html 57B
META-INF
MANIFEST.MF 39B
static
bootstrap
js
bootstrap.js 68KB
bootstrap.min.js 36KB
css
bootstrap.min.css 118KB
bootstrap-theme.min.css 23KB
bootstrap.css 143KB
jquery.min.js 91KB
resources
log4j.xml 2KB
applicationContext.xml 6KB
spring-mvc.xml 3KB
database.properties 150B
java
com
example
service
TestService.java 2KB
StudentService.java 331B
impl
StudentServiceImpl.java 771B
model
Student.java 1KB
controller
StudentController.java 2KB
HelloController.java 645B
dao
StudentDao.java 320B
impl
StudentDaoImpl.java 1KB
TestDao.java 2KB
BaseDao.java 394B
test
MockMvcTest.java 3KB
target
m2e-wtp
web-resources
META-INF
MANIFEST.MF 114B
maven
com.xh.ssht
spring-springmvc-hibernate-thymeleaf
pom.properties 334B
pom.xml 5KB
classes
log4j.xml 2KB
applicationContext.xml 6KB
com
example
service
impl
StudentServiceImpl.class 1KB
StudentService.class 423B
TestService.class 2KB
model
Student.class 2KB
controller
StudentController.class 3KB
HelloController.class 1KB
dao
impl
StudentDaoImpl.class 2KB
BaseDao.class 626B
StudentDao.class 411B
TestDao.class 2KB
test
MockMvcTest.class 3KB
spring-mvc.xml 3KB
database.properties 150B
test-classes
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 252B
org.eclipse.m2e.core.prefs 90B
org.eclipse.jdt.core.prefs 736B
org.eclipse.wst.validation.prefs 50B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.component 749B
.jsdtscope 639B
pom.xml 5KB
.classpath 1KB
共 58 条
- 1
资源评论
PandaCode辉
- 粉丝: 94
- 资源: 29
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功