Showing
3 changed files
with
42 additions
and
1 deletions
lib/hamcrest-core-1.3.jar
0 → 100644
No preview for this file type
| 1 | +git pull | ||
| 1 | git add --all src/* | 2 | git add --all src/* |
| 3 | +git add --all lib/* | ||
| 2 | git add push.sh | 4 | git add push.sh |
| 3 | git add pom.xml | 5 | git add pom.xml |
| 4 | -git commit -m "Modify to make better" | 6 | +git commit -m "Add admin info test" |
| 5 | git push origin master | 7 | git push origin master |
| 6 | git status | 8 | git status |
| 7 | git pull | 9 | git pull |
| 1 | +package com.xkl.upsoft; | ||
| 2 | + | ||
| 3 | +import com.xkl.Constants; | ||
| 4 | +import com.xkl.EncodeTools; | ||
| 5 | +import com.xkl.HttpTools; | ||
| 6 | +import org.json.JSONObject; | ||
| 7 | +import org.junit.Test; | ||
| 8 | + | ||
| 9 | +import java.util.HashMap; | ||
| 10 | +import java.util.Map; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 获取admin个人信息 | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +public class AdminInfoTest { | ||
| 17 | + private static final String URL_ADMININFO = Constants.URL_PREFIX + "/adminInfo"; | ||
| 18 | + private static final String URL_LOGIN = Constants.URL_PREFIX + "/upsoft/account"; | ||
| 19 | + | ||
| 20 | + public static String loginAndGetToken(String user, String pass) { | ||
| 21 | + Map<String, String> params = new HashMap<String, String>(); | ||
| 22 | + params.put("account", user); | ||
| 23 | + params.put("password", EncodeTools.encode("MD5", pass)); | ||
| 24 | + params.put("t", HttpTools.getNow()); | ||
| 25 | + String response = HttpTools.requestByMap(URL_LOGIN, "POST", params); | ||
| 26 | + System.out.println("login success:" + response); | ||
| 27 | + JSONObject jsonObject = new JSONObject(response); | ||
| 28 | + JSONObject content = jsonObject.getJSONObject("content"); | ||
| 29 | + return content.getString("userId") + "_" + content.getString("token"); | ||
| 30 | + } | ||
| 31 | + @Test | ||
| 32 | + public void testGetAdminInfo() { | ||
| 33 | + String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD); | ||
| 34 | + Map<String, String> params = new HashMap<String, String>(); | ||
| 35 | + params.put("t", HttpTools.getNow()); | ||
| 36 | + String response = HttpTools.requestByMapWithToken(URL_ADMININFO, "GET", params, token); | ||
| 37 | + System.out.println("admin info get success:" + response); | ||
| 38 | + } | ||
| 39 | +} |
-
Please register or login to post a comment