Authored by zhaoyue

Mod some var names

... ... @@ -3,7 +3,7 @@ git add --all src/*
git add --all lib/*
git add push.sh
git add pom.xml
git commit -m "Add qrcode testcases"
git commit -m "Mod some var names"
git push origin master
git status
git pull
... ...
... ... @@ -17,6 +17,15 @@ public interface Constants {
String USR_PWD = "pass1";
String USR_OPENID = "abcdefghijklmnopqrstuvwxyz123456";
String USR_OPENID_TYPE = "0";
/**
*
*/
// admin account
public static final String ADMIN_ACCOUNT = "user1";
// admin password
public static final String ADMIN_PWD = "pass1";
/**
* 密钥
*/
... ...
... ... @@ -23,8 +23,8 @@ public class OpenIdTest {
public static String bindWithOpenIdAndUser(){
Map<String,String> params = new HashMap<String, String>();
params.put("username","user1");
params.put("password",EncodeTools.encode("MD5","pass1"));
params.put("username",Constants.USR_ACC);
params.put("password",EncodeTools.encode("MD5",Constants.USR_PWD));
params.put("openId",Constants.USR_OPENID);
params.put("openIdType",Constants.USR_OPENID_TYPE);
params.put("t",HttpTools.getNow());
... ... @@ -40,10 +40,10 @@ public class OpenIdTest {
@Test
public void testUnBind(){
Map<String,String> params = new HashMap<String, String>();
params.put("username","user1");
params.put("password",EncodeTools.encode("MD5","pass1"));
params.put("openId","abcdefghijklmnopqrstuvwxyz123456");
params.put("openIdType","0");
params.put("username",Constants.USR_ACC);
params.put("password",EncodeTools.encode("MD5",Constants.USR_PWD));
params.put("openId",Constants.USR_OPENID);
params.put("openIdType",Constants.USR_OPENID_TYPE);
params.put("t",HttpTools.getNow());
params.put("type",Constants.KEY_ID);
... ... @@ -59,7 +59,7 @@ public class OpenIdTest {
*/
@Test
public void testLogin(){
System.out.println(bindWithOpenIdAndLoginAndGetToken("abcdefghijklmnopqrstuvwxyz123456","0"));
System.out.println(bindWithOpenIdAndLoginAndGetToken(Constants.USR_OPENID,Constants.USR_OPENID_TYPE));
}
public static String bindWithOpenIdAndLoginAndGetToken(String openId, String openIdType){
... ...
... ... @@ -23,8 +23,8 @@ public class ReportTest {
@BeforeClass
public static void init(){
token = loginAndGetToken("user1","pass1");
// String token =OpenIdTest.bindWithOpenIdAndLoginAndGetToken("abcdefghijklmnopqrstuvwxyz123456","0");
token = loginAndGetToken(Constants.USR_ACC,Constants.USR_PWD);
String token =OpenIdTest.bindWithOpenIdAndLoginAndGetToken(Constants.USR_OPENID,Constants.USR_OPENID_TYPE);
}
/**
... ...
... ... @@ -33,7 +33,7 @@ public class TokenTest {
*/
@Test
public void testLogin(){
System.out.println(loginAndGetToken("user1","pass1"));
System.out.println(loginAndGetToken(Constants.USR_ACC,Constants.USR_PWD));
}
/**
... ... @@ -41,7 +41,7 @@ public class TokenTest {
*/
@Test
public void logout(){
String token = loginAndGetToken("user1","pass1");
String token = loginAndGetToken(Constants.USR_ACC,Constants.USR_PWD);
Map<String,String> params = new HashMap<String, String>();
params.put("t",HttpTools.getNow());
params.put("type",Constants.KEY_ID);
... ... @@ -69,7 +69,7 @@ public class TokenTest {
*/
@Test
public void adminTestLogin(){
System.out.println(adminLoginAndGetToken("user1","pass1"));
System.out.println(adminLoginAndGetToken( Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD));
}
/**
... ... @@ -77,7 +77,7 @@ public class TokenTest {
*/
@Test
public void adminLogout(){
String token = loginAndGetToken("user1","pass1");
String token = loginAndGetToken( Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String,String> params = new HashMap<String, String>();
params.put("t",HttpTools.getNow());
params.put("type",Constants.KEY_ID);
... ...
... ... @@ -17,66 +17,66 @@ public class UserInfoTest {
/**
* 用户注册:
* register(String adminUser,String adminPass,
String user,String pass,String name,String sex,String birthDate,String phone,String idcard)
* String user,String pass,String name,String sex,String birthDate,String phone,String idcard)
*/
@Test
public void testRegister(){
String adminUser = "user1";
String adminPass = "pass1";
public void testRegister() {
String adminUser = Constants.ADMIN_ACCOUNT;
String adminPass = Constants.ADMIN_PWD;
String user = "15211112222";
String pass = "pass152";
String name = "usernameTest";
String sex = Constants.MALE;
String birthDate= "1966-06-12";
String birthDate = "1966-06-12";
String phone = "13011112222";
String idcard = "130105196606125555";
register(adminUser,adminPass,user,pass,name,sex,birthDate,phone,idcard);
register(adminUser, adminPass, user, pass, name, sex, birthDate, phone, idcard);
}
@Test
public void testRegisterWithDiffId(){
String adminUser = "user1";
String adminPass = "pass1";
public void testRegisterWithDiffId() {
String adminUser = Constants.ADMIN_ACCOUNT;
String adminPass = Constants.ADMIN_PWD;
String user = "15233334444";
String pass = "pass152";
String name = "usernameTest1";
String sex = Constants.MALE;
String birthDate= "1966-06-12";
String birthDate = "1966-06-12";
String phone = "13011112222";
String idcard = "110000196606125555";
register(adminUser,adminPass,user,pass,name,sex,birthDate,phone,idcard);
register(adminUser, adminPass, user, pass, name, sex, birthDate, phone, idcard);
}
@Test
public void testRegisterWithOutIdCard(){
String adminUser = "user1";
String adminPass = "pass1";
public void testRegisterWithOutIdCard() {
String adminUser = Constants.ADMIN_ACCOUNT;
String adminPass = Constants.ADMIN_PWD;
String user = "15222223333";
String pass = "pass152";
String name = "usernameTest2";
String sex = Constants.FEMALE;
String birthDate= "1999-12-22";
String birthDate = "1999-12-22";
String phone = "13011112222";
String idcard = null;
register(adminUser,adminPass,user,pass,name,sex,birthDate,phone,idcard);
register(adminUser, adminPass, user, pass, name, sex, birthDate, phone, idcard);
}
/**
* 用户修改密码
*/
@Test
public void testModPass(){
register("user1","pass1","15211112222","pass152","usernameTest","1","1966-06-12","13011112222","130105196606125555");
public void testModPass() {
register(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD, "15211112222", "pass152", "usernameTest", "1", "1966-06-12", "13011112222", "130105196606125555");
Map<String,String> params = new HashMap<String, String>();
params.put("password",EncodeTools.encode("MD5","pass152_new"));
params.put("t",HttpTools.getNow());
params.put("type",Constants.KEY_ID);
params.put("sign",HttpTools.getSign(params));
Map<String, String> params = new HashMap<String, String>();
params.put("password", EncodeTools.encode("MD5", "pass152_new"));
params.put("t", HttpTools.getNow());
params.put("type", Constants.KEY_ID);
params.put("sign", HttpTools.getSign(params));
//获取token
String token = loginAndGetToken("15211112222","pass152");
String token = loginAndGetToken("15211112222", "pass152");
System.out.println(token);
String response = HttpTools.requestByMapWithToken(URL_USER,"PUT",params,token);
String response = HttpTools.requestByMapWithToken(URL_USER, "PUT", params, token);
System.out.println(response);
}
... ... @@ -84,34 +84,34 @@ public class UserInfoTest {
* 个人信息查询接口
*/
@Test
public void testGetUserInfo(){
Map<String,String> params = new HashMap<String, String>();
params.put("t",HttpTools.getNow());
params.put("type",Constants.KEY_ID);
params.put("sign",HttpTools.getSign(params));
public void testGetUserInfo() {
Map<String, String> params = new HashMap<String, String>();
params.put("t", HttpTools.getNow());
params.put("type", Constants.KEY_ID);
params.put("sign", HttpTools.getSign(params));
//获取token
String token = loginAndGetToken("user1","pass1");
String token = loginAndGetToken(Constants.USR_ACC, Constants.USR_PWD);
System.out.println(token);
String response = HttpTools.requestByMapWithToken(URL_USER,"GET",params,token);
String response = HttpTools.requestByMapWithToken(URL_USER, "GET", params, token);
System.out.println(response);
}
public void register(String adminUser,String adminPass,
String user,String pass,String name,String sex,String birthDate,String phone,String idcard){
Map<String,String> params = new HashMap<String, String>();
params.put("username",user);
params.put("password",EncodeTools.encode("MD5",pass));
params.put("name",name);
params.put("sex",sex);
params.put("birthDate",birthDate);
params.put("phone",phone);
if(idcard!=null&&idcard!="")
params.put("idcard",idcard);
params.put("t",HttpTools.getNow());
params.put("type",Constants.KEY_ID);
params.put("sign",HttpTools.getSign(params));
String token = TokenTest.adminLoginAndGetToken(adminUser,adminPass);
String response = HttpTools.requestByMapWithToken(URL_USER,"POST",params,token);
public void register(String adminUser, String adminPass,
String user, String pass, String name, String sex, String birthDate, String phone, String idcard) {
Map<String, String> params = new HashMap<String, String>();
params.put("username", user);
params.put("password", EncodeTools.encode("MD5", pass));
params.put("name", name);
params.put("sex", sex);
params.put("birthDate", birthDate);
params.put("phone", phone);
if (idcard != null && idcard != "")
params.put("idcard", idcard);
params.put("t", HttpTools.getNow());
params.put("type", Constants.KEY_ID);
params.put("sign", HttpTools.getSign(params));
String token = TokenTest.adminLoginAndGetToken(adminUser, adminPass);
String response = HttpTools.requestByMapWithToken(URL_USER, "POST", params, token);
System.out.println(response);
}
... ... @@ -119,30 +119,30 @@ public class UserInfoTest {
* 错误的注册:不带sign
*/
@Test
public void testRegisterNoSign(){
String adminUser = "user1";
String adminPass = "pass1";
public void testRegisterNoSign() {
String adminUser = Constants.ADMIN_ACCOUNT;
String adminPass = Constants.ADMIN_PWD;
String user = "15211112222";
String pass = "pass152";
String name = "usernameTest";
String sex = Constants.MALE;
String birthDate= "1966-06-12";
String birthDate = "1966-06-12";
String phone = "13011112222";
String idcard = "130105196606125555";
Map<String,String> params = new HashMap<String, String>();
params.put("username",user);
params.put("password",EncodeTools.encode("MD5",pass));
params.put("name",name);
params.put("sex",sex);
params.put("birthDate",birthDate);
params.put("phone",phone);
if(idcard!=null&&idcard!="")
params.put("idcard",idcard);
params.put("t",HttpTools.getNow());
params.put("type",Constants.KEY_ID);
params.put("sign","nosign");
String token = TokenTest.adminLoginAndGetToken(adminUser,adminPass);
String response = HttpTools.requestByMapWithToken(URL_USER,"POST",params,token);
Map<String, String> params = new HashMap<String, String>();
params.put("username", user);
params.put("password", EncodeTools.encode("MD5", pass));
params.put("name", name);
params.put("sex", sex);
params.put("birthDate", birthDate);
params.put("phone", phone);
if (idcard != null && idcard != "")
params.put("idcard", idcard);
params.put("t", HttpTools.getNow());
params.put("type", Constants.KEY_ID);
params.put("sign", "nosign");
String token = TokenTest.adminLoginAndGetToken(adminUser, adminPass);
String response = HttpTools.requestByMapWithToken(URL_USER, "POST", params, token);
System.out.println(response);
}
... ... @@ -150,30 +150,30 @@ public class UserInfoTest {
* 错误注册:客户端与服务端时间差距过大
*/
@Test
public void testRegisterWrongTime(){
String adminUser = "user1";
String adminPass = "pass1";
public void testRegisterWrongTime() {
String adminUser = Constants.ADMIN_ACCOUNT;
String adminPass = Constants.ADMIN_PWD;
String user = "15211112222";
String pass = "pass152";
String name = "usernameTest";
String sex = Constants.MALE;
String birthDate= "1966-06-12";
String birthDate = "1966-06-12";
String phone = "13011112222";
String idcard = "130105196606125555";
Map<String,String> params = new HashMap<String, String>();
params.put("username",user);
params.put("password",EncodeTools.encode("MD5",pass));
params.put("name",name);
params.put("sex",sex);
params.put("birthDate",birthDate);
params.put("phone",phone);
if(idcard!=null&&idcard!="")
params.put("idcard",idcard);
params.put("t",HttpTools.getNow()+60*60*26);
params.put("type",Constants.KEY_ID);
params.put("sign","nosign");
String token = TokenTest.adminLoginAndGetToken(adminUser,adminPass);
String response = HttpTools.requestByMapWithToken(URL_USER,"POST",params,token);
Map<String, String> params = new HashMap<String, String>();
params.put("username", user);
params.put("password", EncodeTools.encode("MD5", pass));
params.put("name", name);
params.put("sex", sex);
params.put("birthDate", birthDate);
params.put("phone", phone);
if (idcard != null && idcard != "")
params.put("idcard", idcard);
params.put("t", HttpTools.getNow() + 60 * 60 * 26);
params.put("type", Constants.KEY_ID);
params.put("sign", "nosign");
String token = TokenTest.adminLoginAndGetToken(adminUser, adminPass);
String response = HttpTools.requestByMapWithToken(URL_USER, "POST", params, token);
System.out.println(response);
}
... ...
... ... @@ -15,19 +15,7 @@ import static com.xkl.TokenTest.loginAndGetToken;
* 报告相关
*/
public class ReportTest {
private static final String URL_REPORT_LIST = Constants.URL_PREFIX + "/report/list";
private static final String URL_REPORT_DETAIL = Constants.URL_PREFIX + "/report/detail";
private static final String URL_REPORT_SCORE = Constants.URL_PREFIX + "/report/score";
private static final String URL_ITEM_INFO = Constants.URL_PREFIX + "/report/itemInfo";
private static final String URL_ITEM_GRAPH = Constants.URL_PREFIX + "/report/itemGraph";
private static final String URL_COMPARE = Constants.URL_PREFIX + "/report/compare";
private static String token;
@BeforeClass
public static void init(){
token = loginAndGetToken("user1","pass1");
// String token =OpenIdTest.bindWithOpenIdAndLoginAndGetToken("abcdefghijklmnopqrstuvwxyz123456","0");
}
/**
* 健康评分接口
... ...
... ... @@ -32,12 +32,12 @@ public class AccountTest {
@Test
public void testLogin() {
System.out.println(loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD));
System.out.println(loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD));
}
@Test
public void testLogout() {
String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD);
String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
params.put("t", HttpTools.getNow());
String response = HttpTools.requestByMapWithToken(URL_LOGIN, "DELETE", params, token);
... ... @@ -46,9 +46,9 @@ public class AccountTest {
@Test
public void testModPwd() {
String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD);
String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
String newPassWord = "pass1";
String newPassWord = Constants.ADMIN_PWD;
params.put("newpwd", EncodeTools.encode("MD5", newPassWord));
String response = HttpTools.requestByMapWithToken(URL_LOGIN, "PUT", params, token);
System.out.println("modify password success:" + response);
... ...
... ... @@ -30,7 +30,7 @@ public class AdminInfoTest {
}
@Test
public void testGetAdminInfo() {
String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD);
String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
params.put("t", HttpTools.getNow());
String response = HttpTools.requestByMapWithToken(URL_ADMININFO, "GET", params, token);
... ...
package com.xkl.upsoft;
import com.xkl.Constants;
import org.json.JSONObject;
import org.junit.Test;
... ... @@ -14,8 +15,6 @@ import java.text.DecimalFormat;
* Created by zhao yue on 2017/1/14.
*/
public class Data {
public static final String ADMIN_ACCOUNT = "user1";
public static final String ADMIN_PWD = "pass1";
public static final String USR_ACCOUNT = "15211112222";
public static String AMP_REPORT = "";
... ... @@ -81,7 +80,7 @@ public class Data {
report.put("stable", "99999");
report.put("weight", 45);
report.put("title", "AMP无创健康评估报告"); // report title
report.put("account", "15211112222");
report.put("account", Constants.USR_ACC); // user account
report.put("machine_num", "10311212");//machine serial
// /*
... ...
... ... @@ -34,7 +34,7 @@ public class ReportTest {
@Test
public void testAddReport() {
String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD);
String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
// 程序自动生成json报告。
String report = Data.AMP_REPORT;
... ... @@ -47,7 +47,7 @@ public class ReportTest {
@Test
public void testDelReport() {
String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD);
String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
params.put("report_id", "143");
String response = HttpTools.requestByMapWithToken(URL_REPORT, "DELETE", params, token);
... ...
... ... @@ -59,7 +59,7 @@ public class AccountTest {
*/
@Test
public void testLoginSuccess() {
System.out.println(loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD));
System.out.println(loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD));
}
/**
... ... @@ -67,7 +67,7 @@ public class AccountTest {
*/
@Test
public void testLoginFail() {
System.out.println(loginAndGetToken(Data.ADMIN_ACCOUNT + "ppppp", Data.ADMIN_PWD));
System.out.println(loginAndGetToken(Constants.ADMIN_ACCOUNT + "ppppp", Constants.ADMIN_PWD));
}
/**
... ... @@ -75,7 +75,7 @@ public class AccountTest {
*/
@Test
public void testLoginModPwdSuccess() {
System.out.println(loginModPwdAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD, Data.ADMIN_PWD));
System.out.println(loginModPwdAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD, Constants.ADMIN_PWD));
}
/**
... ... @@ -83,13 +83,13 @@ public class AccountTest {
*/
@Test
public void testLoginModPwdFail() {
System.out.println(loginModPwdAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD + "pppppp", Data.ADMIN_PWD));
System.out.println(loginModPwdAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD + "pppppp", Constants.ADMIN_PWD));
}
@Test
public void testLogout() {
String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD);
String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
params.put("t", HttpTools.getNow());
String response = HttpTools.requestByMapWithToken(URL_LOGIN, "DELETE", params, token);
... ... @@ -98,7 +98,7 @@ public class AccountTest {
@Test
public void testLogoutFail() {
String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD);
String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
params.put("t", HttpTools.getNow());
String response = HttpTools.requestByMapWithToken(URL_LOGIN, "DELETE", params, token + "PPPPPP");
... ...
package com.xkl.uspih;
import com.xkl.Constants;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Test;
... ... @@ -56,7 +57,7 @@ public class Data {
report.put("stable", "99999");
report.put("weight", 45);
report.put("title", "AMP无创健康评估报告"); // report title
report.put("account", "15211112222");//user account
report.put("account", Constants.USR_ACC);//user account
report.put("machine_num", "10311212");//machine serial
/*
... ...
... ... @@ -35,7 +35,7 @@ public class ReportTest {
@Test
public void testAddReport() {
//
String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD);
String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
params.put("json_report", Data.AMP_REPORT);
String response = HttpTools.requestByMapWithToken(URL_REPORT, "POST", params, token);
... ... @@ -44,7 +44,7 @@ public class ReportTest {
@Test
public void testDelReport() {
String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD);
String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
params.put("report_id", "133");
String response = HttpTools.requestByMapWithToken(URL_REPORT, "DELETE", params, token);
... ...
... ... @@ -17,7 +17,7 @@ import java.util.Map;
public class UsrAccountTest {
private static final String URL_LOGIN = Constants.URL_PREFIX + "/uspih/account";
private static final String URL_USER= Constants.URL_PREFIX + "/uspihusr";
private static final String URL_USER = Constants.URL_PREFIX + "/uspihusr";
public static String loginAndGetToken(String user, String pass) {
... ... @@ -35,7 +35,7 @@ public class UsrAccountTest {
@Test
public void testAccountExistVerify() {
String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD);
String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
params.put("usraccount", Data.USR_ACCOUNT);
String response = HttpTools.requestByMapWithToken(URL_USER, "GET", params, token);
... ... @@ -45,9 +45,9 @@ public class UsrAccountTest {
@Test
public void testAccountNotExist() {
String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD);
String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
params.put("usraccount", Data.USR_ACCOUNT+"not exist account");
params.put("usraccount", Data.USR_ACCOUNT + "not exist account");
String response = HttpTools.requestByMapWithToken(URL_USER, "GET", params, token);
System.out.println("verify status:" + response);
}
... ...