use of com.microsoft.live.mock.MockHttpClient in project LiveSDK-for-Android by liveservices.
the class ApiTest method loadLiveLibraryHeaderChecker.
/**
* Changes the mockClient to one that checks if the incoming requests contains the
* Live Library header and then reverts to the original mockClient.
*/
protected void loadLiveLibraryHeaderChecker() {
final MockHttpClient currentMockClient = this.mockClient;
MockHttpClient liveLibraryHeaderCheckerClient = new MockHttpClient() {
@Override
public HttpResponse execute(HttpUriRequest request) throws IOException, ClientProtocolException {
Header header = request.getFirstHeader("X-HTTP-Live-Library");
assertEquals("android/" + Build.VERSION.RELEASE + "_5.0", header.getValue());
// load the old mock client back after we check.
mockClient = currentMockClient;
return currentMockClient.execute(request);
}
@Override
public HttpResponse getHttpResponse() {
return currentMockClient.getHttpResponse();
}
@Override
public void setHttpResponse(HttpResponse httpResponse) {
currentMockClient.setHttpResponse(httpResponse);
}
@Override
public void addHttpResponse(HttpResponse httpResponse) {
currentMockClient.addHttpResponse(httpResponse);
}
@Override
public void clearHttpResponseQueue() {
currentMockClient.clearHttpResponseQueue();
}
};
this.mockClient = liveLibraryHeaderCheckerClient;
}
use of com.microsoft.live.mock.MockHttpClient in project LiveSDK-for-Android by liveservices.
the class ApiTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
// Set up the MockClient
this.mockEntity = new MockHttpEntity();
StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
this.mockResponse = new MockHttpResponse(this.mockEntity, statusLine);
this.mockClient = new MockHttpClient(this.mockResponse);
this.loadLiveLibraryHeaderChecker();
this.exceptionQueue = new LinkedBlockingQueue<LiveOperationException>();
this.liveConnectClient = TestUtils.newLiveConnectClient(this.mockClient);
}
Aggregations