當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpRequest.setNumberOfRetries方法代碼示例

本文整理匯總了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) {
	}	
}
 
開發者ID:postmen,項目名稱:postmen-sdk-java,代碼行數:19,代碼來源:PostmenUnsuccessfulResponseHandlerTest.java

示例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) {
	}	
}
 
開發者ID:postmen,項目名稱:postmen-sdk-java,代碼行數:25,代碼來源:PostmenUnsuccessfulResponseHandlerTest.java

示例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) {
	}	
}
 
開發者ID:postmen,項目名稱:postmen-sdk-java,代碼行數:22,代碼來源:PostmenUnsuccessfulResponseHandlerTest.java

示例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) {
	}	
}
 
開發者ID:postmen,項目名稱:postmen-sdk-java,代碼行數:20,代碼來源:PostmenUnsuccessfulResponseHandlerTest.java

示例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) {
	}	
}
 
開發者ID:postmen,項目名稱:postmen-sdk-java,代碼行數:20,代碼來源:PostmenUnsuccessfulResponseHandlerTest.java

示例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) {
	}	
}
 
開發者ID:postmen,項目名稱:postmen-sdk-java,代碼行數:20,代碼來源:PostmenUnsuccessfulResponseHandlerTest.java

示例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);
}
 
開發者ID:marvin-we,項目名稱:steemj-image-upload,代碼行數:7,代碼來源:HttpClientRequestInitializer.java


注:本文中的com.google.api.client.http.HttpRequest.setNumberOfRetries方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。