当前位置: 首页>>代码示例>>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;未经允许,请勿转载。