use of com.androidquery.callback.AjaxCallback in project androidquery by androidquery.
the class AQueryAsyncTest method testAjaxPut.
public void testAjaxPut() throws UnsupportedEncodingException {
String url = "http://www.androidquery.com/p/doNothing";
AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>() {
@Override
public void callback(String url, JSONObject jo, AjaxStatus status) {
done(url, jo, status);
}
};
StringEntity entity = new StringEntity(new JSONObject().toString());
aq.put(url, "application/json", entity, JSONObject.class, cb);
waitAsync();
JSONObject jo = (JSONObject) result;
AQUtility.debug(jo);
assertNotNull(jo);
assertEquals("PUT", jo.optString("method"));
}
use of com.androidquery.callback.AjaxCallback in project androidquery by androidquery.
the class AQueryAsyncTest method testAjaxAdvance.
//Test: public <K> T ajax(AjaxCallback<K> callback)
public void testAjaxAdvance() {
String url = "http://www.google.com/uds/GnewsSearch?q=Obama&v=1.0";
AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>() {
@Override
public void callback(String url, JSONObject jo, AjaxStatus status) {
done(url, jo, status);
}
};
cb.url(url).type(JSONObject.class);
aq.ajax(cb);
waitAsync();
JSONObject jo = (JSONObject) result;
assertNotNull(jo);
assertNotNull(jo.opt("responseData"));
}
use of com.androidquery.callback.AjaxCallback in project androidquery by androidquery.
the class AQueryServiceTest method testMarketSubmit.
public void testMarketSubmit() throws IOException {
AQUtility.debug("start");
String appId = "com.androidquery";
String locale = "en_US";
//String gurl = "http://192.168.1.222/test/test.htm";
String gurl = "https://market.android.com/details?id=" + appId + "&hl=" + locale;
byte[] data = IOUtility.openBytes(gurl);
String html = new String(data, "UTF-8");
//String url = "http://192.168.1.222/api/market?app=com.androidquery&locale=zh-TW&version=0.13.2&code=16";
String url = "https://androidquery.appspot.com/api/market?app=com.androidquery&locale=en_US&version=0.24.46&code=46&aq=0.23.1&force=true";
//String url = "http://192.168.1.165/api/market?app=com.androidquery&locale=en_US&version=0.24.46&code=46&aq=0.23.1&force=true";
AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>();
cb.url(url).type(JSONObject.class).handler(this, "jsonCb");
cb.param("html", html);
aq.ajax(cb);
waitAsync();
JSONObject jo = (JSONObject) result;
String pub = jo.optString("published", null);
String code = jo.optString("code", null);
AQUtility.debug("jo", jo);
AQUtility.debug("pub", pub);
AQUtility.debug("code", code);
assertNotNull(pub);
assertNotNull(code);
}
use of com.androidquery.callback.AjaxCallback in project androidquery by androidquery.
the class AQueryAsyncTest method testRetryOk.
public void testRetryOk() {
String url = "http://www.androidquery.com/p/retry?wait=3000";
AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>();
cb.retry(1).weakHandler(this, "jsonCb").timeout(1000);
aq.ajax(url, JSONObject.class, cb);
waitAsync();
JSONObject jo = (JSONObject) result;
assertNotNull(jo);
assertEquals(200, status.getCode());
}
use of com.androidquery.callback.AjaxCallback in project androidquery by androidquery.
the class AQueryAsyncTest method testWaitBlock.
public void testWaitBlock() {
String url = "http://www.google.com/uds/GnewsSearch?q=Obama&v=1.0";
AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>();
cb.url(url).type(JSONObject.class);
aq.sync(cb);
String u = cb.getUrl();
JSONObject jo = cb.getResult();
AjaxStatus status = cb.getStatus();
assertNotNull(jo);
assertNotNull(jo.opt("responseData"));
checkStatus(status);
}
Aggregations