Showing
15 changed files
with
130 additions
and
133 deletions
@@ -3,7 +3,7 @@ git add --all src/* | @@ -3,7 +3,7 @@ git add --all src/* | ||
3 | git add --all lib/* | 3 | git add --all lib/* |
4 | git add push.sh | 4 | git add push.sh |
5 | git add pom.xml | 5 | git add pom.xml |
6 | -git commit -m "Add qrcode testcases" | 6 | +git commit -m "Mod some var names" |
7 | git push origin master | 7 | git push origin master |
8 | git status | 8 | git status |
9 | git pull | 9 | git pull |
@@ -17,6 +17,15 @@ public interface Constants { | @@ -17,6 +17,15 @@ public interface Constants { | ||
17 | String USR_PWD = "pass1"; | 17 | String USR_PWD = "pass1"; |
18 | String USR_OPENID = "abcdefghijklmnopqrstuvwxyz123456"; | 18 | String USR_OPENID = "abcdefghijklmnopqrstuvwxyz123456"; |
19 | String USR_OPENID_TYPE = "0"; | 19 | String USR_OPENID_TYPE = "0"; |
20 | + | ||
21 | + | ||
22 | + /** | ||
23 | + * | ||
24 | + */ | ||
25 | + // admin account | ||
26 | + public static final String ADMIN_ACCOUNT = "user1"; | ||
27 | + // admin password | ||
28 | + public static final String ADMIN_PWD = "pass1"; | ||
20 | /** | 29 | /** |
21 | * 密钥 | 30 | * 密钥 |
22 | */ | 31 | */ |
@@ -23,8 +23,8 @@ public class OpenIdTest { | @@ -23,8 +23,8 @@ public class OpenIdTest { | ||
23 | 23 | ||
24 | public static String bindWithOpenIdAndUser(){ | 24 | public static String bindWithOpenIdAndUser(){ |
25 | Map<String,String> params = new HashMap<String, String>(); | 25 | Map<String,String> params = new HashMap<String, String>(); |
26 | - params.put("username","user1"); | ||
27 | - params.put("password",EncodeTools.encode("MD5","pass1")); | 26 | + params.put("username",Constants.USR_ACC); |
27 | + params.put("password",EncodeTools.encode("MD5",Constants.USR_PWD)); | ||
28 | params.put("openId",Constants.USR_OPENID); | 28 | params.put("openId",Constants.USR_OPENID); |
29 | params.put("openIdType",Constants.USR_OPENID_TYPE); | 29 | params.put("openIdType",Constants.USR_OPENID_TYPE); |
30 | params.put("t",HttpTools.getNow()); | 30 | params.put("t",HttpTools.getNow()); |
@@ -40,10 +40,10 @@ public class OpenIdTest { | @@ -40,10 +40,10 @@ public class OpenIdTest { | ||
40 | @Test | 40 | @Test |
41 | public void testUnBind(){ | 41 | public void testUnBind(){ |
42 | Map<String,String> params = new HashMap<String, String>(); | 42 | Map<String,String> params = new HashMap<String, String>(); |
43 | - params.put("username","user1"); | ||
44 | - params.put("password",EncodeTools.encode("MD5","pass1")); | ||
45 | - params.put("openId","abcdefghijklmnopqrstuvwxyz123456"); | ||
46 | - params.put("openIdType","0"); | 43 | + params.put("username",Constants.USR_ACC); |
44 | + params.put("password",EncodeTools.encode("MD5",Constants.USR_PWD)); | ||
45 | + params.put("openId",Constants.USR_OPENID); | ||
46 | + params.put("openIdType",Constants.USR_OPENID_TYPE); | ||
47 | 47 | ||
48 | params.put("t",HttpTools.getNow()); | 48 | params.put("t",HttpTools.getNow()); |
49 | params.put("type",Constants.KEY_ID); | 49 | params.put("type",Constants.KEY_ID); |
@@ -59,7 +59,7 @@ public class OpenIdTest { | @@ -59,7 +59,7 @@ public class OpenIdTest { | ||
59 | */ | 59 | */ |
60 | @Test | 60 | @Test |
61 | public void testLogin(){ | 61 | public void testLogin(){ |
62 | - System.out.println(bindWithOpenIdAndLoginAndGetToken("abcdefghijklmnopqrstuvwxyz123456","0")); | 62 | + System.out.println(bindWithOpenIdAndLoginAndGetToken(Constants.USR_OPENID,Constants.USR_OPENID_TYPE)); |
63 | } | 63 | } |
64 | 64 | ||
65 | public static String bindWithOpenIdAndLoginAndGetToken(String openId, String openIdType){ | 65 | public static String bindWithOpenIdAndLoginAndGetToken(String openId, String openIdType){ |
@@ -23,8 +23,8 @@ public class ReportTest { | @@ -23,8 +23,8 @@ public class ReportTest { | ||
23 | 23 | ||
24 | @BeforeClass | 24 | @BeforeClass |
25 | public static void init(){ | 25 | public static void init(){ |
26 | - token = loginAndGetToken("user1","pass1"); | ||
27 | -// String token =OpenIdTest.bindWithOpenIdAndLoginAndGetToken("abcdefghijklmnopqrstuvwxyz123456","0"); | 26 | + token = loginAndGetToken(Constants.USR_ACC,Constants.USR_PWD); |
27 | + String token =OpenIdTest.bindWithOpenIdAndLoginAndGetToken(Constants.USR_OPENID,Constants.USR_OPENID_TYPE); | ||
28 | } | 28 | } |
29 | 29 | ||
30 | /** | 30 | /** |
@@ -33,7 +33,7 @@ public class TokenTest { | @@ -33,7 +33,7 @@ public class TokenTest { | ||
33 | */ | 33 | */ |
34 | @Test | 34 | @Test |
35 | public void testLogin(){ | 35 | public void testLogin(){ |
36 | - System.out.println(loginAndGetToken("user1","pass1")); | 36 | + System.out.println(loginAndGetToken(Constants.USR_ACC,Constants.USR_PWD)); |
37 | } | 37 | } |
38 | 38 | ||
39 | /** | 39 | /** |
@@ -41,7 +41,7 @@ public class TokenTest { | @@ -41,7 +41,7 @@ public class TokenTest { | ||
41 | */ | 41 | */ |
42 | @Test | 42 | @Test |
43 | public void logout(){ | 43 | public void logout(){ |
44 | - String token = loginAndGetToken("user1","pass1"); | 44 | + String token = loginAndGetToken(Constants.USR_ACC,Constants.USR_PWD); |
45 | Map<String,String> params = new HashMap<String, String>(); | 45 | Map<String,String> params = new HashMap<String, String>(); |
46 | params.put("t",HttpTools.getNow()); | 46 | params.put("t",HttpTools.getNow()); |
47 | params.put("type",Constants.KEY_ID); | 47 | params.put("type",Constants.KEY_ID); |
@@ -69,7 +69,7 @@ public class TokenTest { | @@ -69,7 +69,7 @@ public class TokenTest { | ||
69 | */ | 69 | */ |
70 | @Test | 70 | @Test |
71 | public void adminTestLogin(){ | 71 | public void adminTestLogin(){ |
72 | - System.out.println(adminLoginAndGetToken("user1","pass1")); | 72 | + System.out.println(adminLoginAndGetToken( Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD)); |
73 | } | 73 | } |
74 | 74 | ||
75 | /** | 75 | /** |
@@ -77,7 +77,7 @@ public class TokenTest { | @@ -77,7 +77,7 @@ public class TokenTest { | ||
77 | */ | 77 | */ |
78 | @Test | 78 | @Test |
79 | public void adminLogout(){ | 79 | public void adminLogout(){ |
80 | - String token = loginAndGetToken("user1","pass1"); | 80 | + String token = loginAndGetToken( Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD); |
81 | Map<String,String> params = new HashMap<String, String>(); | 81 | Map<String,String> params = new HashMap<String, String>(); |
82 | params.put("t",HttpTools.getNow()); | 82 | params.put("t",HttpTools.getNow()); |
83 | params.put("type",Constants.KEY_ID); | 83 | params.put("type",Constants.KEY_ID); |
@@ -17,66 +17,66 @@ public class UserInfoTest { | @@ -17,66 +17,66 @@ public class UserInfoTest { | ||
17 | /** | 17 | /** |
18 | * 用户注册: | 18 | * 用户注册: |
19 | * register(String adminUser,String adminPass, | 19 | * register(String adminUser,String adminPass, |
20 | - String user,String pass,String name,String sex,String birthDate,String phone,String idcard) | 20 | + * String user,String pass,String name,String sex,String birthDate,String phone,String idcard) |
21 | */ | 21 | */ |
22 | @Test | 22 | @Test |
23 | - public void testRegister(){ | ||
24 | - String adminUser = "user1"; | ||
25 | - String adminPass = "pass1"; | 23 | + public void testRegister() { |
24 | + String adminUser = Constants.ADMIN_ACCOUNT; | ||
25 | + String adminPass = Constants.ADMIN_PWD; | ||
26 | String user = "15211112222"; | 26 | String user = "15211112222"; |
27 | String pass = "pass152"; | 27 | String pass = "pass152"; |
28 | String name = "usernameTest"; | 28 | String name = "usernameTest"; |
29 | String sex = Constants.MALE; | 29 | String sex = Constants.MALE; |
30 | - String birthDate= "1966-06-12"; | 30 | + String birthDate = "1966-06-12"; |
31 | String phone = "13011112222"; | 31 | String phone = "13011112222"; |
32 | String idcard = "130105196606125555"; | 32 | String idcard = "130105196606125555"; |
33 | - register(adminUser,adminPass,user,pass,name,sex,birthDate,phone,idcard); | 33 | + register(adminUser, adminPass, user, pass, name, sex, birthDate, phone, idcard); |
34 | } | 34 | } |
35 | 35 | ||
36 | @Test | 36 | @Test |
37 | - public void testRegisterWithDiffId(){ | ||
38 | - String adminUser = "user1"; | ||
39 | - String adminPass = "pass1"; | 37 | + public void testRegisterWithDiffId() { |
38 | + String adminUser = Constants.ADMIN_ACCOUNT; | ||
39 | + String adminPass = Constants.ADMIN_PWD; | ||
40 | String user = "15233334444"; | 40 | String user = "15233334444"; |
41 | String pass = "pass152"; | 41 | String pass = "pass152"; |
42 | String name = "usernameTest1"; | 42 | String name = "usernameTest1"; |
43 | String sex = Constants.MALE; | 43 | String sex = Constants.MALE; |
44 | - String birthDate= "1966-06-12"; | 44 | + String birthDate = "1966-06-12"; |
45 | String phone = "13011112222"; | 45 | String phone = "13011112222"; |
46 | String idcard = "110000196606125555"; | 46 | String idcard = "110000196606125555"; |
47 | - register(adminUser,adminPass,user,pass,name,sex,birthDate,phone,idcard); | 47 | + register(adminUser, adminPass, user, pass, name, sex, birthDate, phone, idcard); |
48 | } | 48 | } |
49 | 49 | ||
50 | @Test | 50 | @Test |
51 | - public void testRegisterWithOutIdCard(){ | ||
52 | - String adminUser = "user1"; | ||
53 | - String adminPass = "pass1"; | 51 | + public void testRegisterWithOutIdCard() { |
52 | + String adminUser = Constants.ADMIN_ACCOUNT; | ||
53 | + String adminPass = Constants.ADMIN_PWD; | ||
54 | String user = "15222223333"; | 54 | String user = "15222223333"; |
55 | String pass = "pass152"; | 55 | String pass = "pass152"; |
56 | String name = "usernameTest2"; | 56 | String name = "usernameTest2"; |
57 | String sex = Constants.FEMALE; | 57 | String sex = Constants.FEMALE; |
58 | - String birthDate= "1999-12-22"; | 58 | + String birthDate = "1999-12-22"; |
59 | String phone = "13011112222"; | 59 | String phone = "13011112222"; |
60 | String idcard = null; | 60 | String idcard = null; |
61 | - register(adminUser,adminPass,user,pass,name,sex,birthDate,phone,idcard); | 61 | + register(adminUser, adminPass, user, pass, name, sex, birthDate, phone, idcard); |
62 | } | 62 | } |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * 用户修改密码 | 65 | * 用户修改密码 |
66 | */ | 66 | */ |
67 | @Test | 67 | @Test |
68 | - public void testModPass(){ | ||
69 | - register("user1","pass1","15211112222","pass152","usernameTest","1","1966-06-12","13011112222","130105196606125555"); | 68 | + public void testModPass() { |
69 | + register(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD, "15211112222", "pass152", "usernameTest", "1", "1966-06-12", "13011112222", "130105196606125555"); | ||
70 | 70 | ||
71 | - Map<String,String> params = new HashMap<String, String>(); | ||
72 | - params.put("password",EncodeTools.encode("MD5","pass152_new")); | ||
73 | - params.put("t",HttpTools.getNow()); | ||
74 | - params.put("type",Constants.KEY_ID); | ||
75 | - params.put("sign",HttpTools.getSign(params)); | 71 | + Map<String, String> params = new HashMap<String, String>(); |
72 | + params.put("password", EncodeTools.encode("MD5", "pass152_new")); | ||
73 | + params.put("t", HttpTools.getNow()); | ||
74 | + params.put("type", Constants.KEY_ID); | ||
75 | + params.put("sign", HttpTools.getSign(params)); | ||
76 | //获取token | 76 | //获取token |
77 | - String token = loginAndGetToken("15211112222","pass152"); | 77 | + String token = loginAndGetToken("15211112222", "pass152"); |
78 | System.out.println(token); | 78 | System.out.println(token); |
79 | - String response = HttpTools.requestByMapWithToken(URL_USER,"PUT",params,token); | 79 | + String response = HttpTools.requestByMapWithToken(URL_USER, "PUT", params, token); |
80 | System.out.println(response); | 80 | System.out.println(response); |
81 | } | 81 | } |
82 | 82 | ||
@@ -84,34 +84,34 @@ public class UserInfoTest { | @@ -84,34 +84,34 @@ public class UserInfoTest { | ||
84 | * 个人信息查询接口 | 84 | * 个人信息查询接口 |
85 | */ | 85 | */ |
86 | @Test | 86 | @Test |
87 | - public void testGetUserInfo(){ | ||
88 | - Map<String,String> params = new HashMap<String, String>(); | ||
89 | - params.put("t",HttpTools.getNow()); | ||
90 | - params.put("type",Constants.KEY_ID); | ||
91 | - params.put("sign",HttpTools.getSign(params)); | 87 | + public void testGetUserInfo() { |
88 | + Map<String, String> params = new HashMap<String, String>(); | ||
89 | + params.put("t", HttpTools.getNow()); | ||
90 | + params.put("type", Constants.KEY_ID); | ||
91 | + params.put("sign", HttpTools.getSign(params)); | ||
92 | //获取token | 92 | //获取token |
93 | - String token = loginAndGetToken("user1","pass1"); | 93 | + String token = loginAndGetToken(Constants.USR_ACC, Constants.USR_PWD); |
94 | System.out.println(token); | 94 | System.out.println(token); |
95 | - String response = HttpTools.requestByMapWithToken(URL_USER,"GET",params,token); | 95 | + String response = HttpTools.requestByMapWithToken(URL_USER, "GET", params, token); |
96 | System.out.println(response); | 96 | System.out.println(response); |
97 | } | 97 | } |
98 | 98 | ||
99 | - public void register(String adminUser,String adminPass, | ||
100 | - String user,String pass,String name,String sex,String birthDate,String phone,String idcard){ | ||
101 | - Map<String,String> params = new HashMap<String, String>(); | ||
102 | - params.put("username",user); | ||
103 | - params.put("password",EncodeTools.encode("MD5",pass)); | ||
104 | - params.put("name",name); | ||
105 | - params.put("sex",sex); | ||
106 | - params.put("birthDate",birthDate); | ||
107 | - params.put("phone",phone); | ||
108 | - if(idcard!=null&&idcard!="") | ||
109 | - params.put("idcard",idcard); | ||
110 | - params.put("t",HttpTools.getNow()); | ||
111 | - params.put("type",Constants.KEY_ID); | ||
112 | - params.put("sign",HttpTools.getSign(params)); | ||
113 | - String token = TokenTest.adminLoginAndGetToken(adminUser,adminPass); | ||
114 | - String response = HttpTools.requestByMapWithToken(URL_USER,"POST",params,token); | 99 | + public void register(String adminUser, String adminPass, |
100 | + String user, String pass, String name, String sex, String birthDate, String phone, String idcard) { | ||
101 | + Map<String, String> params = new HashMap<String, String>(); | ||
102 | + params.put("username", user); | ||
103 | + params.put("password", EncodeTools.encode("MD5", pass)); | ||
104 | + params.put("name", name); | ||
105 | + params.put("sex", sex); | ||
106 | + params.put("birthDate", birthDate); | ||
107 | + params.put("phone", phone); | ||
108 | + if (idcard != null && idcard != "") | ||
109 | + params.put("idcard", idcard); | ||
110 | + params.put("t", HttpTools.getNow()); | ||
111 | + params.put("type", Constants.KEY_ID); | ||
112 | + params.put("sign", HttpTools.getSign(params)); | ||
113 | + String token = TokenTest.adminLoginAndGetToken(adminUser, adminPass); | ||
114 | + String response = HttpTools.requestByMapWithToken(URL_USER, "POST", params, token); | ||
115 | System.out.println(response); | 115 | System.out.println(response); |
116 | } | 116 | } |
117 | 117 | ||
@@ -119,30 +119,30 @@ public class UserInfoTest { | @@ -119,30 +119,30 @@ public class UserInfoTest { | ||
119 | * 错误的注册:不带sign | 119 | * 错误的注册:不带sign |
120 | */ | 120 | */ |
121 | @Test | 121 | @Test |
122 | - public void testRegisterNoSign(){ | ||
123 | - String adminUser = "user1"; | ||
124 | - String adminPass = "pass1"; | 122 | + public void testRegisterNoSign() { |
123 | + String adminUser = Constants.ADMIN_ACCOUNT; | ||
124 | + String adminPass = Constants.ADMIN_PWD; | ||
125 | String user = "15211112222"; | 125 | String user = "15211112222"; |
126 | String pass = "pass152"; | 126 | String pass = "pass152"; |
127 | String name = "usernameTest"; | 127 | String name = "usernameTest"; |
128 | String sex = Constants.MALE; | 128 | String sex = Constants.MALE; |
129 | - String birthDate= "1966-06-12"; | 129 | + String birthDate = "1966-06-12"; |
130 | String phone = "13011112222"; | 130 | String phone = "13011112222"; |
131 | String idcard = "130105196606125555"; | 131 | String idcard = "130105196606125555"; |
132 | - Map<String,String> params = new HashMap<String, String>(); | ||
133 | - params.put("username",user); | ||
134 | - params.put("password",EncodeTools.encode("MD5",pass)); | ||
135 | - params.put("name",name); | ||
136 | - params.put("sex",sex); | ||
137 | - params.put("birthDate",birthDate); | ||
138 | - params.put("phone",phone); | ||
139 | - if(idcard!=null&&idcard!="") | ||
140 | - params.put("idcard",idcard); | ||
141 | - params.put("t",HttpTools.getNow()); | ||
142 | - params.put("type",Constants.KEY_ID); | ||
143 | - params.put("sign","nosign"); | ||
144 | - String token = TokenTest.adminLoginAndGetToken(adminUser,adminPass); | ||
145 | - String response = HttpTools.requestByMapWithToken(URL_USER,"POST",params,token); | 132 | + Map<String, String> params = new HashMap<String, String>(); |
133 | + params.put("username", user); | ||
134 | + params.put("password", EncodeTools.encode("MD5", pass)); | ||
135 | + params.put("name", name); | ||
136 | + params.put("sex", sex); | ||
137 | + params.put("birthDate", birthDate); | ||
138 | + params.put("phone", phone); | ||
139 | + if (idcard != null && idcard != "") | ||
140 | + params.put("idcard", idcard); | ||
141 | + params.put("t", HttpTools.getNow()); | ||
142 | + params.put("type", Constants.KEY_ID); | ||
143 | + params.put("sign", "nosign"); | ||
144 | + String token = TokenTest.adminLoginAndGetToken(adminUser, adminPass); | ||
145 | + String response = HttpTools.requestByMapWithToken(URL_USER, "POST", params, token); | ||
146 | System.out.println(response); | 146 | System.out.println(response); |
147 | } | 147 | } |
148 | 148 | ||
@@ -150,30 +150,30 @@ public class UserInfoTest { | @@ -150,30 +150,30 @@ public class UserInfoTest { | ||
150 | * 错误注册:客户端与服务端时间差距过大 | 150 | * 错误注册:客户端与服务端时间差距过大 |
151 | */ | 151 | */ |
152 | @Test | 152 | @Test |
153 | - public void testRegisterWrongTime(){ | ||
154 | - String adminUser = "user1"; | ||
155 | - String adminPass = "pass1"; | 153 | + public void testRegisterWrongTime() { |
154 | + String adminUser = Constants.ADMIN_ACCOUNT; | ||
155 | + String adminPass = Constants.ADMIN_PWD; | ||
156 | String user = "15211112222"; | 156 | String user = "15211112222"; |
157 | String pass = "pass152"; | 157 | String pass = "pass152"; |
158 | String name = "usernameTest"; | 158 | String name = "usernameTest"; |
159 | String sex = Constants.MALE; | 159 | String sex = Constants.MALE; |
160 | - String birthDate= "1966-06-12"; | 160 | + String birthDate = "1966-06-12"; |
161 | String phone = "13011112222"; | 161 | String phone = "13011112222"; |
162 | String idcard = "130105196606125555"; | 162 | String idcard = "130105196606125555"; |
163 | - Map<String,String> params = new HashMap<String, String>(); | ||
164 | - params.put("username",user); | ||
165 | - params.put("password",EncodeTools.encode("MD5",pass)); | ||
166 | - params.put("name",name); | ||
167 | - params.put("sex",sex); | ||
168 | - params.put("birthDate",birthDate); | ||
169 | - params.put("phone",phone); | ||
170 | - if(idcard!=null&&idcard!="") | ||
171 | - params.put("idcard",idcard); | ||
172 | - params.put("t",HttpTools.getNow()+60*60*26); | ||
173 | - params.put("type",Constants.KEY_ID); | ||
174 | - params.put("sign","nosign"); | ||
175 | - String token = TokenTest.adminLoginAndGetToken(adminUser,adminPass); | ||
176 | - String response = HttpTools.requestByMapWithToken(URL_USER,"POST",params,token); | 163 | + Map<String, String> params = new HashMap<String, String>(); |
164 | + params.put("username", user); | ||
165 | + params.put("password", EncodeTools.encode("MD5", pass)); | ||
166 | + params.put("name", name); | ||
167 | + params.put("sex", sex); | ||
168 | + params.put("birthDate", birthDate); | ||
169 | + params.put("phone", phone); | ||
170 | + if (idcard != null && idcard != "") | ||
171 | + params.put("idcard", idcard); | ||
172 | + params.put("t", HttpTools.getNow() + 60 * 60 * 26); | ||
173 | + params.put("type", Constants.KEY_ID); | ||
174 | + params.put("sign", "nosign"); | ||
175 | + String token = TokenTest.adminLoginAndGetToken(adminUser, adminPass); | ||
176 | + String response = HttpTools.requestByMapWithToken(URL_USER, "POST", params, token); | ||
177 | 177 | ||
178 | System.out.println(response); | 178 | System.out.println(response); |
179 | } | 179 | } |
@@ -15,19 +15,7 @@ import static com.xkl.TokenTest.loginAndGetToken; | @@ -15,19 +15,7 @@ import static com.xkl.TokenTest.loginAndGetToken; | ||
15 | * 报告相关 | 15 | * 报告相关 |
16 | */ | 16 | */ |
17 | public class ReportTest { | 17 | public class ReportTest { |
18 | - private static final String URL_REPORT_LIST = Constants.URL_PREFIX + "/report/list"; | ||
19 | - private static final String URL_REPORT_DETAIL = Constants.URL_PREFIX + "/report/detail"; | ||
20 | private static final String URL_REPORT_SCORE = Constants.URL_PREFIX + "/report/score"; | 18 | private static final String URL_REPORT_SCORE = Constants.URL_PREFIX + "/report/score"; |
21 | - private static final String URL_ITEM_INFO = Constants.URL_PREFIX + "/report/itemInfo"; | ||
22 | - private static final String URL_ITEM_GRAPH = Constants.URL_PREFIX + "/report/itemGraph"; | ||
23 | - private static final String URL_COMPARE = Constants.URL_PREFIX + "/report/compare"; | ||
24 | - private static String token; | ||
25 | - | ||
26 | - @BeforeClass | ||
27 | - public static void init(){ | ||
28 | - token = loginAndGetToken("user1","pass1"); | ||
29 | -// String token =OpenIdTest.bindWithOpenIdAndLoginAndGetToken("abcdefghijklmnopqrstuvwxyz123456","0"); | ||
30 | - } | ||
31 | 19 | ||
32 | /** | 20 | /** |
33 | * 健康评分接口 | 21 | * 健康评分接口 |
@@ -32,12 +32,12 @@ public class AccountTest { | @@ -32,12 +32,12 @@ public class AccountTest { | ||
32 | 32 | ||
33 | @Test | 33 | @Test |
34 | public void testLogin() { | 34 | public void testLogin() { |
35 | - System.out.println(loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD)); | 35 | + System.out.println(loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD)); |
36 | } | 36 | } |
37 | 37 | ||
38 | @Test | 38 | @Test |
39 | public void testLogout() { | 39 | public void testLogout() { |
40 | - String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD); | 40 | + String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD); |
41 | Map<String, String> params = new HashMap<String, String>(); | 41 | Map<String, String> params = new HashMap<String, String>(); |
42 | params.put("t", HttpTools.getNow()); | 42 | params.put("t", HttpTools.getNow()); |
43 | String response = HttpTools.requestByMapWithToken(URL_LOGIN, "DELETE", params, token); | 43 | String response = HttpTools.requestByMapWithToken(URL_LOGIN, "DELETE", params, token); |
@@ -46,9 +46,9 @@ public class AccountTest { | @@ -46,9 +46,9 @@ public class AccountTest { | ||
46 | 46 | ||
47 | @Test | 47 | @Test |
48 | public void testModPwd() { | 48 | public void testModPwd() { |
49 | - String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD); | 49 | + String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD); |
50 | Map<String, String> params = new HashMap<String, String>(); | 50 | Map<String, String> params = new HashMap<String, String>(); |
51 | - String newPassWord = "pass1"; | 51 | + String newPassWord = Constants.ADMIN_PWD; |
52 | params.put("newpwd", EncodeTools.encode("MD5", newPassWord)); | 52 | params.put("newpwd", EncodeTools.encode("MD5", newPassWord)); |
53 | String response = HttpTools.requestByMapWithToken(URL_LOGIN, "PUT", params, token); | 53 | String response = HttpTools.requestByMapWithToken(URL_LOGIN, "PUT", params, token); |
54 | System.out.println("modify password success:" + response); | 54 | System.out.println("modify password success:" + response); |
@@ -30,7 +30,7 @@ public class AdminInfoTest { | @@ -30,7 +30,7 @@ public class AdminInfoTest { | ||
30 | } | 30 | } |
31 | @Test | 31 | @Test |
32 | public void testGetAdminInfo() { | 32 | public void testGetAdminInfo() { |
33 | - String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD); | 33 | + String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD); |
34 | Map<String, String> params = new HashMap<String, String>(); | 34 | Map<String, String> params = new HashMap<String, String>(); |
35 | params.put("t", HttpTools.getNow()); | 35 | params.put("t", HttpTools.getNow()); |
36 | String response = HttpTools.requestByMapWithToken(URL_ADMININFO, "GET", params, token); | 36 | String response = HttpTools.requestByMapWithToken(URL_ADMININFO, "GET", params, token); |
1 | package com.xkl.upsoft; | 1 | package com.xkl.upsoft; |
2 | 2 | ||
3 | 3 | ||
4 | +import com.xkl.Constants; | ||
4 | import org.json.JSONObject; | 5 | import org.json.JSONObject; |
5 | import org.junit.Test; | 6 | import org.junit.Test; |
6 | 7 | ||
@@ -14,8 +15,6 @@ import java.text.DecimalFormat; | @@ -14,8 +15,6 @@ import java.text.DecimalFormat; | ||
14 | * Created by zhao yue on 2017/1/14. | 15 | * Created by zhao yue on 2017/1/14. |
15 | */ | 16 | */ |
16 | public class Data { | 17 | public class Data { |
17 | - public static final String ADMIN_ACCOUNT = "user1"; | ||
18 | - public static final String ADMIN_PWD = "pass1"; | ||
19 | public static final String USR_ACCOUNT = "15211112222"; | 18 | public static final String USR_ACCOUNT = "15211112222"; |
20 | public static String AMP_REPORT = ""; | 19 | public static String AMP_REPORT = ""; |
21 | 20 | ||
@@ -81,7 +80,7 @@ public class Data { | @@ -81,7 +80,7 @@ public class Data { | ||
81 | report.put("stable", "99999"); | 80 | report.put("stable", "99999"); |
82 | report.put("weight", 45); | 81 | report.put("weight", 45); |
83 | report.put("title", "AMP无创健康评估报告"); // report title | 82 | report.put("title", "AMP无创健康评估报告"); // report title |
84 | - report.put("account", "15211112222"); | 83 | + report.put("account", Constants.USR_ACC); // user account |
85 | report.put("machine_num", "10311212");//machine serial | 84 | report.put("machine_num", "10311212");//machine serial |
86 | 85 | ||
87 | // /* | 86 | // /* |
@@ -34,7 +34,7 @@ public class ReportTest { | @@ -34,7 +34,7 @@ public class ReportTest { | ||
34 | 34 | ||
35 | @Test | 35 | @Test |
36 | public void testAddReport() { | 36 | public void testAddReport() { |
37 | - String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD); | 37 | + String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD); |
38 | Map<String, String> params = new HashMap<String, String>(); | 38 | Map<String, String> params = new HashMap<String, String>(); |
39 | // 程序自动生成json报告。 | 39 | // 程序自动生成json报告。 |
40 | String report = Data.AMP_REPORT; | 40 | String report = Data.AMP_REPORT; |
@@ -47,7 +47,7 @@ public class ReportTest { | @@ -47,7 +47,7 @@ public class ReportTest { | ||
47 | 47 | ||
48 | @Test | 48 | @Test |
49 | public void testDelReport() { | 49 | public void testDelReport() { |
50 | - String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD); | 50 | + String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD); |
51 | Map<String, String> params = new HashMap<String, String>(); | 51 | Map<String, String> params = new HashMap<String, String>(); |
52 | params.put("report_id", "143"); | 52 | params.put("report_id", "143"); |
53 | String response = HttpTools.requestByMapWithToken(URL_REPORT, "DELETE", params, token); | 53 | String response = HttpTools.requestByMapWithToken(URL_REPORT, "DELETE", params, token); |
@@ -59,7 +59,7 @@ public class AccountTest { | @@ -59,7 +59,7 @@ public class AccountTest { | ||
59 | */ | 59 | */ |
60 | @Test | 60 | @Test |
61 | public void testLoginSuccess() { | 61 | public void testLoginSuccess() { |
62 | - System.out.println(loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD)); | 62 | + System.out.println(loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD)); |
63 | } | 63 | } |
64 | 64 | ||
65 | /** | 65 | /** |
@@ -67,7 +67,7 @@ public class AccountTest { | @@ -67,7 +67,7 @@ public class AccountTest { | ||
67 | */ | 67 | */ |
68 | @Test | 68 | @Test |
69 | public void testLoginFail() { | 69 | public void testLoginFail() { |
70 | - System.out.println(loginAndGetToken(Data.ADMIN_ACCOUNT + "ppppp", Data.ADMIN_PWD)); | 70 | + System.out.println(loginAndGetToken(Constants.ADMIN_ACCOUNT + "ppppp", Constants.ADMIN_PWD)); |
71 | } | 71 | } |
72 | 72 | ||
73 | /** | 73 | /** |
@@ -75,7 +75,7 @@ public class AccountTest { | @@ -75,7 +75,7 @@ public class AccountTest { | ||
75 | */ | 75 | */ |
76 | @Test | 76 | @Test |
77 | public void testLoginModPwdSuccess() { | 77 | public void testLoginModPwdSuccess() { |
78 | - System.out.println(loginModPwdAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD, Data.ADMIN_PWD)); | 78 | + System.out.println(loginModPwdAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD, Constants.ADMIN_PWD)); |
79 | } | 79 | } |
80 | 80 | ||
81 | /** | 81 | /** |
@@ -83,13 +83,13 @@ public class AccountTest { | @@ -83,13 +83,13 @@ public class AccountTest { | ||
83 | */ | 83 | */ |
84 | @Test | 84 | @Test |
85 | public void testLoginModPwdFail() { | 85 | public void testLoginModPwdFail() { |
86 | - System.out.println(loginModPwdAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD + "pppppp", Data.ADMIN_PWD)); | 86 | + System.out.println(loginModPwdAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD + "pppppp", Constants.ADMIN_PWD)); |
87 | } | 87 | } |
88 | 88 | ||
89 | 89 | ||
90 | @Test | 90 | @Test |
91 | public void testLogout() { | 91 | public void testLogout() { |
92 | - String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD); | 92 | + String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD); |
93 | Map<String, String> params = new HashMap<String, String>(); | 93 | Map<String, String> params = new HashMap<String, String>(); |
94 | params.put("t", HttpTools.getNow()); | 94 | params.put("t", HttpTools.getNow()); |
95 | String response = HttpTools.requestByMapWithToken(URL_LOGIN, "DELETE", params, token); | 95 | String response = HttpTools.requestByMapWithToken(URL_LOGIN, "DELETE", params, token); |
@@ -98,7 +98,7 @@ public class AccountTest { | @@ -98,7 +98,7 @@ public class AccountTest { | ||
98 | 98 | ||
99 | @Test | 99 | @Test |
100 | public void testLogoutFail() { | 100 | public void testLogoutFail() { |
101 | - String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD); | 101 | + String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD); |
102 | Map<String, String> params = new HashMap<String, String>(); | 102 | Map<String, String> params = new HashMap<String, String>(); |
103 | params.put("t", HttpTools.getNow()); | 103 | params.put("t", HttpTools.getNow()); |
104 | String response = HttpTools.requestByMapWithToken(URL_LOGIN, "DELETE", params, token + "PPPPPP"); | 104 | String response = HttpTools.requestByMapWithToken(URL_LOGIN, "DELETE", params, token + "PPPPPP"); |
1 | package com.xkl.uspih; | 1 | package com.xkl.uspih; |
2 | 2 | ||
3 | 3 | ||
4 | +import com.xkl.Constants; | ||
4 | import org.json.JSONArray; | 5 | import org.json.JSONArray; |
5 | import org.json.JSONObject; | 6 | import org.json.JSONObject; |
6 | import org.junit.Test; | 7 | import org.junit.Test; |
@@ -56,7 +57,7 @@ public class Data { | @@ -56,7 +57,7 @@ public class Data { | ||
56 | report.put("stable", "99999"); | 57 | report.put("stable", "99999"); |
57 | report.put("weight", 45); | 58 | report.put("weight", 45); |
58 | report.put("title", "AMP无创健康评估报告"); // report title | 59 | report.put("title", "AMP无创健康评估报告"); // report title |
59 | - report.put("account", "15211112222");//user account | 60 | + report.put("account", Constants.USR_ACC);//user account |
60 | report.put("machine_num", "10311212");//machine serial | 61 | report.put("machine_num", "10311212");//machine serial |
61 | 62 | ||
62 | /* | 63 | /* |
@@ -35,7 +35,7 @@ public class ReportTest { | @@ -35,7 +35,7 @@ public class ReportTest { | ||
35 | @Test | 35 | @Test |
36 | public void testAddReport() { | 36 | public void testAddReport() { |
37 | // | 37 | // |
38 | - String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD); | 38 | + String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD); |
39 | Map<String, String> params = new HashMap<String, String>(); | 39 | Map<String, String> params = new HashMap<String, String>(); |
40 | params.put("json_report", Data.AMP_REPORT); | 40 | params.put("json_report", Data.AMP_REPORT); |
41 | String response = HttpTools.requestByMapWithToken(URL_REPORT, "POST", params, token); | 41 | String response = HttpTools.requestByMapWithToken(URL_REPORT, "POST", params, token); |
@@ -44,7 +44,7 @@ public class ReportTest { | @@ -44,7 +44,7 @@ public class ReportTest { | ||
44 | 44 | ||
45 | @Test | 45 | @Test |
46 | public void testDelReport() { | 46 | public void testDelReport() { |
47 | - String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD); | 47 | + String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD); |
48 | Map<String, String> params = new HashMap<String, String>(); | 48 | Map<String, String> params = new HashMap<String, String>(); |
49 | params.put("report_id", "133"); | 49 | params.put("report_id", "133"); |
50 | String response = HttpTools.requestByMapWithToken(URL_REPORT, "DELETE", params, token); | 50 | String response = HttpTools.requestByMapWithToken(URL_REPORT, "DELETE", params, token); |
@@ -17,7 +17,7 @@ import java.util.Map; | @@ -17,7 +17,7 @@ import java.util.Map; | ||
17 | 17 | ||
18 | public class UsrAccountTest { | 18 | public class UsrAccountTest { |
19 | private static final String URL_LOGIN = Constants.URL_PREFIX + "/uspih/account"; | 19 | private static final String URL_LOGIN = Constants.URL_PREFIX + "/uspih/account"; |
20 | - private static final String URL_USER= Constants.URL_PREFIX + "/uspihusr"; | 20 | + private static final String URL_USER = Constants.URL_PREFIX + "/uspihusr"; |
21 | 21 | ||
22 | 22 | ||
23 | public static String loginAndGetToken(String user, String pass) { | 23 | public static String loginAndGetToken(String user, String pass) { |
@@ -35,7 +35,7 @@ public class UsrAccountTest { | @@ -35,7 +35,7 @@ public class UsrAccountTest { | ||
35 | 35 | ||
36 | @Test | 36 | @Test |
37 | public void testAccountExistVerify() { | 37 | public void testAccountExistVerify() { |
38 | - String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD); | 38 | + String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD); |
39 | Map<String, String> params = new HashMap<String, String>(); | 39 | Map<String, String> params = new HashMap<String, String>(); |
40 | params.put("usraccount", Data.USR_ACCOUNT); | 40 | params.put("usraccount", Data.USR_ACCOUNT); |
41 | String response = HttpTools.requestByMapWithToken(URL_USER, "GET", params, token); | 41 | String response = HttpTools.requestByMapWithToken(URL_USER, "GET", params, token); |
@@ -45,9 +45,9 @@ public class UsrAccountTest { | @@ -45,9 +45,9 @@ public class UsrAccountTest { | ||
45 | 45 | ||
46 | @Test | 46 | @Test |
47 | public void testAccountNotExist() { | 47 | public void testAccountNotExist() { |
48 | - String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD); | 48 | + String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD); |
49 | Map<String, String> params = new HashMap<String, String>(); | 49 | Map<String, String> params = new HashMap<String, String>(); |
50 | - params.put("usraccount", Data.USR_ACCOUNT+"not exist account"); | 50 | + params.put("usraccount", Data.USR_ACCOUNT + "not exist account"); |
51 | String response = HttpTools.requestByMapWithToken(URL_USER, "GET", params, token); | 51 | String response = HttpTools.requestByMapWithToken(URL_USER, "GET", params, token); |
52 | System.out.println("verify status:" + response); | 52 | System.out.println("verify status:" + response); |
53 | } | 53 | } |
-
Please register or login to post a comment