Skip to content

Commit 553d2a9

Browse files
committed
Add post raw json case.
1 parent cba8b3d commit 553d2a9

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/src/com/androidquery/test/AQueryAsyncTest.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,41 @@ public void callback(String url, JSONObject jo, AjaxStatus status) {
14151415

14161416
}
14171417

1418+
public void testAjaxPostJson() throws UnsupportedEncodingException{
1419+
1420+
String url = "http://www.androidquery.com/p/doNothing";
1421+
1422+
AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>(){
1423+
1424+
@Override
1425+
public void callback(String url, JSONObject jo, AjaxStatus status) {
1426+
1427+
done(url, jo, status);
1428+
1429+
}
1430+
1431+
};
1432+
1433+
StringEntity entity = new StringEntity(new JSONObject().toString());
1434+
1435+
cb.url(url).type(JSONObject.class).header("Content-Type", "application/json").param(AQuery.POST_ENTITY, entity);
1436+
1437+
aq.ajax(cb);
1438+
1439+
//aq.put(url, "application/json", entity, JSONObject.class, cb);
1440+
1441+
waitAsync();
1442+
1443+
JSONObject jo = (JSONObject) result;
1444+
1445+
AQUtility.debug(jo);
1446+
1447+
assertNotNull(jo);
1448+
1449+
assertEquals("POST", jo.optString("method"));
1450+
1451+
}
1452+
14181453

14191454
public void testAjaxPut() throws UnsupportedEncodingException{
14201455

0 commit comments

Comments
 (0)