本文整理汇总了Java中com.turbomanage.httpclient.ParameterMap类的典型用法代码示例。如果您正苦于以下问题:Java ParameterMap类的具体用法?Java ParameterMap怎么用?Java ParameterMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParameterMap类属于com.turbomanage.httpclient包,在下文中一共展示了ParameterMap类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initWithStubbedSuccessfulConnection
import com.turbomanage.httpclient.ParameterMap; //导入依赖的package包/类
private void initWithStubbedSuccessfulConnection(){
when(mMockHttpClient.addHeader(anyString(), anyString())).thenReturn(mMockHttpClient);
when(mMockHttpClient.newParams()).thenReturn(mMockParameterMap);
when(mMockParameterMap.add(anyString(),anyString())).thenReturn(mMockParameterMap);
when(mMockHttpClient.get(eq(FAKE_URL), any(ParameterMap.class))).thenReturn(
mMockHttpResponse);
when(mMockHttpResponse.getStatus()).thenReturn(HttpURLConnection.HTTP_OK);
}
示例2: sendSessionToServer
import com.turbomanage.httpclient.ParameterMap; //导入依赖的package包/类
/**
* Posts a session to the event server.
*
* @param sessionId The ID of the session that was reviewed.
* @return whether or not updating succeeded
*/
public boolean sendSessionToServer(String sessionId, List<String> questions) {
BasicHttpClient httpClient = new BasicHttpClient();
httpClient.addHeader(PARAMETER_EVENT_CODE, Config.FEEDBACK_API_CODE);
httpClient.addHeader(PARAMETER_API_KEY, Config.FEEDBACK_API_KEY);
ParameterMap parameterMap = httpClient.newParams();
parameterMap.add(PARAMETER_SESSION_ID, sessionId);
parameterMap.add(PARAMETER_SURVEY_ID, Config.FEEDBACK_SURVEY_ID);
parameterMap.add(PARAMETER_REGISTRANT_ID, Config.FEEDBACK_DUMMY_REGISTRANT_ID);
int i = 1;
for (String question : questions) {
parameterMap.add("q" + i, question);
i++;
}
HttpResponse response = httpClient.get(mUrl, parameterMap);
if (response != null && response.getStatus() == HttpURLConnection.HTTP_OK) {
LogUtils.LOGD(TAG, "Server returned HTTP_OK, so session posting was successful.");
return true;
} else {
LogUtils.LOGE(TAG, "Error posting session: HTTP status " + response.getStatus());
return false;
}
}
示例3: sendSessionToServer
import com.turbomanage.httpclient.ParameterMap; //导入依赖的package包/类
/**
* Posts a session to the event server.
*
* @param sessionId The ID of the session that was reviewed.
* @return whether or not updating succeeded
*/
public boolean sendSessionToServer(String sessionId, List<String> questions) {
BasicHttpClient httpClient = new BasicHttpClient();
httpClient.addHeader(PARAMETER_EVENT_CODE, Config.FEEDBACK_API_CODE);
httpClient.addHeader(PARAMETER_API_KEY, Config.FEEDBACK_API_KEY);
ParameterMap parameterMap = httpClient.newParams();
parameterMap.add(PARAMETER_SESSION_ID, sessionId);
parameterMap.add(PARAMETER_SURVEY_ID, Config.FEEDBACK_SURVEY_ID);
parameterMap.add(PARAMETER_REGISTRANT_ID, Config.FEEDBACK_DUMMY_REGISTRANT_ID);
int i = 1;
for (String question : questions) {
parameterMap.add("q" + i, question);
i++;
}
HttpResponse response = httpClient.get(mUrl, parameterMap);
if (response != null && response.getStatus() == HttpURLConnection.HTTP_OK) {
LOGD(TAG, "Server returned HTTP_OK, so session posting was successful.");
return true;
} else {
LOGE(TAG, "Error posting session: HTTP status " + response.getStatus());
return false;
}
}
示例4: OnRun
import com.turbomanage.httpclient.ParameterMap; //导入依赖的package包/类
@Override
protected void OnRun() {
String url = SignalAUtils.EnsureEndsWith(mConnection.getUrl(), "/");
try {
url += "abort?transport=LongPolling&connectionToken=" + URLEncoder.encode(mConnection.getConnectionToken(), "utf-8");
} catch (UnsupportedEncodingException e) {
Log.e(TAG, "Unsupported message encoding error, when encoding connectionToken.");
}
TransportHelper.AppendCustomQueryString(mConnection, url);
AsyncCallback cb = new AsyncCallback() {
@Override
public void onComplete(HttpResponse httpResponse) {
if(httpResponse.getStatus() != 200 || httpResponse.getBodyAsString() == null || httpResponse.getBodyAsString().isEmpty())
{
Log.e(TAG, "Clean disconnect failed. " + httpResponse.getStatus());
}
mConnection.SetNewState(new DisconnectedState(mConnection));
}
@Override
public void onError(Exception ex) {
mConnection.setError(ex);
mConnection.SetNewState(new DisconnectedState(mConnection));
}
};
ParallelHttpClient httpClient = new ParallelHttpClient();
httpClient.setMaxRetries(1);
ParameterMap params = httpClient.newParams();
httpClient.post(url, params, cb);
}
示例5: notifyGcmDevices
import com.turbomanage.httpclient.ParameterMap; //导入依赖的package包/类
private void notifyGcmDevices() {
String plusID = AccountUtils.getPlusProfileId(getApplicationContext());
if (plusID != null) {
LOGI(TAG, "Sending device sync notification");
AndroidHttpClient httpClient = new AndroidHttpClient(Config.GCM_SERVER_URL);
httpClient.setMaxRetries(1);
ParameterMap params = httpClient.newParams()
.add("key", Config.GCM_API_KEY)
.add("squelch", ServerUtilities.getGcmId(this));
String path = "/send/" + plusID + "/sync_user";
httpClient.post(path, params, new AsyncCallback() {
@Override
public void onComplete(HttpResponse httpResponse) {
LOGI(TAG, "Device sync notification sent");
}
@Override
public void onError(Exception e) {
LOGW(TAG, "Device sync notification failed", e);
}
});
} else {
LOGI(TAG, "No gPlusID, skipping device sync notification");
}
}
示例6: initWithStubbedUnsuccessfulConnection
import com.turbomanage.httpclient.ParameterMap; //导入依赖的package包/类
private void initWithStubbedUnsuccessfulConnection(){
when(mMockHttpClient.addHeader(anyString(), anyString())).thenReturn(mMockHttpClient);
when(mMockHttpClient.newParams()).thenReturn(mMockParameterMap);
when(mMockParameterMap.add(anyString(),anyString())).thenReturn(mMockParameterMap);
when(mMockHttpClient.get(eq(FAKE_URL), any(ParameterMap.class))).thenReturn(null);
}