package test;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import dbm.Register;
import jdbc.BaseUnit;
public class RegisterTest {
//密码判断测试
/*public static void isConsistentTest() {
Register register=new Register("djz", "123456","123456");
System.out.println(register.isConsistent());
Register register2=new Register("djz", "12345","12456");
System.out.println(register2.isConsistent());
}
*/
//用户存在判断测试
public static void isExistTest() {
Register register=new Register("djz", "123456","123456");
System.out.println(register.isExist());
//插入数据后再判断
String sql="insert into Users values('djz', '123456')";
Connection conn;
Statement stmt;
try {
conn=BaseUnit.getConnection();
stmt=conn.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Register register2=new Register("djz", "123456","123456");
System.out.println(register2.isExist());
}
//删除用户存在判断测试所插入的数据
public static void deleteUsersData() {
String sql="delete from Users where userName='djz';";
Connection conn;
Statement stmt;
try {
conn=BaseUnit.getConnection();
stmt=conn.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//创建个人记录表测试
public static void createPersonalHistoryTbTest() {
Register register=new Register("djz", "123456","123456");
register.getCreatePersonalHistoryTb();
}
//删除测试创建的个人记录表
public static void deletePersonalHistoryTb() {
String sql="drop table _djzHistory;";
Connection conn;
Statement stmt;
try {
conn=BaseUnit.getConnection();
stmt=conn.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//创建错题集记录表测试
public static void createPersonalErrorSetTest() {
Register register=new Register("djz", "123456","123456");
register.getCreatePersonalErrorSet();
}
//删除测试创建的错题集记录表
public static void deletePersonalErrorSet() {
String sql="drop table _djzErrorSet;";
Connection conn;
Statement stmt;
try {
conn=BaseUnit.getConnection();
stmt=conn.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//上传用户信息测试
public static void infoUploadTest() {
Register register=new Register("djz", "123456","123456");
register.getInfoUpload();
}
//删除测试上传的用户信息
public static void deleteInfoUpload() {
String sql="delete from UsersRecord where userName='djz';";
Connection conn;
Statement stmt;
try {
conn=BaseUnit.getConnection();
stmt=conn.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//上传用户数据完成注册测试
public static void registerTest() {
Register register=new Register("djz", "123456","123456");
register.register();
}
//删除注册数据
public static void deleteRegisterData() {
String sql="delete from Users;"
+ "drop table _djzHistory;"
+ "drop table _djzErrorSet;"
+ "delete from UsersRecord;";
Connection conn;
Statement stmt;
try {
conn=BaseUnit.getConnection();
stmt=conn.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
package test;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import dbm.Login;
import jdbc.BaseUnit;
public class LoginTest {
//用户存在判断测试
public static void isExistTest() {
Login login=new Login("djz", "123456");
System.out.println(login.isExist());
//插入数据后再判断
String sql="insert into Users values('djz', '123456')";
Connection conn;
Statement stmt;
try {
conn=BaseUnit.getConnection();
stmt=conn.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Login login1=new Login("djz", "123456");
System.out.println(login1.isExist());
}
//密码正确判断测试
public static void isMatchedTest() {
// String str="123456".hashCode()+"";
Login login=new Login("djz","123456" );
System.out.println(login.isMatched());
String sql="insert into Users values('djz', '"+"123456".hashCode()+"')";
Connection conn;
Statement stmt;
try {
conn=BaseUnit.getConnection();
stmt=conn.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Login login2=new Login("djz","123456" );
System.out.println(login2.isMatched());
}
//删除用户存在判断测试所插入的数据(适用前两者)
public static void deleteUsersData() {
String sql="delete from Users where userName='djz';";
Connection conn;
Statement stmt;
try {
conn=BaseUnit.getConnection();
stmt=conn.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}