use of com.androidquery.callback.AjaxStatus in project androidquery by androidquery.
the class AQueryImageTest method testImageIOError.
public void testImageIOError() {
clearCache();
AQUtility.cleanCache(AQUtility.getCacheDir(getActivity()), 0, 0);
File file = aq.getCachedFile(LAND_URL);
assertNull(file);
AQUtility.TEST_IO_EXCEPTION = true;
AQUtility.post(new Runnable() {
@Override
public void run() {
BitmapAjaxCallback cb = new BitmapAjaxCallback() {
protected void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status) {
AQUtility.debug("bm", bm);
//iv.setImageBitmap(bm);
bmResult = bm;
}
};
aq.id(R.id.image).image(LAND_URL, true, true, 0, 0, cb);
}
});
waitAsync(2000);
assertNull(bmResult);
File file2 = aq.getCachedFile(LAND_URL);
if (file2 != null) {
AQUtility.debug("file length", file2.length());
}
assertNull(file2);
}
use of com.androidquery.callback.AjaxStatus in project androidquery by androidquery.
the class AQueryAsyncTest method testAjaxPostMulti.
public void testAjaxPostMulti() {
String url = "http://www.androidquery.com/p/multipart";
Map<String, Object> params = new HashMap<String, Object>();
byte[] data = new byte[1234];
byte[] data2 = new byte[2345];
params.put("data", data);
params.put("data2", data2);
aq.ajax(url, params, JSONObject.class, new AjaxCallback<JSONObject>() {
@Override
public void callback(String url, JSONObject jo, AjaxStatus status) {
AQUtility.debug(status.getCode(), status.getError());
AQueryAsyncTest.this.result = jo;
}
});
waitAsync();
JSONObject jo = (JSONObject) result;
AQUtility.debug(jo);
assertNotNull(jo);
assertEquals(1234, jo.optInt("data"));
assertEquals(2345, jo.optInt("data2"));
}
use of com.androidquery.callback.AjaxStatus in project androidquery by androidquery.
the class AQueryAsyncTest method testFile404.
public void testFile404() {
String url = "http://androidquery.appspot.com/test/fake";
File old = aq.getCachedFile(url);
if (old != null) {
old.delete();
}
old = aq.getCachedFile(url);
assertNull(old);
AjaxCallback<File> cb = new AjaxCallback<File>();
cb.url(url).type(File.class);
//aq.ajax(url, JSONObject.class, cb);
aq.sync(cb);
File file = cb.getResult();
AjaxStatus status = cb.getStatus();
assertNull(file);
assertEquals(404, status.getCode());
old = aq.getCachedFile(url);
assertNull(old);
}
use of com.androidquery.callback.AjaxStatus in project androidquery by androidquery.
the class AQueryAsyncTest method testAjaxProxy.
//http://www.proxynova.com/proxy-server-list/
public void testAjaxProxy() throws ClientProtocolException, IOException {
String url = "http://www.google.com";
aq.ajax(url, String.class, new AjaxCallback<String>() {
@Override
public void callback(String url, String json, AjaxStatus status) {
done(url, json, status);
}
}.proxy("192.168.0.105", 3128));
waitAsync();
assertNotNull(result);
List<Header> headers = status.getHeaders();
assertTrue(headers.size() > 0);
Header c = headers.get(0);
AQUtility.debug(c.getName(), c.getValue());
}
use of com.androidquery.callback.AjaxStatus in project androidquery by androidquery.
the class AQueryAsyncTest method testAjaxProxyStaticNTLMCredential.
public void testAjaxProxyStaticNTLMCredential() throws ClientProtocolException, IOException {
String url = "http://www.google.com";
String proxyHost = "192.168.111.20";
String domain = "AIGENSTEST.com";
String user = "user3";
String password = "Orange99";
int port = 8081;
//ProxyHandle handle = new BasicProxyHandle(host, port, user, password);
ProxyHandle handle = new NTLMProxyHandle(proxyHost, port, domain, user, password);
AjaxCallback.setProxyHandle(handle);
aq.ajax(url, String.class, new AjaxCallback<String>() {
@Override
public void callback(String url, String json, AjaxStatus status) {
done(url, json, status);
}
});
waitAsync();
assertNotNull(result);
}
Aggregations