I am trying to create Unit test on Android project which is working with URL requests. I use loopj library but something doesn't work. Internet is enabled in my manifest:
<uses-permission android:name="android.permission.INTERNET" />
Java code in a test method:
AsyncHttpClient client = new AsyncHttpClient();
client.get("http://www.yahoo.com", new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
System.out.println(response); // <------ I never get here!?!?!
}
});
Folowing procedure (without loopj) works in same unit test method:
URL yahoo;
yahoo = new URL("http://www.yahoo.com/");
BufferedReader in;
in = new BufferedReader(new InputStreamReader(yahoo.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
in.close();
It seems like loopj requests dont work in unit test class but it works normal in basic Activity class. Any suggestion?