本文整理匯總了Java中com.google.api.client.http.HttpRequest.setNumberOfRetries方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpRequest.setNumberOfRetries方法的具體用法?Java HttpRequest.setNumberOfRetries怎麽用?Java HttpRequest.setNumberOfRetries使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.api.client.http.HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.setNumberOfRetries方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testHandleResponse
import com.google.api.client.http.HttpRequest; //導入方法依賴的package包/類
@Test
public void testHandleResponse() {
HttpRequest req;
try {
req = transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL);
req.setNumberOfRetries(5);
LabelResponse labelResponse = new LabelResponse();
Meta meta = new Meta();
meta.setCode(200);
meta.setRetryable(true);
labelResponse.setMeta(meta);
Boolean retry = responseHandler.handleResponse(req, labelResponse, true);
assertTrue(retry);
assertEquals(new Long(1000), sleeper.getDelay());
//responseHandler.handleResponse(req, labelResponse, true);
} catch (IOException e) {
}
}
示例2: testExponentialDelay
import com.google.api.client.http.HttpRequest; //導入方法依賴的package包/類
@Test
public void testExponentialDelay() {
HttpRequest req;
try {
req = transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL);
req.setNumberOfRetries(5);
LabelResponse labelResponse = new LabelResponse();
Meta meta = new Meta();
meta.setCode(200);
meta.setRetryable(true);
labelResponse.setMeta(meta);
Boolean retry = null;
Long delay = new Long(1000);
for(int i = 0; i < 5; i++) {
retry = responseHandler.handleResponse(req, labelResponse, true);
assertEquals(delay, sleeper.getDelay());
delay *= 2;
}
assertTrue(retry);
//responseHandler.handleResponse(req, labelResponse, true);
} catch (IOException e) {
}
}
示例3: testRetryStopOnSixth
import com.google.api.client.http.HttpRequest; //導入方法依賴的package包/類
@Test
public void testRetryStopOnSixth() {
HttpRequest req;
try {
req = transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL);
req.setNumberOfRetries(5);
LabelResponse labelResponse = new LabelResponse();
Meta meta = new Meta();
meta.setCode(200);
meta.setRetryable(true);
labelResponse.setMeta(meta);
Boolean retry = null;
for(int i = 0; i < 6; i++) {
retry = responseHandler.handleResponse(req, labelResponse, true);
}
assertFalse(retry);
//responseHandler.handleResponse(req, labelResponse, true);
} catch (IOException e) {
}
}
示例4: testNotRetryable
import com.google.api.client.http.HttpRequest; //導入方法依賴的package包/類
@Test
public void testNotRetryable() {
HttpRequest req;
try {
req = transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL);
req.setNumberOfRetries(5);
LabelResponse labelResponse = new LabelResponse();
Meta meta = new Meta();
meta.setCode(200);
meta.setRetryable(false);
labelResponse.setMeta(meta);
Boolean retry = null;
retry = responseHandler.handleResponse(req, labelResponse, true);
assertFalse(retry);
//responseHandler.handleResponse(req, labelResponse, true);
} catch (IOException e) {
}
}
示例5: testRetryableNullInResponse
import com.google.api.client.http.HttpRequest; //導入方法依賴的package包/類
@Test
public void testRetryableNullInResponse() {
HttpRequest req;
try {
req = transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL);
req.setNumberOfRetries(5);
LabelResponse labelResponse = new LabelResponse();
Meta meta = new Meta();
meta.setCode(200);
meta.setRetryable(null);
labelResponse.setMeta(meta);
Boolean retry = null;
retry = responseHandler.handleResponse(req, labelResponse, true);
assertFalse(retry);
//responseHandler.handleResponse(req, labelResponse, true);
} catch (IOException e) {
}
}
示例6: testDoNotRetry
import com.google.api.client.http.HttpRequest; //導入方法依賴的package包/類
@Test
public void testDoNotRetry() {
HttpRequest req;
try {
req = transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL);
req.setNumberOfRetries(5);
LabelResponse labelResponse = new LabelResponse();
Meta meta = new Meta();
meta.setCode(200);
meta.setRetryable(true);
labelResponse.setMeta(meta);
Boolean retry = null;
retry = responseHandler.handleResponse(req, labelResponse, false);
assertFalse(retry);
//responseHandler.handleResponse(req, labelResponse, true);
} catch (IOException e) {
}
}
示例7: initialize
import com.google.api.client.http.HttpRequest; //導入方法依賴的package包/類
@Override
public void initialize(HttpRequest request) throws IOException {
request.setConnectTimeout(SteemJImageUploadConfig.getInstance().getConnectTimeout());
request.setReadTimeout(SteemJImageUploadConfig.getInstance().getReadTimeout());
request.setNumberOfRetries(0);
}