测试mapper的工作
来源:互联网 发布:批量域名查询 编辑:程序博客网 时间:2024/06/06 01:32
package cn.com.cmbc.crud.test;import cn.com.cmbc.crud.bean.Department;import cn.com.cmbc.crud.bean.Employee;import cn.com.cmbc.crud.dao.DepartmentMapper;import cn.com.cmbc.crud.dao.EmployeeMapper;import org.apache.ibatis.session.SqlSession;import org.junit.Test;import org.junit.runner.RunWith;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.test.context.ContextConfiguration;import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;import java.util.UUID;/** *测试dao层的工作 * Created by yemin on 2017/8/26. * 使用spring的单元测试,可以自动注入我们的组件 * 需要在pom中导入spring单元测试的插件 * @ContextConfiguration指定spring配置文件的位置,可以不使用原生写法,直接指定autowired即可 */@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations={"classpath:applicationContext.xml"})public class MapperTest { @Autowired DepartmentMapper departmentMapper; @Autowired EmployeeMapper employeeMapper; @Autowired SqlSession sqlSession; @Test public void testCRUD(){ /* System.out.println(departmentMapper); departmentMapper.insertSelective(new Department(null,"开发部门")); departmentMapper.insertSelective(new Department(null,"测试部门"));// 生成员工数据,插入数据库 employeeMapper.insertSelective(new Employee(null, "gl", "M", "stream_gao@qq.com", 1)); employeeMapper.insertSelective(new Employee(null,"zhangsan","F","123@126.com",2));*///批量插入多个员工,批量,使用可以进行批量的sqlsession EmployeeMapper em= sqlSession.getMapper(EmployeeMapper.class); for(int i=0;i<1000;i++){ String uid= UUID.randomUUID().toString().substring(0,5)+i; em.insertSelective(new Employee(null, uid, "M", uid+"@126.com", 1)); } }}
阅读全文
0 0
- 测试mapper的工作
- mybatis自动扫描mapper的工作原理
- 实际工作中:----mybatis长用的mapper.xml
- 测试工作的量化
- 功能测试的测试工作流程
- 功能测试的测试工作流程
- 【转帖】功能测试的测试工作流程
- 功能测试的测试工作流程
- ATE测试的工作内容
- ATE测试的工作内容
- 测试团队的工作模式
- device mapper的使用
- device mapper的使用
- Mapper reducer 的生命周期
- device mapper的使用
- mybatis的mapper
- mybatis mapper的配置
- idea的Mapper配置
- Equals和==的区别
- Python学习 -- filter
- 逼格极高的注释
- TCP/UDP下的socket编程
- Java中创建对象的5种方式
- 测试mapper的工作
- forward 和redirect的区别
- 监控windows某个服务当服务停止后自动重启服务
- 仿 IOS-SlideBar
- android打包时The same input jar is specified twice 解决办法
- Filter详解+实例
- Java代码优化
- 解决SVN选项不可用的情况
- linux学习笔记(17)