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");
}
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);
}
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);
}
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);
}
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);
}
Aggregations