Search in sources :

Example 46 with BaseDataType

use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.

the class TimeOutWatcherTest method testThrowingTimeout.

/**
 * Tests that a timeout error is thrown if the response of the request has not been received after the timeout period.
 */
@Suppress
public void testThrowingTimeout() {
    Log.i("testThrowingTimeout()", "-begin");
    final Request request = createRequestWithTimeout(TIMEOUT_2000_MS);
    // check that the response queue is empty for the engine with EngineId.UNDEFINED id (we use this one for the test)
    DecodedResponse response = ResponseQueue.getInstance().getNextResponse(EngineId.UNDEFINED);
    assertNull(response);
    // adding the request to the queue should add it to the TimeOutWatcher
    final int reqId = QueueManager.getInstance().addRequest(request);
    // check that the response queue is still empty
    response = ResponseQueue.getInstance().getNextResponse(EngineId.UNDEFINED);
    assertNull(response);
    // let's give at least 2 times the timeout to the system before checking
    long stopTime = System.currentTimeMillis() + (TIMEOUT_2000_MS * 2);
    while (System.currentTimeMillis() < stopTime) {
        try {
            Thread.sleep(TIMEOUT_2000_MS);
        } catch (InterruptedException ie) {
            Log.i("testThrowingTimeout()", "Error while sleeping: " + ie);
        }
    }
    // check that the response is still empty
    response = ResponseQueue.getInstance().getNextResponse(EngineId.UNDEFINED);
    assertNotNull(response);
    // check response request id is the same as the request id
    assertEquals(reqId, response.mReqId.intValue());
    // check the timeout error returned is as expected
    assertNotNull(response.mDataTypes);
    assertEquals(1, response.mDataTypes.size());
    BaseDataType error = response.mDataTypes.get(0);
    assertTrue(error instanceof ServerError);
    ServerError srvError = (ServerError) error;
    assertEquals(ServerError.ErrorType.REQUEST_TIMEOUT, srvError.getType());
    Log.i("testThrowingTimeout()", "-end");
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) ServerError(com.vodafone360.people.datatypes.ServerError) Request(com.vodafone360.people.service.io.Request) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 47 with BaseDataType

use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.

the class HessianDecoderTest method testSessionResponse.

/*
	 * 
	 * r{1}{0}fS{0}{4}codeS{0}{14}INTERNAL_ERRORS{0}{7}
	 * messageS{0}hError occured while getting contacts. Message was: Object reference not set to an instance of an object.S{0}{7}detailsMt{0}{0}S{0}{5}classS{0}Dcom.vodafone.next.api.common.APIStructures$APIInternalErrorExceptionzzz
	 */
@MediumTest
public void testSessionResponse() {
    // boolean testPassed = true;
    List<BaseDataType> slist = new ArrayList<BaseDataType>();
    HessianDecoder hess = new HessianDecoder();
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(1, testSessionData, Type.COMMON, false, EngineId.UNDEFINED);
        slist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    int size = slist.size();
    assertTrue(size == 1);
    assertTrue(slist.get(0) instanceof AuthSessionHolder);
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) AuthSessionHolder(com.vodafone360.people.datatypes.AuthSessionHolder) ArrayList(java.util.ArrayList) HessianDecoder(com.vodafone360.people.service.utils.hessian.HessianDecoder) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) IOException(java.io.IOException) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 48 with BaseDataType

use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.

the class HessianDecoderTest method testContactListResponse.

@MediumTest
public void testContactListResponse() {
    // boolean testPassed = true;
    List<BaseDataType> clist = new ArrayList<BaseDataType>();
    HessianDecoder hess = new HessianDecoder();
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(3, testContactListData, Type.COMMON, false, EngineId.UNDEFINED);
        clist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    int size = clist.size();
    assertTrue(size == 3);
    assertTrue(clist.get(0) instanceof Contact);
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) ArrayList(java.util.ArrayList) HessianDecoder(com.vodafone360.people.service.utils.hessian.HessianDecoder) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) IOException(java.io.IOException) Contact(com.vodafone360.people.datatypes.Contact) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 49 with BaseDataType

use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.

the class HessianDecoderTest method testUserProfileResponse.

@MediumTest
public void testUserProfileResponse() {
    // boolean testPassed = true;
    List<BaseDataType> ulist = new ArrayList<BaseDataType>();
    HessianDecoder hess = new HessianDecoder();
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(2, testUserProfileData, Type.COMMON, false, EngineId.UNDEFINED);
        ulist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    int size = ulist.size();
    assertTrue(size == 1);
    assertTrue(ulist.get(0) instanceof UserProfile);
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) UserProfile(com.vodafone360.people.datatypes.UserProfile) ArrayList(java.util.ArrayList) HessianDecoder(com.vodafone360.people.service.utils.hessian.HessianDecoder) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) IOException(java.io.IOException) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 50 with BaseDataType

use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.

the class HessianDecoderTest method testActivityListResponse.

@MediumTest
public void testActivityListResponse() {
    // boolean testPassed = true;
    List<BaseDataType> clist = new ArrayList<BaseDataType>();
    HessianDecoder hess = new HessianDecoder();
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(5, testActivityList, Type.COMMON, false, EngineId.UNDEFINED);
        clist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    int size = clist.size();
    assertTrue(size == 2);
    assertTrue(clist.get(0) instanceof ActivityItem);
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) ArrayList(java.util.ArrayList) HessianDecoder(com.vodafone360.people.service.utils.hessian.HessianDecoder) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) IOException(java.io.IOException) ActivityItem(com.vodafone360.people.datatypes.ActivityItem) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Aggregations

BaseDataType (com.vodafone360.people.datatypes.BaseDataType)29 ArrayList (java.util.ArrayList)25 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)21 ServiceStatus (com.vodafone360.people.service.ServiceStatus)15 ServerError (com.vodafone360.people.datatypes.ServerError)12 MediumTest (android.test.suitebuilder.annotation.MediumTest)9 Contact (com.vodafone360.people.datatypes.Contact)9 IOException (java.io.IOException)9 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)8 Identity (com.vodafone360.people.datatypes.Identity)7 ResponseQueue (com.vodafone360.people.service.io.ResponseQueue)7 HessianDecoder (com.vodafone360.people.service.utils.hessian.HessianDecoder)7 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)6 ExternalResponseObject (com.vodafone360.people.datatypes.ExternalResponseObject)5 PushEvent (com.vodafone360.people.datatypes.PushEvent)5 StatusMsg (com.vodafone360.people.datatypes.StatusMsg)5 Bundle (android.os.Bundle)3 Suppress (android.test.suitebuilder.annotation.Suppress)3 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)3 AuthSessionHolder (com.vodafone360.people.datatypes.AuthSessionHolder)3