小型的员工管理系统-SSM-05

这节我们来测试下我们生成的逆向工程是否合理吧!

这时我们来采用spring自带的test测试来完成!

test.java:

package com.yiyi.crud.utils;

import java.util.UUID;

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 com.yiyi.crud.bean.Department;
import com.yiyi.crud.bean.Employee;
import com.yiyi.crud.dao.DepartmentMapper;
import com.yiyi.crud.dao.EmployeeMapper;

/**
 * 
 * @Title: Test.java
 * @Package com.yiyi.crud.utils
 * @Description: 测试类
 * @author zww
 * @date 2017年5月9日 下午11:26:58
 * @version V1.0
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
public class Test {

	@Autowired
	private DepartmentMapper departmentMapper;

	@Autowired
	private EmployeeMapper employeeMapper;

	@Autowired
	private SqlSession sqlSession;

	/**
	 * 测试DepartmentMapper
	 */
	@Test
	public void testCRUD() {

		// 1、插入几个部门
		departmentMapper.insertSelective(new Department(null, "运维部"));
		departmentMapper.insertSelective(new Department(null, "测试部"));
		// //2、生成员工数据,测试员工插入
		employeeMapper.insertSelective(new Employee(null, "zww", "M", "zww@yiyi.com", 6));

		// 3、批量插入多个员工;批量,使用可以执行批量操作的sqlSession。

		EmployeeMapper mapper = sqlSession.getMapper(EmployeeMapper.class);
		for (int i = 0; i < 1000; i++) {
			String uid = UUID.randomUUID().toString().substring(0, 5) + i;
			mapper.insertSelective(new Employee(null, uid, "M", uid + "@yiyi.com", 10));
			System.out.println("查看批量完成是否结束!");

		}
	}
}
这时来查下数据库相应的数据已经生成,接下里你们也来试试吧!

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值