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


Java ResponseErrorHandler類代碼示例

本文整理匯總了Java中org.springframework.web.client.ResponseErrorHandler的典型用法代碼示例。如果您正苦於以下問題:Java ResponseErrorHandler類的具體用法?Java ResponseErrorHandler怎麽用?Java ResponseErrorHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ResponseErrorHandler類屬於org.springframework.web.client包,在下文中一共展示了ResponseErrorHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: RestTemplateBuilder

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
private RestTemplateBuilder(boolean detectRequestFactory, String rootUri,
		Set<HttpMessageConverter<?>> messageConverters,
		ClientHttpRequestFactory requestFactory,
		UriTemplateHandler uriTemplateHandler, ResponseErrorHandler errorHandler,
		BasicAuthorizationInterceptor basicAuthorization,
		Set<RestTemplateCustomizer> restTemplateCustomizers,
		Set<RequestFactoryCustomizer> requestFactoryCustomizers) {
	super();
	this.detectRequestFactory = detectRequestFactory;
	this.rootUri = rootUri;
	this.messageConverters = messageConverters;
	this.requestFactory = requestFactory;
	this.uriTemplateHandler = uriTemplateHandler;
	this.errorHandler = errorHandler;
	this.basicAuthorization = basicAuthorization;
	this.restTemplateCustomizers = restTemplateCustomizers;
	this.requestFactoryCustomizers = requestFactoryCustomizers;
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:19,代碼來源:RestTemplateBuilder.java

示例2: RestTemplateBuilder

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
private RestTemplateBuilder(boolean detectRequestFactory, String rootUri,
		Set<HttpMessageConverter<?>> messageConverters,
		ClientHttpRequestFactory requestFactory,
		UriTemplateHandler uriTemplateHandler, ResponseErrorHandler errorHandler,
		BasicAuthorizationInterceptor basicAuthorization,
		Set<RestTemplateCustomizer> customizers) {
	super();
	this.detectRequestFactory = detectRequestFactory;
	this.rootUri = rootUri;
	this.messageConverters = messageConverters;
	this.requestFactory = requestFactory;
	this.uriTemplateHandler = uriTemplateHandler;
	this.errorHandler = errorHandler;
	this.basicAuthorization = basicAuthorization;
	this.customizers = customizers;
}
 
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:17,代碼來源:RestTemplateBuilder.java

示例3: testInvalidCredentials

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
@Test
@OAuth2ContextConfiguration(resource = InvalidClientCredentials.class, initialize = false)
public void testInvalidCredentials() throws Exception {
	context.setAccessTokenProvider(new ClientCredentialsAccessTokenProvider() {
		@Override
		protected ResponseErrorHandler getResponseErrorHandler() {
			return new DefaultResponseErrorHandler() {
				public void handleError(ClientHttpResponse response) throws IOException {
					responseHeaders = response.getHeaders();
					responseStatus = response.getStatusCode();
				}
			};
		}
	});
	try {
		context.getAccessToken();
		fail("Expected ResourceAccessException");
	}
	catch (Exception e) {
		// ignore
	}
	// System.err.println(responseHeaders);
	String header = responseHeaders.getFirst("WWW-Authenticate");
	assertTrue("Wrong header: " + header, header.contains("Basic realm"));
	assertEquals(HttpStatus.UNAUTHORIZED, responseStatus);
}
 
開發者ID:jungyang,項目名稱:oauth-client-master,代碼行數:27,代碼來源:ClientCredentialsProviderTests.java

示例4: handleError

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
public void handleError() {
	// handle error2
	RestTemplate client = new RestTemplate();
	ResponseErrorHandler responseErrorHandler = new DefaultResponseErrorHandler() {
		@Override
		public void handleError(ClientHttpResponse response)
				throws IOException {
			LOGGER.warn("response status: '{}', headers: '{}'",
					response.getStatusCode(), response.getHeaders());
		}
	};
	
	client.setErrorHandler(responseErrorHandler);

	client.exchange("http://localhost:8080/person/denied", HttpMethod.GET,
			null, String.class);
}
 
開發者ID:spotlight2001,項目名稱:itsme,代碼行數:18,代碼來源:MyRestClient.java

示例5: setErrorHandlerWithUnderlying

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
@Test
public void setErrorHandlerWithUnderlying() {
  ResponseErrorHandler errorHandler = mock(ResponseErrorHandler.class);

  wrapper.setErrorHandler(errorHandler);

  assertThat(wrapper.getErrorHandler(), is(errorHandler));
  assertThat(wrapper.defaultRestTemplate.getErrorHandler(), is(errorHandler));

  verify(underlying).setErrorHandler(errorHandler);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:12,代碼來源:TestRestTemplateWrapper.java

示例6: buildOAuth2RestTemplate

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
private RestOperations buildOAuth2RestTemplate(final String tokenName, final ResponseErrorHandler errorHandler) {
    final RestTemplate restTemplate = new StupsOAuth2RestTemplate(
            new StupsTokensAccessTokenProvider(tokenName, accessTokens),
            new HttpComponentsClientHttpRequestFactory());

    if (errorHandler != null) {
        restTemplate.setErrorHandler(errorHandler);
    }

    return restTemplate;
}
 
開發者ID:zalando-stups,項目名稱:fullstop,代碼行數:12,代碼來源:ClientConfig.java

示例7: testInvalidCredentialsWithFormAuthentication

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
@Test
@OAuth2ContextConfiguration(resource = InvalidClientCredentials.class, initialize = false)
public void testInvalidCredentialsWithFormAuthentication() throws Exception {
	resource.setClientAuthenticationScheme(AuthenticationScheme.form);
	context.setAccessTokenProvider(new ClientCredentialsAccessTokenProvider() {
		@Override
		protected ResponseErrorHandler getResponseErrorHandler() {
			return new DefaultResponseErrorHandler() {
				public void handleError(ClientHttpResponse response) throws IOException {
					responseHeaders = response.getHeaders();
					responseStatus = response.getStatusCode();
				}
			};
		}
	});
	try {
		context.getAccessToken();
		fail("Expected ResourceAccessException");
	}
	catch (Exception e) {
		// ignore
	}
	// System.err.println(responseHeaders);
	String header = responseHeaders.getFirst("WWW-Authenticate");
	assertTrue("Wrong header: " + header, header.contains("Form realm"));
	assertEquals(HttpStatus.UNAUTHORIZED, responseStatus);
}
 
開發者ID:jungyang,項目名稱:oauth-client-master,代碼行數:28,代碼來源:ClientCredentialsProviderTests.java

示例8: GaeRestTemplate

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
public GaeRestTemplate(Type responseType, ResponseErrorHandler errorHandler, List<ClientHttpRequestInterceptor> interceptors) {
	this.setErrorHandler(errorHandler);
	this.setInterceptors(interceptors);

	final GsonHttpMessageConverter converter = new GsonHttpMessageConverter();
	if (responseType != null) {
		converter.setType(responseType);
	}

	this.setMessageConverters(Collections.<HttpMessageConverter<?>>singletonList(converter));
}
 
開發者ID:kultus,項目名稱:StockAnalyze,代碼行數:12,代碼來源:GaeRestTemplate.java

示例9: setErrorHandler

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
@Override
public void setErrorHandler(ResponseErrorHandler errorHandler) {
  super.setErrorHandler(errorHandler);
  acceptableRestTemplates.forEach(template -> template.setErrorHandler(errorHandler));
  defaultRestTemplate.setErrorHandler(errorHandler);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:7,代碼來源:RestTemplateWrapper.java

示例10: setResponseErrorHandler

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
@Override
public void setResponseErrorHandler(ResponseErrorHandler errorHandler) {
    this.restTemplate.setErrorHandler(errorHandler);
}
 
開發者ID:SAP,項目名稱:cf-java-client-sap,代碼行數:5,代碼來源:CloudControllerClientImpl.java

示例11: setResponseErrorHandler

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
@Override
public void setResponseErrorHandler(ResponseErrorHandler errorHandler) {
    cc.setResponseErrorHandler(errorHandler);
}
 
開發者ID:SAP,項目名稱:cf-java-client-sap,代碼行數:5,代碼來源:CloudFoundryClient.java

示例12: setResponseErrorHandler

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
@Override
public void setResponseErrorHandler(ResponseErrorHandler errorHandler) {
}
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:4,代碼來源:MockCloudFoundryClient.java

示例13: DefaultRestTemplateFactoryImpl

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
public DefaultRestTemplateFactoryImpl(ResponseErrorHandler errorHandler) {
	this.errorHandler = errorHandler;
}
 
開發者ID:AppDirect,項目名稱:service-integration-sdk,代碼行數:4,代碼來源:DefaultRestTemplateFactoryImpl.java

示例14: errorHandlerShouldApply

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
@Test
public void errorHandlerShouldApply() throws Exception {
	ResponseErrorHandler errorHandler = mock(ResponseErrorHandler.class);
	RestTemplate template = this.builder.errorHandler(errorHandler).build();
	assertThat(template.getErrorHandler()).isSameAs(errorHandler);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:7,代碼來源:RestTemplateBuilderTests.java

示例15: errorHandler

import org.springframework.web.client.ResponseErrorHandler; //導入依賴的package包/類
protected ResponseErrorHandler errorHandler() {
    return new DefaultResponseErrorHandler();
}
 
開發者ID:alex-bretet,項目名稱:cloudstreetmarket.com,代碼行數:4,代碼來源:Yahoo2Template.java


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