spring boot1.5.6 测试类
package com.qutaoyao.demo.web; import com.qutaoyao.demo.web.controller.HelloController;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.test.web.servlet.setup.MockMvcBuilders; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; @RunWith(SpringRunner.class)
@SpringBootTest
public class HelloControllerTests { private MockMvc mvc; @Before
public void init(){
this.mvc = MockMvcBuilders.standaloneSetup(new HelloController()).build();
} @Test
public void sayHi() throws Exception{
RequestBuilder req = get("/hello/hi"); mvc.perform(req).andExpect(status().isOk()).andExpect(content().string("Hello World!."));
}
}
spring boot1.5.6 测试类的更多相关文章
- spring boot1.5.6 测试类1
package com.example.demo; import org.junit.Before;import org.junit.Test; import org.junit.runner.Run ...
- Mybatis+Spring整合后Mapper测试类编写
public class UserMapperTest { private ApplicationContext applicationContext; @Before public void ini ...
- spring boot 单元测试 --- 在测试类使用 javabean注解操作接口
1.依赖包 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>s ...
- spring 测试类test测试方法
实例掩码地址为:孔浩组织结构设计 web.xml配置文件: <!-- Spring 的监听器可以通过这个上下文参数来获取beans.xml的位置 --> <context-param ...
- 测试类异常Manual close is not allowed over a Spring managed SqlSession
在用Spring 和mybatis整合的 写测试类的时候报出解决办法:在全局配置文件 class="org.mybatis.spring.SqlSessionTemplate" ...
- Injection of autowired dependencies failed; autowire 自动注入失败,测试类已初始化过了Spring容器。
1 严重: StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException: Error creat ...
- spring boot测试类自动注入service或dao
使用Spring Boot进行单元测试时,发现使用@Autowired注解的类无法自动注入,当使用这个类的实例的时候,报出NullPointerException,即空指针异常. Spring Boo ...
- spring hibernate 事务整合 使用测试类 事务不自动提交的问题!!!
使用JUnit 测试hibernate 事务管理的时候应注意 ,测试类完成是默认回滚的. 所以只能查询数据库却不能增删改数据库. 应该在测试类上面加上注解 @Rollback(false) 表似默认 ...
- 二 Spring的IOC入门,环境搭建,Spring测试类
IOC:inversion of Control 控制反转,Spring框架的核心.削减计算机程序的耦合问题,把对象(例如JDBC)的创建权交给Spring. IOC的两种类型: 依赖注入: 依赖查 ...
随机推荐
- oracle数据库的备份与还原
转自:https://www.cnblogs.com/ylldbk/p/5613365.html 数据导出: 1 将数据库TEST完全导出,用户名system 密码manager 导出到D:\daoc ...
- 01 性能优化基础怀实践 之 ASH分析
1.模拟一个会话阻塞的场景. 通过update 同一行数据达到模拟阻塞的效果 : SQL> create table t1 (id number ,name varchar2(20)) ; ...
- 生成jvm快照文件
原文:https://blog.csdn.net/jijianshuai/article/details/79128033 -Xmx20m -Xms5m -XX:HeapDumpOnOutofMem ...
- vue interceptors 设置请求头
在main.js添加过滤器,可以 Vue.http.interceptors.push((request,next)=>{ //request.credentials = true; // 接口 ...
- Oracle基础篇--03DML语言
1.数据准备: --创建表格的 create table dept as select * from scott.dept; create table emp as select * from sco ...
- 【3dsMax安装失败,如何卸载、安装3dMax 2017?】
是不是遇到MAYA/CAD/3DSMAX/INVENTOR安装失败?AUTODESK系列软件着实令人头疼,MAYA/CAD/3DSMAX/INVENTOR安装失败之后不能完全卸载!!!(比如maya, ...
- maya安装错误
AUTODESK系列软件着实令人头疼,安装失败之后不能完全卸载!!!(比如maya,cad,3dsmax等).有时手动删除注册表重装之后还是会出现各种问题,每个版本的C++Runtime和.NET f ...
- 性能测试工具Jmeter07-Jmeter性能测试实战
测试需求:测试20个用户访问www.baozhenart.com在负载达到30QPS时的平均响应时间 QPS:Query Per Second每秒查询率.是一台查询服务器每秒能够处理的查询次数.在因特 ...
- vue进阶 --- 实例演示
这篇博客将通过一个实例来对vue构建项目的过程有一个了解. 主要用到的知识点如下所示: vue-router 2.0路由配置 router-view 和 router-link的使用 transiti ...
- LeetCode 881.救生艇(C++)
第 i 个人的体重为 people[i],每艘船可以承载的最大重量为 limit. 每艘船最多可同时载两人,但条件是这些人的重量之和最多为 limit. 返回载到每一个人所需的最小船数.(保证每个人都 ...