Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fangyeqing
/
xkl-interface-example-all
·
Commits
Go to a project
GitLab
Go to dashboard
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
fangyeqing
8 years ago
Commit
3c0aca86ccbe2a0f1206d9513075bb0bbb5cc09e
2 parents
c5009ab0
6693f9f6
merge
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
1 deletions
lib/hamcrest-core-1.3.jar
push.sh
src/test/java/com/xkl/upsoft/AdminInfoTest.java
lib/hamcrest-core-1.3.jar
0 → 100644
View file @
3c0aca8
No preview for this file type
push.sh
View file @
3c0aca8
git pull
git add --all src/
*
git add --all lib/
*
git add push.sh
git add pom.xml
git commit -m
"
Modify to make better
"
git commit -m
"
Add admin info test
"
git push origin master
git status
git pull
...
...
src/test/java/com/xkl/upsoft/AdminInfoTest.java
0 → 100644
View file @
3c0aca8
package
com
.
xkl
.
upsoft
;
import
com.xkl.Constants
;
import
com.xkl.EncodeTools
;
import
com.xkl.HttpTools
;
import
org.json.JSONObject
;
import
org.junit.Test
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 获取admin个人信息
*/
public
class
AdminInfoTest
{
private
static
final
String
URL_ADMININFO
=
Constants
.
URL_PREFIX
+
"/adminInfo"
;
private
static
final
String
URL_LOGIN
=
Constants
.
URL_PREFIX
+
"/upsoft/account"
;
public
static
String
loginAndGetToken
(
String
user
,
String
pass
)
{
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"account"
,
user
);
params
.
put
(
"password"
,
EncodeTools
.
encode
(
"MD5"
,
pass
));
params
.
put
(
"t"
,
HttpTools
.
getNow
());
String
response
=
HttpTools
.
requestByMap
(
URL_LOGIN
,
"POST"
,
params
);
System
.
out
.
println
(
"login success:"
+
response
);
JSONObject
jsonObject
=
new
JSONObject
(
response
);
JSONObject
content
=
jsonObject
.
getJSONObject
(
"content"
);
return
content
.
getString
(
"userId"
)
+
"_"
+
content
.
getString
(
"token"
);
}
@Test
public
void
testGetAdminInfo
()
{
String
token
=
loginAndGetToken
(
Data
.
ADMIN_ACCOUNT
,
Data
.
ADMIN_PWD
);
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"t"
,
HttpTools
.
getNow
());
String
response
=
HttpTools
.
requestByMapWithToken
(
URL_ADMININFO
,
"GET"
,
params
,
token
);
System
.
out
.
println
(
"admin info get success:"
+
response
);
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment