📄 kqserviceimpltest.java
字号:
package org.HumanResManSys.service;
//import static org.junit.Assert.*;
import java.util.List;
import junit.framework.TestCase;
import org.HumResManSys.service.KqService;
import org.HumResManSys.vo.Kq_info;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class KqServiceImplTest extends TestCase{
@Test
public void testAddKq_info() {
try{
ApplicationContext ac=
new ClassPathXmlApplicationContext("/applicationContext.xml");
KqService kqserv=(KqService)ac.getBean("KqService");
String emp_name="czq";
long times=30;
long kq_degree=0;
String month="1";
Kq_info kq_info=new Kq_info();
kq_info.setEmp_name(emp_name);
kq_info.setTimes(times);
kq_info.setKq_degree(kq_degree);
kq_info.setMonth(month);
kqserv.addKq_info(kq_info);
}catch(Exception e ){
e.printStackTrace();
}
}
@Test
public void testDisplayKq_info() {
try{
ApplicationContext ac=
new ClassPathXmlApplicationContext("/applicationContext.xml");
KqService kqserv=(KqService)ac.getBean("KqService");
kqserv.displayKq_info();
}catch(Exception e ){
e.printStackTrace();
}
}
@Test
public void testDisplaySelfKq_info() {
try{
ApplicationContext ac=
new ClassPathXmlApplicationContext("/applicationContext.xml");
KqService kqserv=(KqService)ac.getBean("KqService");
List<Kq_info> list=kqserv.displaySelfKq_info("7");
for(int i=0;i<list.size();i++){
System.out.println(list.get(i).getEmp_name());
System.out.println(list.get(i).getMonth());
System.out.println(list.get(i).getKq_degree());
System.out.println(list.get(i).getTimes());
}
}catch(Exception e ){
e.printStackTrace();
}
}
@Test
public void testUpdateKq_info() {
try{
ApplicationContext ac=
new ClassPathXmlApplicationContext("/applicationContext.xml");
KqService kqserv=(KqService)ac.getBean("KqService");
/***在Hibernate中,当byEntity查询时,不能含有主键,也就是说,不能有kq_leave表中的ID列。
* 否则,会有错误。byEntity查询可以不包括表中的所有列。
***/
String emp_name="czq";
long times=30;
String month="1";
Kq_info new_kq_info=new Kq_info();
new_kq_info.setEmp_name(emp_name);
new_kq_info.setTimes(times);
new_kq_info.setMonth(month);
kqserv.updateKq_info(new_kq_info);
}catch(Exception e ){
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -