测试系统:河北省重大需求填报系统
测试内容:
注册登录模块,包含注册账号、系统登录,找回密码;
用户管理模块,修改个人资料,更改用户密码,删除用户,用户查询;
征文信息模块, 征文信息填报,征文信息审核,征文信息修改;
统计查询模块, 按类别查询模块,精确查询模块;查询所有征文信息模块
图表展示模块, Json数据展示;
测试工具:
eclipse+junit5
测试方案:
单元测试方案
模块功能 |
注册登录模块 |
||
现有资源 |
模块1 |
注册账号 |
|
模块2 |
登录系统 |
||
模块 3 |
找回密码 |
||
程序结构 |
功能点 |
涉及的方法 |
|
注册帐号 |
方法1:public boolean add(User user) 功能说明:添加用户 参数描述:User use:用户类对象 输出:true 或 false 异常: 流程:输入用户信息 添加数据库 返回注册信息,注册码 |
||
登录系统 |
方法1: public boolean checkUserid(String username) 功能说明:验证用户是否存在 参数描述:String username:用户名 输出:true 或 false 异常: 流程:输入用户名 查询数据库 返回布尔值 方法2:public User checkUser(String username,String password,String role) 功能说明:验证密码是否正确 参数描述:String username:用户名 (主键) String password:用户密码 String role: 用户角色 输出:null 或 user类对象信息 异常: 流程:输入用户名,用户密码 用户角色 查询数据库 返回用户信息 |
||
找回密码 |
方法1:public boolean Tusal(String username) 功能说明:判断用户是否存在 参数描述:String username:用户名 输出:true 或 false 异常: 流程:输入用户名 查询数据库 返回布尔值 方法2:public boolean Tusalkey(String username,String keyid) 功能说明:判断用户是否正确 参数描述:String username:用户名 String keyid:注册码 输出:true 或 false 异常: 流程:输入用户名和注册码 查询数据库 返回布尔值 方法3:public boolean modifyPassword(String name,String password) 功能说明:找回密码 参数描述:String name:用户名 String password:用户密码 输出:true 或 false 异常: 流程:输入用户名和密码 修改数据库 返回布尔值 |
||
测试用例 |
测试功能点 |
用例描述 |
用例测试结果 |
注册帐号 |
使用测试程序实现单元测试: public void addtest() { String sql = "insert into user(username,password,employee,factoryname,postal,premission) values('" + name + "','" + password + "','" + employee + "','" + factoryname +"','" + postal +"','" + premission + "')";"; User user = (User) JSONObject.toBean (JSONObject.fromObject(data), User.class); assertEquals(Ser.add(user), true); } public void Tusalkeyidtest() { assertEquals(Ser.Tusalkeyid("20183669"), true); assertEquals(Ser.Tusalkeyid("20183788"), false); } |
通过 |
|
登录系统 |
方法一:使用测试程序实现单元测试: public void checkuseridtest() { assertEquals(Ser.checkUserid("zzm","123456",inperson"), true); assertEquals(Ser.checkUserid("zzmtest","zzm""admin"), false); }
@Test void testLogin() { //普通用户登录 String id="赵常恒"; String password="123"; String shenfen="inperson"; String sql="select * from user where (username='" + id + "' and password='" + password + "' and employee='"+shenfen+"')"; try { MessageService.login(sql); System.out.println("普通用户,登陆成功"); } catch (Exception e) { System.out.println(e); } //形式审核员登录 sql="select * from user where (username='" + "infor" + "' and password='" + "infor" + "' and employee='"+"inforplace"+"')"; try { if(MessageService.login(sql)>0) { System.out.println("形式审核员,登陆成功"); } } catch (Exception e) { System.out.println(e); } //管理员登录 sql="select * from user where (username='" + "admin" + "' and password='" + "admin" + "' and employee='"+"admin"+"')"; try { if(MessageService.login(sql)>0) { System.out.println("管理员,登陆成功"); } } catch (Exception e) { System.out.println(e); } sql="select * from user where (username='" + "one" + "' and password='" + "one" + "' and employee='"+"business"+"')"; try { if(MessageService.login(sql)>0) { System.out.println("部门审核员,登陆成功"); } } catch (Exception e) { System.out.println(e); } } @Test void testSearch() { //未输入时,全部展示 System.out.println("列表全部查询,List>0"); System.out.println("列表以工作单位查询,List>0"); //普通用户登录 String id="赵常恒"; String password="123"; String shenfen="inperson"; String sql="select * from user where (username='" + id + "' and password='" + password + "' and employee='"+shenfen+"')"; try { MessageService.login(sql);
} catch (Exception e) { System.out.println(e); } //形式审核员登录 sql="select * from user where (username='" + "infor" + "' and password='" + "infor" + "' and employee='"+"inforplace"+"')"; try { if(MessageService.login(sql)>0) {
} } catch (Exception e) { System.out.println(e); } //管理员登录 sql="select * from user where (username='" + "admin" + "' and password='" + "admin" + "' and employee='"+"admin"+"')"; try { if(MessageService.login(sql)>0) {
} } catch (Exception e) { System.out.println(e); } sql="select * from user where (username='" + "one" + "' and password='" + "one" + "' and employee='"+"business"+"')"; try { if(MessageService.login(sql)>0) {
} } catch (Exception e) { System.out.println(e); } } 方法二:使用界面进行单元测试: 进入登录界面,输入【帐号】、【密码】、【角色】,点击【登录】按钮后,将进入用户对应界面,并显示部分信息。 |
通过 |
|
找回密码 |
使用测试程序实现单元测试: public void Tusaltest() { assertEquals(Ser.Tusal("1111123"), true); assertEquals(Ser.Tusal("1111126"), false); } public void Tusalkeytest() { assertEquals(Ser.Tusalkey("zzm666", "zzm666"), true); assertEquals(Ser.Tusalkey("zzm666", "zzm999"), false); } |
通过 |
|
测试结果 |
注册登录模块通过 |
Username |
Password |
Employee |
Factoryname |
Postal |
premisson |
predict |
Test |
123456 |
123456 |
Inperson |
石家庄铁道大学 |
054001 |
0 |
True |
True |
11 |
11 |
Inperson |
11 |
11 |
0 |
True |
True |
123456 |
123456 |
Inforplace |
石家庄铁道大学 |
054001 |
1 |
False |
False |
Zzm |
987654321 |
business |
宿舍 |
12356 |
2 |
False |
True |
Zzm666 |
S123456 |
Information |
铁道大学 |
321 |
3 |
False |
True |
模块功能 |
用户管理模块 |
||
现有资源 |
模块1 |
修改个人资料 |
|
模块2 |
更改用户密码 |
||
模块3 |
删除用户 |
||
模块4 |
用户查询 |
||
程序结构 |
功能点 |
涉及的方法 |
|
修改个人资料 |
方法1: public boolean updateinfo(User user) 功能说明:修改用户资料 参数描述:User user:用户类对象 输出:true 或 false 异常: 流程:输入用户对象 修改数据库 返回布尔值 |
||
更该用户密码 |
方法1:public boolean updatecode(Usermess user) 功能说明:修改用户密码 参数描述: Usermess user:用户对象 输出:true 或 false 异常: 流程:输入Usermess 修改user数据库 返回布尔值 |
||
删除用户 |
方法1:public boolean deleteUser(String username,String role) 功能说明:删除宿舍信息 参数描述:String username 用户名 String role 用户角色 主键 role username 输出:true 或 false 异常: 流程:输入username role 删除数据库信息 返回布尔值 |
||
用户查询 |
方法1:public List<Usermess> searchinfo(sql) 功能说明:查询用户信息 参数描述:sql 查询语句 输出:返回list数组 异常: 流程:输入sql语句 查询数据库 返回用户信息 |
||
测试用例 |
测试功能点 |
用例描述 |
用例测试结果 |
修改个人资料 |
使用测试程序实现单元测试: void testUpdateinfo() { Usermess usermess1 = new Usermess(); Usermess usermess2 = new Usermess(); Usermess1.set("123456", "123456", "inperson", "石家庄铁道大学", "054600", "0") ;true Usermess2.set("123456", "123456", "inperson", "铁道大学", "054600", "2") false assertEquals(Ser.updateinfo(usermess1), true); assertEquals(Ser. updateinfo (usermess2), false); } |
通过 |
|
更该用户密码 |
使用测试程序实现单元测试: public void testupdatecode() { Usermess usermess1 = new Usermess(); Usermess usermess2 = new Usermess(); Usermess usermess3 = new Usermess(); Usermess1.set("123456", "123456", "inperson") Usermess2.set("123456","123457","inperson") Usermess3.set("123456","123456","admin") assertEquals(Ser.update(Usermess1),true); assertEquals(Ser.update(Usermess2),false); assertEquals(Ser.update(Usermess3),false); } |
通过 |
|
删除用户信息 |
使用测试程序实现单元测试: public void testdeleteUser(String username,String role) { Usermess usermess1 = new Usermess(); Usermess usermess2 = new Usermess(); Usermess usermess3 = new Usermess(); Usermess1.set("123456", "inperson") Usermess2.set("zzm666", "bussiness") Usermess3.set("zzm", "admin") assertEquals(Ser. deleteUser (Usermess1),true); assertEquals(Ser. deleteUser (Usermess2),false); assertEquals(Ser. deleteUser (Usermess3),false); } |
通过 |
|
查询用户 |
方法一:使用测试程序实现单元测试: public void testsearchinfo () { //testcase sql String sql ="select * from user" try { List<Usermess> list= MessageService. searchinfo (sql); //list转Json JSONArray Js = JSONArray.fromObject(echartslist); System.out.println(Js); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } 方法二:使用界面进行单元测试: 管理员进入用户信息界面,输入要查询的信息,点击【搜索】按钮后,显示用户详细信息 |
||
测试结果 |
用户管理模块通过 |
模块功能 |
征文信息模块 |
||
现有资源 |
模块1 |
征文信息填报 |
|
模块2 |
修改个人信息 |
||
程序结构 |
功能点 |
涉及的方法 |
|
征文信息填报 |
方法1:private boolean addinformation (sql) 功能说明:征文信息填报 参数描述:sql :sql语句 页面参数 输出:true 或 false 异常: 流程:输入sql 增添需求信息 返回布尔值 |
||
征文信息审核 |
方法1:public boolean aboutmine(Userinfo userinfo) 功能说明:修改个人资料 参数描述:Userinfo userinfo:用户信息类对象 输出:true 或 false 异常: 流程:输入用户信息 修改数据库 返回布尔值 |
||
征文信息修改 |
|||
测试用例 |
测试功能点 |
用例描述 |
用例测试结果 |
征文信息填报 |
使用测试程序实现单元测试,例如: |
通过 |
|
征文信息审核 |
使用测试程序实现单元测试; @Test //通过修改状态位来改变征文信息状态,默认为0,形式审核为1,部门审核为3, void voidStatuscheck() { String[] status=new String[] { "0","1","3"}; //id=531 文件ID 正确测试 最终status=3 int id=531; //普通转形式审核 True String sql1 = "update information set status='" + status[1] + "' where id='" + id + "'"; //形式转部门 True String sql2 = "update information set status='" + status[2] + "' where id='" + id + "'";
if (MessageService.update(sql1)) { System.out.println("形式审核通过"); if (MessageService.update(sql2)) { System.out.println("部门审核通过"); }else { System.out.println("部门审核未通过"); } }else { System.out.println("形式审核未通过"); }
} |
通过 |
|
征文信息修改 |
//征文信息修改 //变化数值,email,phone comaddress void testUpdateinfo() { String[] test1 =new String[] { "石家庄铁道大学","河北省石家庄市","www.website.com","3176080045@qq.com","赵常恒","054600","1356942","19930502297","starr","河北","text","techname" String[] test2 =new String[] { "石家庄铁道大学","河北省铁道大学","www.website.com","www.baidu.com","赵常恒","054600","1356942","15028884162","starr","河北","text","techname"
}; String sql = "insert into information(companyname,comaddress,comwebsite,email,lawperson,postal,contacts,phone,fax" + ",insattr,belongcom,summary,techname,techchat,discuss,subject,domain,vocation," + "togemodern,togecom,status,money,belongarea,totime,telphone,keyword) " + "values('" + companyname + "','" + comaddress+ "','" + comwebsite + "','" + email +"','" + lawperson +
"','" + postal +"','" + contacts +"','" + phone +"','" + fax +"','" + insattr +"','" + belongcom +"','" + summary +"','" + techname + "','" + techchat +"','" + discuss +"','" + subject +"','" + domain +"','" + vocation +"','" + togemodern +"','" + togecom +"','" + status + keyword +"')"; try { if(MessageService.update(sql)) { System.out.println("征文信息修改成功"); System.out.println(); } } catch (Exception e) { System.out.println(e); }
if(MessageService.update(sql)) { System.out.println("征文信息修改成功"); System.out.println(); } } catch (Exception e) { System.out.println(e); } |
通过 |
|
测试结果 |
征文信息模块测试通过 |
模块功能 |
统计查询模块 |
||
程序结构 |
功能点 |
涉及的方法 |
|
按类别查询 |
方法1:public static List<Area> getarea(String sql) 功能说明:按类别查询 并转换为JSONG格式 参数描述:String sql sql 查询语句 输出:Json查询 异常: 流程:输入sql 查询数据库 返回类别数据 方法2:页面测试 |
||
精确查询模块 |
采用页面测试,后台代码同类别测试相似 |
||
查询所有征文信息模块 |
方法1:public static userInfo searchinfo(String sql) 功能说明:查询所有征集信息模块 参数描述: String sql 查询语句 异常: 流程:输入sql 查询数据库 返回征文信息数据 方法2:页面测试 |
||
测试用例 |
测试功能点 |
用例描述 |
用例测试结果 |
类别查询 |
方法1: String information="techchat"; String sql="select "+information+" as leibie,count(*) as num from information group by "+information+" "; try { List<echarts> echartslist= MessageService.getechartsdata(sql); //list转Json JSONArray Js = JSONArray.fromObject(echartslist); System.out.println(Js); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } 输出效果: [{"areaname":"石家庄市","code":"130100"},{"areaname":"唐山市","code":"130200"},{"areaname":"秦皇岛市","code":"130300"},{"areaname":"邯郸市","code":"130400"},{"areaname":"邢台市","code":"130500"},{"areaname":"保定市","code":"130600"},{"areaname":"张家口市","code":"130700"},{"areaname":"承德市","code":"130800"} 使用界面进行单元测试: 进入搜索查询界面输入要查询的信息,选择输入【地域】,,点击【搜索】按钮后,浏览界面能正确的显示所有满足名称模糊查询条件的结果信息; |
通过 |
|
精确查询模块 |
进入搜索查询界面输入要查询的信息,选择输入【地域】,【时间】,【公司】,【法人】,,点击【搜索】按钮后,浏览界面能正确的显示所有满足名称查询条件的结果信息; |
通过 |
|
查询所有征文信息模块 |
代码测试: String sql="select * from information"; 返回数据转换为Json格式 |
通过 |
|
测试结果 |
统计查询模块通过 |
||
模块功能 |
图表展示模块 |
||
程序结构 |
功能点 |
涉及的方法 |
|
Json数据展示 |
方法1:public static List<echarts> getechartsdata(String sql) 功能说明:类别查询 并转换为JSONG格式 参数描述:String sql sql 查询语句 输出:Json数据 异常: 流程:输入sql 查询数据库 返回类别数据 方法2:页面测试 |
||
测试用例 |
测试功能点 |
用例描述 |
用例测试结果 |
Json数据展示 |
方法1: String information="comaddress" ; String information2="tomcat" String sql="select "+information+" as leibie,count(*) as num from information group by "+information+" "; try { List<echarts> echartslist= MessageService.getechartsdata(sql); //list转Json JSONArray Js = JSONArray.fromObject(echartslist); System.out.println(Js); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } 输出部分展示: [{"areaname":"石家庄市","code":"130100"},{"areaname":"唐山市","code":"130200"},{"areaname":"秦皇岛市","code":"130300"},{"areaname":"邯郸市","code":"130400"},{"areaname":"邢台市","code":"130500"},{"areaname":"保定市","code":"130600"},{"areaname":"张家口市","code":"130700"},{"areaname":"承德市","code":"130800"}
{"leibie":"北京市丰台区南大红门路1号","num":1},{"leibie":"北京市东城区王府井帅府园1号","num":2},{"leibie":"北京市海淀区交大东路66号院钻河中心1号楼2层233室",号",num":京市海淀区上地四街9号四方大厦","num":1},{"leibie":"北京市海淀区中关村南三街16号D座812号","num":1},{"leibie":"北京市北三环东路18号","num":1},{"leibie":"石铁大","num":1}] 使用界面进行单元测试: 进入搜索查询界面输入要查询的信息,选择输入【地域】,,点击【搜索】按钮后,浏览界面能正确的显示所有满足名称模糊查询条件的结果信息; |
通过 |
|
测试结果 |
图表展示模块通过 |
测试代码:
package com.service; import static org.junit.jupiter.api.Assertions.*; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; import com.mysql.cj.protocol.Message; import User.Alldata; import User.echarts; import User.userInfo; import User.xsdate; class MessageServiceTest { @Test //注册测试 void testAdd() { System.out.println("Register Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "insert into user(username,password,employee,factoryname,postal,premission) values('" + a[i][0] + "','" + a[i][1] + "','" + a[i][2] + "','" + a[i][3] +"','" + a[i][4] +"','" + a[i][5] + "')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" factor:"+a[i][3]+" postal:"+a[0][4]+" permession:"+a[0][5]+" Return:"+MessageService.add(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" factor:"+"none"+" postal:"+"none"+" permession:"+"none"+" Return:"+MessageService.add(sql)); } @Test //登录测试 void testLogin() { // String[][] a= {{"赵常恒","123456","inperson"},{"zzm","zzm9251","inperson"},{"zchzzm","waod3n","inpersion"},{"infor","infor","inforplace"} ,{"admin","admin","admin"},{"one","one","business"},{"121112","1212","inpersion"},{"error","error","someone"} }; System.out.println("Login Test Case:"); for(int i=0;i<a.length;i++) { String sql="select * from user where (username='" + a[i][0] + "' and password='" +a[i][1]+ "' and employee='"+a[i][1]+"')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" Return:"+MessageService.login(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" Return:"+MessageService.login(sql)); } @Test void testDelete() { System.out.println("Delete Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "delete from user where username='"+a[i][0]+"'and employee='"+a[i][2]+"'"; System.out.println("username:"+a[i][0]+" vertify:"+a[i][2]+" Return:"+MessageService.delete(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" vertify:"+"none"+" Return:"+MessageService.delete(sql)); } @Test //业务测试 void testGetalldate() throws SQLException { List<Alldata> lst = new ArrayList<Alldata>(); String[][] sql= {{"select * from alldate"},{"select * from alldate where id='"+1+"'"}, {"select * from alldate where id='"+2+"'"},{"select * from alldate where id='"+3+"'"} ,{"selec A from alldate" }}; System.out.println("YeWu Test Case"); for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getalldate(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getalldate(sql1)); } //二层产业测试 @Test void testGetxsdate() throws SQLException { List<xsdate> lst = new ArrayList<xsdate>(); String[] xtypeid= {"1","2","3","4","5"}; System.out.println("Factory Test Case"); for(int i=0;i<xtypeid.length;i++) { String sql="select * from xsdate where xtypeid='"+Integer.parseInt(xtypeid[i])+"'"; System.out.println("xtypeid"+xtypeid[i]+" Return:"+MessageService.getalldate(sql)); MessageService.getxsdate(sql); } String sql="xxx"; System.out.println("xtypeid"+"none"+" Return:"+MessageService.getalldate(sql)); } //图表数据测试 @Test void testGetechartsdata() throws SQLException { List<echarts> lst = new ArrayList<echarts>(); System.out.println("Echarts Test Case"); String[] information= {"comaddress","companyname","discuss","voation","test"}; for(int i=0;i<information.length;i++) { String sql="select "+information[i]+" as leibie,count(*) as num from information group by "+information[i]+" "; System.out.println("类别:"+information[i]+" Return:"+MessageService.getechartsdata(sql)); } String sql="xxx"; System.out.println("类别:"+"none"+" Return:"+MessageService.getechartsdata(sql)); } @Test //页面分类查询测试 void testGetlayuiinfonum() throws SQLException { System.out.println("Layui Num Test Case"); String[][] test= {{"companyname","天津科技大学"},{"comaddress","天津市河西区大沽南路1038号"},{"insattr","高等院校"},{"insattr","测试"}}; for(int i=0;i<test.length;i++) { String sql="select count(*) as num from information where "+test[i][0]+" like '"+test[i][1]+"' "; System.out.println("Key: "+test[i][0]+" content:"+test[i][1]+" Return:"+MessageService.getlayuiinfonum(sql)); } String sql="xxx"; System.out.println("Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfonum(sql)); } @Test void testGetuserpremission() throws SQLException { System.out.println("Permission Test Case"); String[][] test= {{"infor","inforplace"},{"admin","admin"},{"one","business"},{"123456","inperson"},{"noexist","noexist"}}; for(int i=0;i<test.length;i++) { String sql="select premission from user where username='"+test[i][0]+"'employee='"+test[i][1]+"'"; System.out.println("username:"+test[i][0]+" emplyee:"+test[i][1]+" Return:"+MessageService.getuserpremission(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" emplyee:"+"none"+" Return:"+MessageService.getuserpremission(sql)); } @Test void testGetlayuiinfo() throws NumberFormatException, SQLException { System.out.println("LayuiInfo Test Case"); String[][] test= {{"1","companyname","天津科技大学"},{"1","comaddress","天津市河西区大沽南路1038号"},{"1","insattr","高等院校"},{"1","insattr","测试"}, {"2","companyname","天津科技大学"},{"3","comaddress","天津市河西区大沽南路1038号"},{"4","insattr","高等院校"}}; for(int i=0;i<test.length;i++) { String sql="select * from information where "+test[i][1]+" like '"+test[i][2]+"' "; System.out.println("page:"+test[i][0]+" Key: "+test[i][1]+" content:"+test[i][2]+" Return:"+MessageService.getlayuiinfo(Integer.parseInt(test[i][0]), 20, sql)); } String sql="xxx"; System.out.println("page:"+"none"+" Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfo(1, 20, sql)); } @Test void testGetmessage() throws SQLException { System.out.println("DemandInfo Test Case"); List<userInfo> lst = new ArrayList<userInfo>(); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"select A from information" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getmessage(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getmessage(sql1)); } @Test //征文信息状态修改 void testUpdate() { String[] status=new String[] { "0","1","3"}; //id=531 文件ID 正确测试 最终status=3 int id=531; //普通转形式审核 True String sql1 = "update information set status='" + status[1] + "' where id='" + id + "'"; //形式转部门 True String sql2 = "update information set status='" + status[2] + "' where id='" + id + "'"; if (MessageService.update(sql1)) { System.out.println("形式审核通过"); if (MessageService.update(sql2)) { System.out.println("部门审核通过"); } } } @Test //信息查询 void testSearchinfo() { System.out.println("DemandSearchInfo Test Case"); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchinfo(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchinfo(sql1)); } @Test //用户查询 void testSearchmess() { System.out.println("UserSearchInfo Test Case"); String[][] sql= {{"select * from user"},{"select * from user where id='"+1+"'"}, {"select * from user where id='"+99+"'"},{"select * from user where id='"+5+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchmess(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchmess(sql1)); } @Test //地域查询 void testGetarea() throws SQLException { System.out.println("Area Test Case"); int [] j= {1}; String[][] sql= {{"select * from area"},{"select areaname from area where code='"+130100+"'"}, {"select * from area where id='"+10+"'"},{"selec A from alldate" },{"select * from area where id='"+j[0]+"'"} }; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getarea(sql[i][0])); } for(int i=0;i<j.length;i++) { System.out.println("测试语句"+sql[4][0]+" Return:"+MessageService.getarea(sql[i][0])); j[0]++; } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getarea(sql1)); } }
package com.service; import static org.junit.jupiter.api.Assertions.*; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; import com.mysql.cj.protocol.Message; import User.Alldata; import User.echarts; import User.userInfo; import User.xsdate; class MessageServiceTest { @Test //注册测试 void testAdd() { System.out.println("Register Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "insert into user(username,password,employee,factoryname,postal,premission) values('" + a[i][0] + "','" + a[i][1] + "','" + a[i][2] + "','" + a[i][3] +"','" + a[i][4] +"','" + a[i][5] + "')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" factor:"+a[i][3]+" postal:"+a[0][4]+" permession:"+a[0][5]+" Return:"+MessageService.add(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" factor:"+"none"+" postal:"+"none"+" permession:"+"none"+" Return:"+MessageService.add(sql)); } @Test //登录测试 void testLogin() { // String[][] a= {{"赵常恒","123456","inperson"},{"zzm","zzm9251","inperson"},{"zchzzm","waod3n","inpersion"},{"infor","infor","inforplace"} ,{"admin","admin","admin"},{"one","one","business"},{"121112","1212","inpersion"},{"error","error","someone"} }; System.out.println("Login Test Case:"); for(int i=0;i<a.length;i++) { String sql="select * from user where (username='" + a[i][0] + "' and password='" +a[i][1]+ "' and employee='"+a[i][1]+"')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" Return:"+MessageService.login(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" Return:"+MessageService.login(sql)); } @Test void testDelete() { System.out.println("Delete Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "delete from user where username='"+a[i][0]+"'and employee='"+a[i][2]+"'"; System.out.println("username:"+a[i][0]+" vertify:"+a[i][2]+" Return:"+MessageService.delete(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" vertify:"+"none"+" Return:"+MessageService.delete(sql)); } @Test //业务测试 void testGetalldate() throws SQLException { List<Alldata> lst = new ArrayList<Alldata>(); String[][] sql= {{"select * from alldate"},{"select * from alldate where id='"+1+"'"}, {"select * from alldate where id='"+2+"'"},{"select * from alldate where id='"+3+"'"} ,{"selec A from alldate" }}; System.out.println("YeWu Test Case"); for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getalldate(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getalldate(sql1)); } //二层产业测试 @Test void testGetxsdate() throws SQLException { List<xsdate> lst = new ArrayList<xsdate>(); String[] xtypeid= {"1","2","3","4","5"}; System.out.println("Factory Test Case"); for(int i=0;i<xtypeid.length;i++) { String sql="select * from xsdate where xtypeid='"+Integer.parseInt(xtypeid[i])+"'"; System.out.println("xtypeid"+xtypeid[i]+" Return:"+MessageService.getalldate(sql)); MessageService.getxsdate(sql); } String sql="xxx"; System.out.println("xtypeid"+"none"+" Return:"+MessageService.getalldate(sql)); } //图表数据测试 @Test void testGetechartsdata() throws SQLException { List<echarts> lst = new ArrayList<echarts>(); System.out.println("Echarts Test Case"); String[] information= {"comaddress","companyname","discuss","voation","test"}; for(int i=0;i<information.length;i++) { String sql="select "+information[i]+" as leibie,count(*) as num from information group by "+information[i]+" "; System.out.println("类别:"+information[i]+" Return:"+MessageService.getechartsdata(sql)); } String sql="xxx"; System.out.println("类别:"+"none"+" Return:"+MessageService.getechartsdata(sql)); } @Test //页面分类查询测试 void testGetlayuiinfonum() throws SQLException { System.out.println("Layui Num Test Case"); String[][] test= {{"companyname","天津科技大学"},{"comaddress","天津市河西区大沽南路1038号"},{"insattr","高等院校"},{"insattr","测试"}}; for(int i=0;i<test.length;i++) { String sql="select count(*) as num from information where "+test[i][0]+" like '"+test[i][1]+"' "; System.out.println("Key: "+test[i][0]+" content:"+test[i][1]+" Return:"+MessageService.getlayuiinfonum(sql)); } String sql="xxx"; System.out.println("Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfonum(sql)); } @Test void testGetuserpremission() throws SQLException { System.out.println("Permission Test Case"); String[][] test= {{"infor","inforplace"},{"admin","admin"},{"one","business"},{"123456","inperson"},{"noexist","noexist"}}; for(int i=0;i<test.length;i++) { String sql="select premission from user where username='"+test[i][0]+"'employee='"+test[i][1]+"'"; System.out.println("username:"+test[i][0]+" emplyee:"+test[i][1]+" Return:"+MessageService.getuserpremission(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" emplyee:"+"none"+" Return:"+MessageService.getuserpremission(sql)); } @Test void testGetlayuiinfo() throws NumberFormatException, SQLException { System.out.println("LayuiInfo Test Case"); String[][] test= {{"1","companyname","天津科技大学"},{"1","comaddress","天津市河西区大沽南路1038号"},{"1","insattr","高等院校"},{"1","insattr","测试"}, {"2","companyname","天津科技大学"},{"3","comaddress","天津市河西区大沽南路1038号"},{"4","insattr","高等院校"}}; for(int i=0;i<test.length;i++) { String sql="select * from information where "+test[i][1]+" like '"+test[i][2]+"' "; System.out.println("page:"+test[i][0]+" Key: "+test[i][1]+" content:"+test[i][2]+" Return:"+MessageService.getlayuiinfo(Integer.parseInt(test[i][0]), 20, sql)); } String sql="xxx"; System.out.println("page:"+"none"+" Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfo(1, 20, sql)); } @Test void testGetmessage() throws SQLException { System.out.println("DemandInfo Test Case"); List<userInfo> lst = new ArrayList<userInfo>(); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"select A from information" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getmessage(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getmessage(sql1)); } @Test //征文信息状态修改 void testUpdate() { String[] status=new String[] { "0","1","3"}; //id=531 文件ID 正确测试 最终status=3 int id=531; //普通转形式审核 True String sql1 = "update information set status='" + status[1] + "' where id='" + id + "'"; //形式转部门 True String sql2 = "update information set status='" + status[2] + "' where id='" + id + "'"; if (MessageService.update(sql1)) { System.out.println("形式审核通过"); if (MessageService.update(sql2)) { System.out.println("部门审核通过"); } } } @Test //信息查询 void testSearchinfo() { System.out.println("DemandSearchInfo Test Case"); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchinfo(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchinfo(sql1)); } @Test //用户查询 void testSearchmess() { System.out.println("UserSearchInfo Test Case"); String[][] sql= {{"select * from user"},{"select * from user where id='"+1+"'"}, {"select * from user where id='"+99+"'"},{"select * from user where id='"+5+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchmess(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchmess(sql1)); } @Test //地域查询 void testGetarea() throws SQLException { System.out.println("Area Test Case"); int [] j= {1}; String[][] sql= {{"select * from area"},{"select areaname from area where code='"+130100+"'"}, {"select * from area where id='"+10+"'"},{"selec A from alldate" },{"select * from area where id='"+j[0]+"'"} }; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getarea(sql[i][0])); } for(int i=0;i<j.length;i++) { System.out.println("测试语句"+sql[4][0]+" Return:"+MessageService.getarea(sql[i][0])); j[0]++; } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getarea(sql1)); } }
package com.service; import static org.junit.jupiter.api.Assertions.*; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; import com.mysql.cj.protocol.Message; import User.Alldata; import User.echarts; import User.userInfo; import User.xsdate; class MessageServiceTest { @Test //注册测试 void testAdd() { System.out.println("Register Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "insert into user(username,password,employee,factoryname,postal,premission) values('" + a[i][0] + "','" + a[i][1] + "','" + a[i][2] + "','" + a[i][3] +"','" + a[i][4] +"','" + a[i][5] + "')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" factor:"+a[i][3]+" postal:"+a[0][4]+" permession:"+a[0][5]+" Return:"+MessageService.add(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" factor:"+"none"+" postal:"+"none"+" permession:"+"none"+" Return:"+MessageService.add(sql)); } @Test //登录测试 void testLogin() { // String[][] a= {{"赵常恒","123456","inperson"},{"zzm","zzm9251","inperson"},{"zchzzm","waod3n","inpersion"},{"infor","infor","inforplace"} ,{"admin","admin","admin"},{"one","one","business"},{"121112","1212","inpersion"},{"error","error","someone"} }; System.out.println("Login Test Case:"); for(int i=0;i<a.length;i++) { String sql="select * from user where (username='" + a[i][0] + "' and password='" +a[i][1]+ "' and employee='"+a[i][1]+"')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" Return:"+MessageService.login(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" Return:"+MessageService.login(sql)); } @Test void testDelete() { System.out.println("Delete Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "delete from user where username='"+a[i][0]+"'and employee='"+a[i][2]+"'"; System.out.println("username:"+a[i][0]+" vertify:"+a[i][2]+" Return:"+MessageService.delete(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" vertify:"+"none"+" Return:"+MessageService.delete(sql)); } @Test //业务测试 void testGetalldate() throws SQLException { List<Alldata> lst = new ArrayList<Alldata>(); String[][] sql= {{"select * from alldate"},{"select * from alldate where id='"+1+"'"}, {"select * from alldate where id='"+2+"'"},{"select * from alldate where id='"+3+"'"} ,{"selec A from alldate" }}; System.out.println("YeWu Test Case"); for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getalldate(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getalldate(sql1)); } //二层产业测试 @Test void testGetxsdate() throws SQLException { List<xsdate> lst = new ArrayList<xsdate>(); String[] xtypeid= {"1","2","3","4","5"}; System.out.println("Factory Test Case"); for(int i=0;i<xtypeid.length;i++) { String sql="select * from xsdate where xtypeid='"+Integer.parseInt(xtypeid[i])+"'"; System.out.println("xtypeid"+xtypeid[i]+" Return:"+MessageService.getalldate(sql)); MessageService.getxsdate(sql); } String sql="xxx"; System.out.println("xtypeid"+"none"+" Return:"+MessageService.getalldate(sql)); } //图表数据测试 @Test void testGetechartsdata() throws SQLException { List<echarts> lst = new ArrayList<echarts>(); System.out.println("Echarts Test Case"); String[] information= {"comaddress","companyname","discuss","voation","test"}; for(int i=0;i<information.length;i++) { String sql="select "+information[i]+" as leibie,count(*) as num from information group by "+information[i]+" "; System.out.println("类别:"+information[i]+" Return:"+MessageService.getechartsdata(sql)); } String sql="xxx"; System.out.println("类别:"+"none"+" Return:"+MessageService.getechartsdata(sql)); } @Test //页面分类查询测试 void testGetlayuiinfonum() throws SQLException { System.out.println("Layui Num Test Case"); String[][] test= {{"companyname","天津科技大学"},{"comaddress","天津市河西区大沽南路1038号"},{"insattr","高等院校"},{"insattr","测试"}}; for(int i=0;i<test.length;i++) { String sql="select count(*) as num from information where "+test[i][0]+" like '"+test[i][1]+"' "; System.out.println("Key: "+test[i][0]+" content:"+test[i][1]+" Return:"+MessageService.getlayuiinfonum(sql)); } String sql="xxx"; System.out.println("Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfonum(sql)); } @Test void testGetuserpremission() throws SQLException { System.out.println("Permission Test Case"); String[][] test= {{"infor","inforplace"},{"admin","admin"},{"one","business"},{"123456","inperson"},{"noexist","noexist"}}; for(int i=0;i<test.length;i++) { String sql="select premission from user where username='"+test[i][0]+"'employee='"+test[i][1]+"'"; System.out.println("username:"+test[i][0]+" emplyee:"+test[i][1]+" Return:"+MessageService.getuserpremission(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" emplyee:"+"none"+" Return:"+MessageService.getuserpremission(sql)); } @Test void testGetlayuiinfo() throws NumberFormatException, SQLException { System.out.println("LayuiInfo Test Case"); String[][] test= {{"1","companyname","天津科技大学"},{"1","comaddress","天津市河西区大沽南路1038号"},{"1","insattr","高等院校"},{"1","insattr","测试"}, {"2","companyname","天津科技大学"},{"3","comaddress","天津市河西区大沽南路1038号"},{"4","insattr","高等院校"}}; for(int i=0;i<test.length;i++) { String sql="select * from information where "+test[i][1]+" like '"+test[i][2]+"' "; System.out.println("page:"+test[i][0]+" Key: "+test[i][1]+" content:"+test[i][2]+" Return:"+MessageService.getlayuiinfo(Integer.parseInt(test[i][0]), 20, sql)); } String sql="xxx"; System.out.println("page:"+"none"+" Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfo(1, 20, sql)); } @Test void testGetmessage() throws SQLException { System.out.println("DemandInfo Test Case"); List<userInfo> lst = new ArrayList<userInfo>(); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"select A from information" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getmessage(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getmessage(sql1)); } @Test //征文信息状态修改 void testUpdate() { String[] status=new String[] { "0","1","3"}; //id=531 文件ID 正确测试 最终status=3 int id=531; //普通转形式审核 True String sql1 = "update information set status='" + status[1] + "' where id='" + id + "'"; //形式转部门 True String sql2 = "update information set status='" + status[2] + "' where id='" + id + "'"; if (MessageService.update(sql1)) { System.out.println("形式审核通过"); if (MessageService.update(sql2)) { System.out.println("部门审核通过"); } } } @Test //信息查询 void testSearchinfo() { System.out.println("DemandSearchInfo Test Case"); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchinfo(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchinfo(sql1)); } @Test //用户查询 void testSearchmess() { System.out.println("UserSearchInfo Test Case"); String[][] sql= {{"select * from user"},{"select * from user where id='"+1+"'"}, {"select * from user where id='"+99+"'"},{"select * from user where id='"+5+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchmess(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchmess(sql1)); } @Test //地域查询 void testGetarea() throws SQLException { System.out.println("Area Test Case"); int [] j= {1}; String[][] sql= {{"select * from area"},{"select areaname from area where code='"+130100+"'"}, {"select * from area where id='"+10+"'"},{"selec A from alldate" },{"select * from area where id='"+j[0]+"'"} }; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getarea(sql[i][0])); } for(int i=0;i<j.length;i++) { System.out.println("测试语句"+sql[4][0]+" Return:"+MessageService.getarea(sql[i][0])); j[0]++; } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getarea(sql1)); } }
package com.service; import static org.junit.jupiter.api.Assertions.*; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; import com.mysql.cj.protocol.Message; import User.Alldata; import User.echarts; import User.userInfo; import User.xsdate; class MessageServiceTest { @Test //注册测试 void testAdd() { System.out.println("Register Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "insert into user(username,password,employee,factoryname,postal,premission) values('" + a[i][0] + "','" + a[i][1] + "','" + a[i][2] + "','" + a[i][3] +"','" + a[i][4] +"','" + a[i][5] + "')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" factor:"+a[i][3]+" postal:"+a[0][4]+" permession:"+a[0][5]+" Return:"+MessageService.add(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" factor:"+"none"+" postal:"+"none"+" permession:"+"none"+" Return:"+MessageService.add(sql)); } @Test //登录测试 void testLogin() { // String[][] a= {{"赵常恒","123456","inperson"},{"zzm","zzm9251","inperson"},{"zchzzm","waod3n","inpersion"},{"infor","infor","inforplace"} ,{"admin","admin","admin"},{"one","one","business"},{"121112","1212","inpersion"},{"error","error","someone"} }; System.out.println("Login Test Case:"); for(int i=0;i<a.length;i++) { String sql="select * from user where (username='" + a[i][0] + "' and password='" +a[i][1]+ "' and employee='"+a[i][1]+"')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" Return:"+MessageService.login(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" Return:"+MessageService.login(sql)); } @Test void testDelete() { System.out.println("Delete Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "delete from user where username='"+a[i][0]+"'and employee='"+a[i][2]+"'"; System.out.println("username:"+a[i][0]+" vertify:"+a[i][2]+" Return:"+MessageService.delete(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" vertify:"+"none"+" Return:"+MessageService.delete(sql)); } @Test //业务测试 void testGetalldate() throws SQLException { List<Alldata> lst = new ArrayList<Alldata>(); String[][] sql= {{"select * from alldate"},{"select * from alldate where id='"+1+"'"}, {"select * from alldate where id='"+2+"'"},{"select * from alldate where id='"+3+"'"} ,{"selec A from alldate" }}; System.out.println("YeWu Test Case"); for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getalldate(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getalldate(sql1)); } //二层产业测试 @Test void testGetxsdate() throws SQLException { List<xsdate> lst = new ArrayList<xsdate>(); String[] xtypeid= {"1","2","3","4","5"}; System.out.println("Factory Test Case"); for(int i=0;i<xtypeid.length;i++) { String sql="select * from xsdate where xtypeid='"+Integer.parseInt(xtypeid[i])+"'"; System.out.println("xtypeid"+xtypeid[i]+" Return:"+MessageService.getalldate(sql)); MessageService.getxsdate(sql); } String sql="xxx"; System.out.println("xtypeid"+"none"+" Return:"+MessageService.getalldate(sql)); } //图表数据测试 @Test void testGetechartsdata() throws SQLException { List<echarts> lst = new ArrayList<echarts>(); System.out.println("Echarts Test Case"); String[] information= {"comaddress","companyname","discuss","voation","test"}; for(int i=0;i<information.length;i++) { String sql="select "+information[i]+" as leibie,count(*) as num from information group by "+information[i]+" "; System.out.println("类别:"+information[i]+" Return:"+MessageService.getechartsdata(sql)); } String sql="xxx"; System.out.println("类别:"+"none"+" Return:"+MessageService.getechartsdata(sql)); } @Test //页面分类查询测试 void testGetlayuiinfonum() throws SQLException { System.out.println("Layui Num Test Case"); String[][] test= {{"companyname","天津科技大学"},{"comaddress","天津市河西区大沽南路1038号"},{"insattr","高等院校"},{"insattr","测试"}}; for(int i=0;i<test.length;i++) { String sql="select count(*) as num from information where "+test[i][0]+" like '"+test[i][1]+"' "; System.out.println("Key: "+test[i][0]+" content:"+test[i][1]+" Return:"+MessageService.getlayuiinfonum(sql)); } String sql="xxx"; System.out.println("Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfonum(sql)); } @Test void testGetuserpremission() throws SQLException { System.out.println("Permission Test Case"); String[][] test= {{"infor","inforplace"},{"admin","admin"},{"one","business"},{"123456","inperson"},{"noexist","noexist"}}; for(int i=0;i<test.length;i++) { String sql="select premission from user where username='"+test[i][0]+"'employee='"+test[i][1]+"'"; System.out.println("username:"+test[i][0]+" emplyee:"+test[i][1]+" Return:"+MessageService.getuserpremission(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" emplyee:"+"none"+" Return:"+MessageService.getuserpremission(sql)); } @Test void testGetlayuiinfo() throws NumberFormatException, SQLException { System.out.println("LayuiInfo Test Case"); String[][] test= {{"1","companyname","天津科技大学"},{"1","comaddress","天津市河西区大沽南路1038号"},{"1","insattr","高等院校"},{"1","insattr","测试"}, {"2","companyname","天津科技大学"},{"3","comaddress","天津市河西区大沽南路1038号"},{"4","insattr","高等院校"}}; for(int i=0;i<test.length;i++) { String sql="select * from information where "+test[i][1]+" like '"+test[i][2]+"' "; System.out.println("page:"+test[i][0]+" Key: "+test[i][1]+" content:"+test[i][2]+" Return:"+MessageService.getlayuiinfo(Integer.parseInt(test[i][0]), 20, sql)); } String sql="xxx"; System.out.println("page:"+"none"+" Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfo(1, 20, sql)); } @Test void testGetmessage() throws SQLException { System.out.println("DemandInfo Test Case"); List<userInfo> lst = new ArrayList<userInfo>(); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"select A from information" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getmessage(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getmessage(sql1)); } @Test //征文信息状态修改 void testUpdate() { String[] status=new String[] { "0","1","3"}; //id=531 文件ID 正确测试 最终status=3 int id=531; //普通转形式审核 True String sql1 = "update information set status='" + status[1] + "' where id='" + id + "'"; //形式转部门 True String sql2 = "update information set status='" + status[2] + "' where id='" + id + "'"; if (MessageService.update(sql1)) { System.out.println("形式审核通过"); if (MessageService.update(sql2)) { System.out.println("部门审核通过"); } } } @Test //信息查询 void testSearchinfo() { System.out.println("DemandSearchInfo Test Case"); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchinfo(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchinfo(sql1)); } @Test //用户查询 void testSearchmess() { System.out.println("UserSearchInfo Test Case"); String[][] sql= {{"select * from user"},{"select * from user where id='"+1+"'"}, {"select * from user where id='"+99+"'"},{"select * from user where id='"+5+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchmess(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchmess(sql1)); } @Test //地域查询 void testGetarea() throws SQLException { System.out.println("Area Test Case"); int [] j= {1}; String[][] sql= {{"select * from area"},{"select areaname from area where code='"+130100+"'"}, {"select * from area where id='"+10+"'"},{"selec A from alldate" },{"select * from area where id='"+j[0]+"'"} }; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getarea(sql[i][0])); } for(int i=0;i<j.length;i++) { System.out.println("测试语句"+sql[4][0]+" Return:"+MessageService.getarea(sql[i][0])); j[0]++; } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getarea(sql1)); } }
package com.service; import static org.junit.jupiter.api.Assertions.*; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; import com.mysql.cj.protocol.Message; import User.Alldata; import User.echarts; import User.userInfo; import User.xsdate; class MessageServiceTest { @Test //注册测试 void testAdd() { System.out.println("Register Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "insert into user(username,password,employee,factoryname,postal,premission) values('" + a[i][0] + "','" + a[i][1] + "','" + a[i][2] + "','" + a[i][3] +"','" + a[i][4] +"','" + a[i][5] + "')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" factor:"+a[i][3]+" postal:"+a[0][4]+" permession:"+a[0][5]+" Return:"+MessageService.add(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" factor:"+"none"+" postal:"+"none"+" permession:"+"none"+" Return:"+MessageService.add(sql)); } @Test //登录测试 void testLogin() { // String[][] a= {{"赵常恒","123456","inperson"},{"zzm","zzm9251","inperson"},{"zchzzm","waod3n","inpersion"},{"infor","infor","inforplace"} ,{"admin","admin","admin"},{"one","one","business"},{"121112","1212","inpersion"},{"error","error","someone"} }; System.out.println("Login Test Case:"); for(int i=0;i<a.length;i++) { String sql="select * from user where (username='" + a[i][0] + "' and password='" +a[i][1]+ "' and employee='"+a[i][1]+"')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" Return:"+MessageService.login(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" Return:"+MessageService.login(sql)); } @Test void testDelete() { System.out.println("Delete Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "delete from user where username='"+a[i][0]+"'and employee='"+a[i][2]+"'"; System.out.println("username:"+a[i][0]+" vertify:"+a[i][2]+" Return:"+MessageService.delete(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" vertify:"+"none"+" Return:"+MessageService.delete(sql)); } @Test //业务测试 void testGetalldate() throws SQLException { List<Alldata> lst = new ArrayList<Alldata>(); String[][] sql= {{"select * from alldate"},{"select * from alldate where id='"+1+"'"}, {"select * from alldate where id='"+2+"'"},{"select * from alldate where id='"+3+"'"} ,{"selec A from alldate" }}; System.out.println("YeWu Test Case"); for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getalldate(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getalldate(sql1)); } //二层产业测试 @Test void testGetxsdate() throws SQLException { List<xsdate> lst = new ArrayList<xsdate>(); String[] xtypeid= {"1","2","3","4","5"}; System.out.println("Factory Test Case"); for(int i=0;i<xtypeid.length;i++) { String sql="select * from xsdate where xtypeid='"+Integer.parseInt(xtypeid[i])+"'"; System.out.println("xtypeid"+xtypeid[i]+" Return:"+MessageService.getalldate(sql)); MessageService.getxsdate(sql); } String sql="xxx"; System.out.println("xtypeid"+"none"+" Return:"+MessageService.getalldate(sql)); } //图表数据测试 @Test void testGetechartsdata() throws SQLException { List<echarts> lst = new ArrayList<echarts>(); System.out.println("Echarts Test Case"); String[] information= {"comaddress","companyname","discuss","voation","test"}; for(int i=0;i<information.length;i++) { String sql="select "+information[i]+" as leibie,count(*) as num from information group by "+information[i]+" "; System.out.println("类别:"+information[i]+" Return:"+MessageService.getechartsdata(sql)); } String sql="xxx"; System.out.println("类别:"+"none"+" Return:"+MessageService.getechartsdata(sql)); } @Test //页面分类查询测试 void testGetlayuiinfonum() throws SQLException { System.out.println("Layui Num Test Case"); String[][] test= {{"companyname","天津科技大学"},{"comaddress","天津市河西区大沽南路1038号"},{"insattr","高等院校"},{"insattr","测试"}}; for(int i=0;i<test.length;i++) { String sql="select count(*) as num from information where "+test[i][0]+" like '"+test[i][1]+"' "; System.out.println("Key: "+test[i][0]+" content:"+test[i][1]+" Return:"+MessageService.getlayuiinfonum(sql)); } String sql="xxx"; System.out.println("Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfonum(sql)); } @Test void testGetuserpremission() throws SQLException { System.out.println("Permission Test Case"); String[][] test= {{"infor","inforplace"},{"admin","admin"},{"one","business"},{"123456","inperson"},{"noexist","noexist"}}; for(int i=0;i<test.length;i++) { String sql="select premission from user where username='"+test[i][0]+"'employee='"+test[i][1]+"'"; System.out.println("username:"+test[i][0]+" emplyee:"+test[i][1]+" Return:"+MessageService.getuserpremission(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" emplyee:"+"none"+" Return:"+MessageService.getuserpremission(sql)); } @Test void testGetlayuiinfo() throws NumberFormatException, SQLException { System.out.println("LayuiInfo Test Case"); String[][] test= {{"1","companyname","天津科技大学"},{"1","comaddress","天津市河西区大沽南路1038号"},{"1","insattr","高等院校"},{"1","insattr","测试"}, {"2","companyname","天津科技大学"},{"3","comaddress","天津市河西区大沽南路1038号"},{"4","insattr","高等院校"}}; for(int i=0;i<test.length;i++) { String sql="select * from information where "+test[i][1]+" like '"+test[i][2]+"' "; System.out.println("page:"+test[i][0]+" Key: "+test[i][1]+" content:"+test[i][2]+" Return:"+MessageService.getlayuiinfo(Integer.parseInt(test[i][0]), 20, sql)); } String sql="xxx"; System.out.println("page:"+"none"+" Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfo(1, 20, sql)); } @Test void testGetmessage() throws SQLException { System.out.println("DemandInfo Test Case"); List<userInfo> lst = new ArrayList<userInfo>(); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"select A from information" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getmessage(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getmessage(sql1)); } @Test //征文信息状态修改 void testUpdate() { String[] status=new String[] { "0","1","3"}; //id=531 文件ID 正确测试 最终status=3 int id=531; //普通转形式审核 True String sql1 = "update information set status='" + status[1] + "' where id='" + id + "'"; //形式转部门 True String sql2 = "update information set status='" + status[2] + "' where id='" + id + "'"; if (MessageService.update(sql1)) { System.out.println("形式审核通过"); if (MessageService.update(sql2)) { System.out.println("部门审核通过"); } } } @Test //信息查询 void testSearchinfo() { System.out.println("DemandSearchInfo Test Case"); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchinfo(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchinfo(sql1)); } @Test //用户查询 void testSearchmess() { System.out.println("UserSearchInfo Test Case"); String[][] sql= {{"select * from user"},{"select * from user where id='"+1+"'"}, {"select * from user where id='"+99+"'"},{"select * from user where id='"+5+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchmess(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchmess(sql1)); } @Test //地域查询 void testGetarea() throws SQLException { System.out.println("Area Test Case"); int [] j= {1}; String[][] sql= {{"select * from area"},{"select areaname from area where code='"+130100+"'"}, {"select * from area where id='"+10+"'"},{"selec A from alldate" },{"select * from area where id='"+j[0]+"'"} }; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getarea(sql[i][0])); } for(int i=0;i<j.length;i++) { System.out.println("测试语句"+sql[4][0]+" Return:"+MessageService.getarea(sql[i][0])); j[0]++; } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getarea(sql1)); } }
package com.service; import static org.junit.jupiter.api.Assertions.*; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; import com.mysql.cj.protocol.Message; import User.Alldata; import User.echarts; import User.userInfo; import User.xsdate; class MessageServiceTest { @Test //注册测试 void testAdd() { System.out.println("Register Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "insert into user(username,password,employee,factoryname,postal,premission) values('" + a[i][0] + "','" + a[i][1] + "','" + a[i][2] + "','" + a[i][3] +"','" + a[i][4] +"','" + a[i][5] + "')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" factor:"+a[i][3]+" postal:"+a[0][4]+" permession:"+a[0][5]+" Return:"+MessageService.add(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" factor:"+"none"+" postal:"+"none"+" permession:"+"none"+" Return:"+MessageService.add(sql)); } @Test //登录测试 void testLogin() { // String[][] a= {{"赵常恒","123456","inperson"},{"zzm","zzm9251","inperson"},{"zchzzm","waod3n","inpersion"},{"infor","infor","inforplace"} ,{"admin","admin","admin"},{"one","one","business"},{"121112","1212","inpersion"},{"error","error","someone"} }; System.out.println("Login Test Case:"); for(int i=0;i<a.length;i++) { String sql="select * from user where (username='" + a[i][0] + "' and password='" +a[i][1]+ "' and employee='"+a[i][1]+"')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" Return:"+MessageService.login(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" Return:"+MessageService.login(sql)); } @Test void testDelete() { System.out.println("Delete Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "delete from user where username='"+a[i][0]+"'and employee='"+a[i][2]+"'"; System.out.println("username:"+a[i][0]+" vertify:"+a[i][2]+" Return:"+MessageService.delete(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" vertify:"+"none"+" Return:"+MessageService.delete(sql)); } @Test //业务测试 void testGetalldate() throws SQLException { List<Alldata> lst = new ArrayList<Alldata>(); String[][] sql= {{"select * from alldate"},{"select * from alldate where id='"+1+"'"}, {"select * from alldate where id='"+2+"'"},{"select * from alldate where id='"+3+"'"} ,{"selec A from alldate" }}; System.out.println("YeWu Test Case"); for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getalldate(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getalldate(sql1)); } //二层产业测试 @Test void testGetxsdate() throws SQLException { List<xsdate> lst = new ArrayList<xsdate>(); String[] xtypeid= {"1","2","3","4","5"}; System.out.println("Factory Test Case"); for(int i=0;i<xtypeid.length;i++) { String sql="select * from xsdate where xtypeid='"+Integer.parseInt(xtypeid[i])+"'"; System.out.println("xtypeid"+xtypeid[i]+" Return:"+MessageService.getalldate(sql)); MessageService.getxsdate(sql); } String sql="xxx"; System.out.println("xtypeid"+"none"+" Return:"+MessageService.getalldate(sql)); } //图表数据测试 @Test void testGetechartsdata() throws SQLException { List<echarts> lst = new ArrayList<echarts>(); System.out.println("Echarts Test Case"); String[] information= {"comaddress","companyname","discuss","voation","test"}; for(int i=0;i<information.length;i++) { String sql="select "+information[i]+" as leibie,count(*) as num from information group by "+information[i]+" "; System.out.println("类别:"+information[i]+" Return:"+MessageService.getechartsdata(sql)); } String sql="xxx"; System.out.println("类别:"+"none"+" Return:"+MessageService.getechartsdata(sql)); } @Test //页面分类查询测试 void testGetlayuiinfonum() throws SQLException { System.out.println("Layui Num Test Case"); String[][] test= {{"companyname","天津科技大学"},{"comaddress","天津市河西区大沽南路1038号"},{"insattr","高等院校"},{"insattr","测试"}}; for(int i=0;i<test.length;i++) { String sql="select count(*) as num from information where "+test[i][0]+" like '"+test[i][1]+"' "; System.out.println("Key: "+test[i][0]+" content:"+test[i][1]+" Return:"+MessageService.getlayuiinfonum(sql)); } String sql="xxx"; System.out.println("Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfonum(sql)); } @Test void testGetuserpremission() throws SQLException { System.out.println("Permission Test Case"); String[][] test= {{"infor","inforplace"},{"admin","admin"},{"one","business"},{"123456","inperson"},{"noexist","noexist"}}; for(int i=0;i<test.length;i++) { String sql="select premission from user where username='"+test[i][0]+"'employee='"+test[i][1]+"'"; System.out.println("username:"+test[i][0]+" emplyee:"+test[i][1]+" Return:"+MessageService.getuserpremission(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" emplyee:"+"none"+" Return:"+MessageService.getuserpremission(sql)); } @Test void testGetlayuiinfo() throws NumberFormatException, SQLException { System.out.println("LayuiInfo Test Case"); String[][] test= {{"1","companyname","天津科技大学"},{"1","comaddress","天津市河西区大沽南路1038号"},{"1","insattr","高等院校"},{"1","insattr","测试"}, {"2","companyname","天津科技大学"},{"3","comaddress","天津市河西区大沽南路1038号"},{"4","insattr","高等院校"}}; for(int i=0;i<test.length;i++) { String sql="select * from information where "+test[i][1]+" like '"+test[i][2]+"' "; System.out.println("page:"+test[i][0]+" Key: "+test[i][1]+" content:"+test[i][2]+" Return:"+MessageService.getlayuiinfo(Integer.parseInt(test[i][0]), 20, sql)); } String sql="xxx"; System.out.println("page:"+"none"+" Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfo(1, 20, sql)); } @Test void testGetmessage() throws SQLException { System.out.println("DemandInfo Test Case"); List<userInfo> lst = new ArrayList<userInfo>(); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"select A from information" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getmessage(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getmessage(sql1)); } @Test //征文信息状态修改 void testUpdate() { String[] status=new String[] { "0","1","3"}; //id=531 文件ID 正确测试 最终status=3 int id=531; //普通转形式审核 True String sql1 = "update information set status='" + status[1] + "' where id='" + id + "'"; //形式转部门 True String sql2 = "update information set status='" + status[2] + "' where id='" + id + "'"; if (MessageService.update(sql1)) { System.out.println("形式审核通过"); if (MessageService.update(sql2)) { System.out.println("部门审核通过"); } } } @Test //信息查询 void testSearchinfo() { System.out.println("DemandSearchInfo Test Case"); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchinfo(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchinfo(sql1)); } @Test //用户查询 void testSearchmess() { System.out.println("UserSearchInfo Test Case"); String[][] sql= {{"select * from user"},{"select * from user where id='"+1+"'"}, {"select * from user where id='"+99+"'"},{"select * from user where id='"+5+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchmess(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchmess(sql1)); } @Test //地域查询 void testGetarea() throws SQLException { System.out.println("Area Test Case"); int [] j= {1}; String[][] sql= {{"select * from area"},{"select areaname from area where code='"+130100+"'"}, {"select * from area where id='"+10+"'"},{"selec A from alldate" },{"select * from area where id='"+j[0]+"'"} }; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getarea(sql[i][0])); } for(int i=0;i<j.length;i++) { System.out.println("测试语句"+sql[4][0]+" Return:"+MessageService.getarea(sql[i][0])); j[0]++; } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getarea(sql1)); } }
package com.service; import static org.junit.jupiter.api.Assertions.*; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; import com.mysql.cj.protocol.Message; import User.Alldata; import User.echarts; import User.userInfo; import User.xsdate; class MessageServiceTest { @Test //注册测试 void testAdd() { System.out.println("Register Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "insert into user(username,password,employee,factoryname,postal,premission) values('" + a[i][0] + "','" + a[i][1] + "','" + a[i][2] + "','" + a[i][3] +"','" + a[i][4] +"','" + a[i][5] + "')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" factor:"+a[i][3]+" postal:"+a[0][4]+" permession:"+a[0][5]+" Return:"+MessageService.add(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" factor:"+"none"+" postal:"+"none"+" permession:"+"none"+" Return:"+MessageService.add(sql)); } @Test //登录测试 void testLogin() { // String[][] a= {{"赵常恒","123456","inperson"},{"zzm","zzm9251","inperson"},{"zchzzm","waod3n","inpersion"},{"infor","infor","inforplace"} ,{"admin","admin","admin"},{"one","one","business"},{"121112","1212","inpersion"},{"error","error","someone"} }; System.out.println("Login Test Case:"); for(int i=0;i<a.length;i++) { String sql="select * from user where (username='" + a[i][0] + "' and password='" +a[i][1]+ "' and employee='"+a[i][1]+"')"; System.out.println("username:"+a[i][0]+" password:"+a[i][1]+" vertify:"+a[i][2]+" Return:"+MessageService.login(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" password:"+"none"+" vertify:"+"none"+" Return:"+MessageService.login(sql)); } @Test void testDelete() { System.out.println("Delete Test Case:"); String[][] a= {{"赵常恒","123456","inperson","factor1","054600","0"},{"zzm","zzm9251","inperson","factor2","054600","0"},{"zchzzm","waod3n","inpersion","factor3","054600","0"},{"infor","infor","inforplace","factor4","054600","0"} ,{"admin","admin","admin","factor5","054600","0"},{"one","one","business","factor6","054600","0"},{"121112","1212","inpersion","factor7","054600","0"},{"error","error","someone","factor8","054600","0"},{"赵常恒","123456","inperson","factor1","054600","0"} }; for(int i=0;i<a.length;i++) { String sql = "delete from user where username='"+a[i][0]+"'and employee='"+a[i][2]+"'"; System.out.println("username:"+a[i][0]+" vertify:"+a[i][2]+" Return:"+MessageService.delete(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" vertify:"+"none"+" Return:"+MessageService.delete(sql)); } @Test //业务测试 void testGetalldate() throws SQLException { List<Alldata> lst = new ArrayList<Alldata>(); String[][] sql= {{"select * from alldate"},{"select * from alldate where id='"+1+"'"}, {"select * from alldate where id='"+2+"'"},{"select * from alldate where id='"+3+"'"} ,{"selec A from alldate" }}; System.out.println("YeWu Test Case"); for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getalldate(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getalldate(sql1)); } //二层产业测试 @Test void testGetxsdate() throws SQLException { List<xsdate> lst = new ArrayList<xsdate>(); String[] xtypeid= {"1","2","3","4","5"}; System.out.println("Factory Test Case"); for(int i=0;i<xtypeid.length;i++) { String sql="select * from xsdate where xtypeid='"+Integer.parseInt(xtypeid[i])+"'"; System.out.println("xtypeid"+xtypeid[i]+" Return:"+MessageService.getalldate(sql)); MessageService.getxsdate(sql); } String sql="xxx"; System.out.println("xtypeid"+"none"+" Return:"+MessageService.getalldate(sql)); } //图表数据测试 @Test void testGetechartsdata() throws SQLException { List<echarts> lst = new ArrayList<echarts>(); System.out.println("Echarts Test Case"); String[] information= {"comaddress","companyname","discuss","voation","test"}; for(int i=0;i<information.length;i++) { String sql="select "+information[i]+" as leibie,count(*) as num from information group by "+information[i]+" "; System.out.println("类别:"+information[i]+" Return:"+MessageService.getechartsdata(sql)); } String sql="xxx"; System.out.println("类别:"+"none"+" Return:"+MessageService.getechartsdata(sql)); } @Test //页面分类查询测试 void testGetlayuiinfonum() throws SQLException { System.out.println("Layui Num Test Case"); String[][] test= {{"companyname","天津科技大学"},{"comaddress","天津市河西区大沽南路1038号"},{"insattr","高等院校"},{"insattr","测试"}}; for(int i=0;i<test.length;i++) { String sql="select count(*) as num from information where "+test[i][0]+" like '"+test[i][1]+"' "; System.out.println("Key: "+test[i][0]+" content:"+test[i][1]+" Return:"+MessageService.getlayuiinfonum(sql)); } String sql="xxx"; System.out.println("Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfonum(sql)); } @Test void testGetuserpremission() throws SQLException { System.out.println("Permission Test Case"); String[][] test= {{"infor","inforplace"},{"admin","admin"},{"one","business"},{"123456","inperson"},{"noexist","noexist"}}; for(int i=0;i<test.length;i++) { String sql="select premission from user where username='"+test[i][0]+"'employee='"+test[i][1]+"'"; System.out.println("username:"+test[i][0]+" emplyee:"+test[i][1]+" Return:"+MessageService.getuserpremission(sql)); } String sql="xxx"; System.out.println("username:"+"none"+" emplyee:"+"none"+" Return:"+MessageService.getuserpremission(sql)); } @Test void testGetlayuiinfo() throws NumberFormatException, SQLException { System.out.println("LayuiInfo Test Case"); String[][] test= {{"1","companyname","天津科技大学"},{"1","comaddress","天津市河西区大沽南路1038号"},{"1","insattr","高等院校"},{"1","insattr","测试"}, {"2","companyname","天津科技大学"},{"3","comaddress","天津市河西区大沽南路1038号"},{"4","insattr","高等院校"}}; for(int i=0;i<test.length;i++) { String sql="select * from information where "+test[i][1]+" like '"+test[i][2]+"' "; System.out.println("page:"+test[i][0]+" Key: "+test[i][1]+" content:"+test[i][2]+" Return:"+MessageService.getlayuiinfo(Integer.parseInt(test[i][0]), 20, sql)); } String sql="xxx"; System.out.println("page:"+"none"+" Key: "+"none"+" content:"+"none"+" Return:"+MessageService.getlayuiinfo(1, 20, sql)); } @Test void testGetmessage() throws SQLException { System.out.println("DemandInfo Test Case"); List<userInfo> lst = new ArrayList<userInfo>(); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"select A from information" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getmessage(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getmessage(sql1)); } @Test //征文信息状态修改 void testUpdate() { String[] status=new String[] { "0","1","3"}; //id=531 文件ID 正确测试 最终status=3 int id=531; //普通转形式审核 True String sql1 = "update information set status='" + status[1] + "' where id='" + id + "'"; //形式转部门 True String sql2 = "update information set status='" + status[2] + "' where id='" + id + "'"; if (MessageService.update(sql1)) { System.out.println("形式审核通过"); if (MessageService.update(sql2)) { System.out.println("部门审核通过"); } } } @Test //信息查询 void testSearchinfo() { System.out.println("DemandSearchInfo Test Case"); String[][] sql= {{"select * from information"},{"select * from information where id='"+1+"'"}, {"select * from information where id='"+99+"'"},{"select * from information where id='"+134+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchinfo(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchinfo(sql1)); } @Test //用户查询 void testSearchmess() { System.out.println("UserSearchInfo Test Case"); String[][] sql= {{"select * from user"},{"select * from user where id='"+1+"'"}, {"select * from user where id='"+99+"'"},{"select * from user where id='"+5+"'"} ,{"selec A from alldate" }}; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.searchmess(sql[i][0])); } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.searchmess(sql1)); } @Test //地域查询 void testGetarea() throws SQLException { System.out.println("Area Test Case"); int [] j= {1}; String[][] sql= {{"select * from area"},{"select areaname from area where code='"+130100+"'"}, {"select * from area where id='"+10+"'"},{"selec A from alldate" },{"select * from area where id='"+j[0]+"'"} }; for(int i=0;i<sql.length;i++) { System.out.println("测试语句"+sql[i][0]+" Return:"+MessageService.getarea(sql[i][0])); } for(int i=0;i<j.length;i++) { System.out.println("测试语句"+sql[4][0]+" Return:"+MessageService.getarea(sql[i][0])); j[0]++; } String sql1="xxx"; System.out.println("测试语句"+sql1+" Return:"+MessageService.getarea(sql1)); } }