liferay / liferay-mobile-sdk

Other
47 stars 56 forks source link

Android & Liferay Mobile SDK: timeout ignored #16

Closed morningstar84 closed 9 years ago

morningstar84 commented 9 years ago

I write because I'm developing an Android App that uses Liferay as a backend. I am experiencing the anomalous behavior in the management of timeout while invoking Liferay's journal article service. In detail, I've setup the session in this two methods described in "SettingsUtils.java". But while I perform the request no exception is raised even if the timeout is arbitrarily low. I wrote a test case "TestCase.java" is completed successfully without exception.

My development environment is Mac OS X (10.10.2) and I'm using Android Studio with Java [ java version "1.8.0_40", Java(TM) SE Runtime Environment (build 1.8.0_40-b27) ].

Thanks for your help

// ------------------ "SettingsUtils.java"

    BasicAuthentication basicAuthentication = new BasicAuthentication(getLogin(), getPassword());

    Session sessionImpl = new SessionImpl(getServer(), basicAuthentication);
    sessionImpl.setConnectionTimeout(1);

// ------------------ "TestCase.java"

public class TestCase extends InstrumentationTestCase {

private static final int CONN_TIMEOUT = 1;

public void testTimeout() throws Exception{
    BasicAuthentication basicAuthentication = new BasicAuthentication("user", "password");

    Session sessionImpl = new SessionImpl("http://domain.net", basicAuthentication);
    sessionImpl.setConnectionTimeout(1);

}

}

brunofarache commented 9 years ago

No exception is being thrown because no request is sent in the test, as explained in the forum.

morningstar84 commented 9 years ago

The problem still persist in my application although I invoke the service. Also the working version of the application has been affected and also by changing the test as you can see below, the result is always the same.

No exception

// -- new Test case public void testTimeout() throws Exception{

    Logger.e("Test timeout");

    BasicAuthentication basicAuthentication = new BasicAuthentication("user", "password");

    Session session = new SessionImpl("http://domain.com", basicAuthentication);
    session.setConnectionTimeout(1);

    ClassNameService classNameService = new ClassNameService(session);
    GroupService groupService = new GroupService(session);

    JSONObject nameArray = classNameService.fetchClassName(CLASS_NAME_RESOURCE);
    long portalInstance = Long.parseLong("10364");
    JSONArray groupJsonArray = groupService.getGroups(portalInstance, 0l, true);

    }