本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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));
}
示例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);
}
示例10: setResponseErrorHandler
import org.springframework.web.client.ResponseErrorHandler; //导入依赖的package包/类
@Override
public void setResponseErrorHandler(ResponseErrorHandler errorHandler) {
this.restTemplate.setErrorHandler(errorHandler);
}
示例11: setResponseErrorHandler
import org.springframework.web.client.ResponseErrorHandler; //导入依赖的package包/类
@Override
public void setResponseErrorHandler(ResponseErrorHandler errorHandler) {
cc.setResponseErrorHandler(errorHandler);
}
示例12: setResponseErrorHandler
import org.springframework.web.client.ResponseErrorHandler; //导入依赖的package包/类
@Override
public void setResponseErrorHandler(ResponseErrorHandler errorHandler) {
}
示例13: DefaultRestTemplateFactoryImpl
import org.springframework.web.client.ResponseErrorHandler; //导入依赖的package包/类
public DefaultRestTemplateFactoryImpl(ResponseErrorHandler errorHandler) {
this.errorHandler = errorHandler;
}
示例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();
}