From a1a45125ea616663c2ec984f069fe6cc745e0892 Mon Sep 17 00:00:00 2001 From: Olga Maciaszek-Sharma Date: Thu, 13 Dec 2018 18:03:35 +0100 Subject: [PATCH] Upgrade openfeign to 10.1.0 (#95) Upgrade to OpenFeign 10.1.0 --- .../cloud/openfeign/EnableFeignClients.java | 4 +- .../cloud/openfeign/HystrixTargeter.java | 4 +- .../openfeign/ribbon/FeignLoadBalancer.java | 29 +-- .../ribbon/LoadBalancerFeignClient.java | 4 +- .../RibbonResponseStatusCodeException.java | 7 +- .../cloud/openfeign/support/FeignUtils.java | 12 +- .../openfeign/support/SpringEncoder.java | 16 +- .../openfeign/support/SpringMvcContract.java | 23 ++- .../FeignClientUsingPropertiesTests.java | 16 +- .../proto/ProtobufNotInClasspathTest.java | 7 +- .../proto/ProtobufSpringEncoderTest.java | 35 ++-- .../security/HystrixSecurityTests.java | 9 +- .../hystrix/security/app/TestInterceptor.java | 3 +- .../ribbon/FeignLoadBalancerTests.java | 59 +++--- .../ribbon/FeignRibbonClientPathTests.java | 15 +- .../ribbon/FeignRibbonClientTests.java | 23 ++- .../RetryableFeignLoadBalancerTests.java | 172 +++++++++++------- ...RibbonResponseStatusCodeExceptionTest.java | 12 +- .../openfeign/support/SpringEncoderTests.java | 33 ++-- .../support/SpringMvcContractTests.java | 40 ++-- .../ApacheHttpClientConfigurationTests.java | 10 +- .../scanning/FeignClientScanningTests.java | 14 +- spring-cloud-openfeign-dependencies/pom.xml | 2 +- 23 files changed, 327 insertions(+), 222 deletions(-) diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/EnableFeignClients.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/EnableFeignClients.java index ee81a204..dfed4f63 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/EnableFeignClients.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/EnableFeignClients.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ public @interface EnableFeignClients { /** * List of classes annotated with @FeignClient. If not empty, disables classpath scanning. - * @return + * @return list of FeignClient classes */ Class[] clients() default {}; } diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/HystrixTargeter.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/HystrixTargeter.java index c2a488f5..6512f904 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/HystrixTargeter.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/HystrixTargeter.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2016 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,8 +17,6 @@ package org.springframework.cloud.openfeign; -import org.springframework.util.Assert; - import feign.Feign; import feign.Target; import feign.hystrix.FallbackFactory; diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/FeignLoadBalancer.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/FeignLoadBalancer.java index 928b4157..cbffd228 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/FeignLoadBalancer.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/FeignLoadBalancer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,6 @@ package org.springframework.cloud.openfeign.ribbon; -import feign.Client; -import feign.Request; -import feign.Response; - import java.io.IOException; import java.net.URI; import java.util.ArrayList; @@ -29,11 +25,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.springframework.cloud.netflix.ribbon.RibbonProperties; -import org.springframework.cloud.netflix.ribbon.ServerIntrospector; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpRequest; import com.netflix.client.AbstractLoadBalancerAwareClient; import com.netflix.client.ClientException; import com.netflix.client.ClientRequest; @@ -43,6 +34,15 @@ import com.netflix.client.RetryHandler; import com.netflix.client.config.IClientConfig; import com.netflix.loadbalancer.ILoadBalancer; import com.netflix.loadbalancer.Server; +import feign.Client; +import feign.Request; +import feign.Response; + +import org.springframework.cloud.netflix.ribbon.RibbonProperties; +import org.springframework.cloud.netflix.ribbon.ServerIntrospector; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpRequest; import static org.springframework.cloud.netflix.ribbon.RibbonUtils.updateToSecureConnectionIfNeeded; @@ -51,6 +51,7 @@ import static org.springframework.cloud.netflix.ribbon.RibbonUtils.updateToSecur * @author Spencer Gibb * @author Ryan Baxter * @author Tim Ysewyn + * @author Olga Maciaszek-Sharma */ public class FeignLoadBalancer extends AbstractLoadBalancerAwareClient { @@ -97,7 +98,7 @@ public class FeignLoadBalancer extends return new RequestSpecificRetryHandler(true, true, this.getRetryHandler(), requestConfig); } - if (!request.toRequest().method().equals("GET")) { + if (!request.toRequest().httpMethod().name().equals("GET")) { return new RequestSpecificRetryHandler(true, false, this.getRetryHandler(), requestConfig); } @@ -127,7 +128,8 @@ public class FeignLoadBalancer extends private Request toRequest(Request request) { Map> headers = new LinkedHashMap<>( request.headers()); - return Request.create(request.method(),getUri().toASCIIString(),headers,request.body(),request.charset()); + return Request.create(request.httpMethod(), getUri().toASCIIString(), headers, + request.requestBody()); } Request toRequest() { @@ -142,7 +144,8 @@ public class FeignLoadBalancer extends return new HttpRequest() { @Override public HttpMethod getMethod() { - return HttpMethod.resolve(RibbonRequest.this.toRequest().method()); + return HttpMethod + .resolve(RibbonRequest.this.toRequest().httpMethod().name()); } @Override diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/LoadBalancerFeignClient.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/LoadBalancerFeignClient.java index 4e210323..750bb62a 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/LoadBalancerFeignClient.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/LoadBalancerFeignClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,8 @@ import feign.Client; import feign.Request; import feign.Response; +import org.springframework.cloud.netflix.ribbon.SpringClientFactory; + /** * @author Dave Syer * diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/RibbonResponseStatusCodeException.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/RibbonResponseStatusCodeException.java index 473c7886..d0025861 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/RibbonResponseStatusCodeException.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/RibbonResponseStatusCodeException.java @@ -15,13 +15,12 @@ */ package org.springframework.cloud.openfeign.ribbon; +import java.io.ByteArrayInputStream; +import java.net.URI; + import feign.Response; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.net.URI; import org.springframework.cloud.client.loadbalancer.RetryableStatusCodeException; -import org.springframework.util.StreamUtils; /** * A {@link RetryableStatusCodeException} for {@link Response}s diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java index cd2f4745..20a214e9 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,11 @@ import java.util.Map; import org.springframework.http.HttpHeaders; +import static java.util.Optional.ofNullable; + /** * @author Spencer Gibb + * @author Olga Maciaszek-Sharma */ public class FeignUtils { @@ -47,4 +50,11 @@ public class FeignUtils { return headers; } + static Collection addTemplateParameter(Collection possiblyNull, + String paramName) { + Collection params = ofNullable(possiblyNull).orElse(new ArrayList<>()); + params.add(String.format("{%s}", paramName)); + return params; + } + } diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringEncoder.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringEncoder.java index fa4508ab..26f9ae0e 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringEncoder.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +26,14 @@ import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Objects; +import feign.Request; +import feign.RequestTemplate; +import feign.codec.EncodeException; +import feign.codec.Encoder; +import feign.form.spring.SpringFormEncoder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.ObjectFactory; import org.springframework.boot.autoconfigure.http.HttpMessageConverters; import org.springframework.http.HttpHeaders; @@ -38,11 +44,6 @@ import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter; import org.springframework.web.multipart.MultipartFile; -import feign.RequestTemplate; -import feign.codec.EncodeException; -import feign.codec.Encoder; -import feign.form.spring.SpringFormEncoder; - import static org.springframework.cloud.openfeign.support.FeignUtils.getHeaders; import static org.springframework.cloud.openfeign.support.FeignUtils.getHttpHeaders; @@ -129,7 +130,8 @@ public class SpringEncoder implements Encoder { } else { charset = StandardCharsets.UTF_8; } - request.body(outputMessage.getOutputStream().toByteArray(), charset); + request.body(Request.Body.encoded(outputMessage.getOutputStream() + .toByteArray(), charset)); return; } } diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java index 67500944..8f74232b 100644 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java +++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java @@ -29,6 +29,12 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import feign.Contract; +import feign.Feign; +import feign.MethodMetadata; +import feign.Param; +import feign.Request; + import org.springframework.cloud.openfeign.AnnotatedParameterProcessor; import org.springframework.cloud.openfeign.annotation.PathVariableParameterProcessor; import org.springframework.cloud.openfeign.annotation.QueryMapParameterProcessor; @@ -52,18 +58,15 @@ import org.springframework.web.bind.annotation.RequestMethod; import static feign.Util.checkState; import static feign.Util.emptyToNull; +import static org.springframework.cloud.openfeign.support.FeignUtils.addTemplateParameter; import static org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotation; -import feign.Contract; -import feign.Feign; -import feign.MethodMetadata; -import feign.Param; - /** * @author Spencer Gibb * @author Abhijit Sarkar * @author Halvdan Hoem Grelland * @author Aram Peres + * @author Olga Maciaszek-Sharma */ public class SpringMvcContract extends Contract.BaseContract implements ResourceLoaderAware { @@ -132,7 +135,7 @@ public class SpringMvcContract extends Contract.BaseContract if (!pathValue.startsWith("/")) { pathValue = "/" + pathValue; } - data.template().insert(0, pathValue); + data.template().uri(pathValue); } } } @@ -178,7 +181,7 @@ public class SpringMvcContract extends Contract.BaseContract methods = new RequestMethod[] { RequestMethod.GET }; } checkOne(method, methods, "method"); - data.template().method(methods[0].name()); + data.template().method(Request.HttpMethod.valueOf(methods[0].name())); // path checkAtMostOne(method, methodMapping.value(), "value"); @@ -188,10 +191,10 @@ public class SpringMvcContract extends Contract.BaseContract pathValue = resolve(pathValue); // Append path from @RequestMapping if value is present on method if (!pathValue.startsWith("/") - && !data.template().toString().endsWith("/")) { + && !data.template().path().endsWith("/")) { pathValue = "/" + pathValue; } - data.template().append(pathValue); + data.template().uri(pathValue, true); } } @@ -395,7 +398,7 @@ public class SpringMvcContract extends Contract.BaseContract @Override public Collection setTemplateParameter(String name, Collection rest) { - return addTemplatedParam(rest, name); + return addTemplateParameter(rest, name); } } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingPropertiesTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingPropertiesTests.java index 62125528..6eca2eaa 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingPropertiesTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingPropertiesTests.java @@ -16,6 +16,13 @@ package org.springframework.cloud.openfeign; +import java.lang.reflect.Type; +import java.util.Collections; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import feign.Request; import feign.RequestInterceptor; import feign.RequestTemplate; import feign.RetryableException; @@ -25,6 +32,7 @@ import feign.codec.Encoder; import feign.codec.ErrorDecoder; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -43,11 +51,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; -import java.lang.reflect.Type; -import java.util.Collections; -import java.util.Map; - +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -214,7 +218,7 @@ public class FeignClientUsingPropertiesTests { }); requestTemplate.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); - requestTemplate.body(builder.toString()); + requestTemplate.body(Request.Body.bodyTemplate(builder.toString(), UTF_8)); } } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufNotInClasspathTest.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufNotInClasspathTest.java index 6eb0bfee..18930ea4 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufNotInClasspathTest.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufNotInClasspathTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.cloud.openfeign.encoding.proto; import feign.RequestTemplate; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.BeansException; import org.springframework.beans.factory.ObjectFactory; import org.springframework.boot.autoconfigure.http.HttpMessageConverters; @@ -27,6 +28,8 @@ import org.springframework.cloud.test.ClassPathExclusions; import org.springframework.cloud.test.ModifiedClassPathRunner; import org.springframework.http.converter.StringHttpMessageConverter; +import static feign.Request.HttpMethod.POST; + /** * Test {@link SpringEncoder} when protobuf is not in classpath * @@ -45,7 +48,7 @@ public class ProtobufNotInClasspathTest { } }; RequestTemplate requestTemplate = new RequestTemplate(); - requestTemplate.method("POST"); + requestTemplate.method(POST); new SpringEncoder(converters).encode("a=b", String.class, requestTemplate); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufSpringEncoderTest.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufSpringEncoderTest.java index 51066cda..2a9ca95a 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufSpringEncoderTest.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufSpringEncoderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,14 @@ package org.springframework.cloud.openfeign.encoding.proto; +import java.io.IOException; +import java.io.InputStream; +import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + import com.google.protobuf.InvalidProtocolBufferException; import feign.RequestTemplate; import feign.httpclient.ApacheHttpClient; @@ -30,24 +38,21 @@ import org.apache.http.message.BasicStatusLine; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentMatchers; import org.mockito.BDDMockito; -import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.mockito.stubbing.Answer; + import org.springframework.beans.BeansException; import org.springframework.beans.factory.ObjectFactory; import org.springframework.boot.autoconfigure.http.HttpMessageConverters; import org.springframework.cloud.openfeign.support.SpringEncoder; import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter; -import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; +import static feign.Request.Body.encoded; +import static feign.Request.HttpMethod.POST; /** * Test {@link SpringEncoder} with {@link ProtobufHttpMessageConverter} @@ -86,7 +91,9 @@ public class ProtobufSpringEncoderTest { RequestTemplate requestTemplate = newRequestTemplate(); newEncoder().encode(request, Request.class, requestTemplate); // set a charset - requestTemplate.body(requestTemplate.body(), StandardCharsets.UTF_8); + requestTemplate + .body(encoded(requestTemplate.requestBody() + .asBytes(), StandardCharsets.UTF_8)); HttpEntity entity = toApacheHttpEntity(requestTemplate); byte[] bytes = read(entity.getContent(), (int) entity.getContentLength()); @@ -112,20 +119,22 @@ public class ProtobufSpringEncoderTest { private RequestTemplate newRequestTemplate() { RequestTemplate requestTemplate = new RequestTemplate(); - requestTemplate.method("POST"); + requestTemplate.method(POST); return requestTemplate; } private HttpEntity toApacheHttpEntity(RequestTemplate requestTemplate) throws IOException, URISyntaxException { final List request = new ArrayList<>(1); - BDDMockito.given(httpClient.execute(Matchers.any())).will(new Answer() { + BDDMockito.given(httpClient.execute(ArgumentMatchers.any())) + .will(new Answer() { @Override public HttpResponse answer(InvocationOnMock invocationOnMock) throws Throwable { request.add((HttpUriRequest) invocationOnMock.getArguments()[0]); return new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("http", 1, 1), 200, null)); } }); - new ApacheHttpClient(httpClient).execute(requestTemplate.request(), new feign.Request.Options()); + new ApacheHttpClient(httpClient).execute(requestTemplate.resolve(new HashMap<>()) + .request(), new feign.Request.Options()); HttpUriRequest httpUriRequest = request.get(0); return ((HttpEntityEnclosingRequestBase)httpUriRequest).getEntity(); } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hystrix/security/HystrixSecurityTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hystrix/security/HystrixSecurityTests.java index 4d41dff8..e3f8fd5f 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hystrix/security/HystrixSecurityTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hystrix/security/HystrixSecurityTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2016 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,12 +16,15 @@ package org.springframework.cloud.openfeign.hystrix.security; +import java.util.Base64; + import com.netflix.hystrix.strategy.HystrixPlugins; import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy; import com.netflix.loadbalancer.Server; import com.netflix.loadbalancer.ServerList; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.test.context.SpringBootTest; @@ -31,9 +34,7 @@ import org.springframework.cloud.netflix.hystrix.security.SecurityContextConcurr import org.springframework.cloud.netflix.ribbon.RibbonClient; import org.springframework.cloud.netflix.ribbon.StaticServerList; import org.springframework.cloud.openfeign.hystrix.security.app.CustomConcurrenyStrategy; -import org.springframework.cloud.openfeign.valid.FeignClientTests; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -45,8 +46,6 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.client.RestTemplate; -import java.util.Base64; - import static org.assertj.core.api.Assertions.assertThat; /** diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hystrix/security/app/TestInterceptor.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hystrix/security/app/TestInterceptor.java index ff45c207..1a5dae00 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hystrix/security/app/TestInterceptor.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hystrix/security/app/TestInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2016 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import feign.RequestInterceptor; import feign.RequestTemplate; import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Component; /** * This interceptor should be called from an Hyxtrix command execution thread. It is diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/FeignLoadBalancerTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/FeignLoadBalancerTests.java index 7576e186..2a285f49 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/FeignLoadBalancerTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/FeignLoadBalancerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,33 +18,31 @@ package org.springframework.cloud.openfeign.ribbon; import java.net.URI; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import com.netflix.client.config.IClientConfig; import com.netflix.loadbalancer.BaseLoadBalancer; +import com.netflix.loadbalancer.ILoadBalancer; import com.netflix.loadbalancer.RoundRobinRule; +import com.netflix.loadbalancer.Server; import com.netflix.loadbalancer.reactive.LoadBalancerCommand; +import feign.Client; +import feign.Request; +import feign.Request.Options; +import feign.RequestTemplate; +import feign.Response; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.springframework.cloud.openfeign.ribbon.FeignLoadBalancer.RibbonRequest; -import org.springframework.cloud.openfeign.ribbon.FeignLoadBalancer.RibbonResponse; + import org.springframework.cloud.netflix.ribbon.DefaultServerIntrospector; import org.springframework.cloud.netflix.ribbon.ServerIntrospector; - -import com.netflix.client.config.IClientConfig; -import com.netflix.loadbalancer.ILoadBalancer; -import com.netflix.loadbalancer.Server; - -import feign.Client; -import feign.Request; -import feign.RequestTemplate; -import feign.Response; -import feign.Request.Options; +import org.springframework.cloud.openfeign.ribbon.FeignLoadBalancer.RibbonRequest; +import org.springframework.cloud.openfeign.ribbon.FeignLoadBalancer.RibbonResponse; import static com.netflix.client.config.CommonClientConfigKey.ConnectTimeout; import static com.netflix.client.config.CommonClientConfigKey.IsSecure; @@ -54,11 +52,12 @@ import static com.netflix.client.config.CommonClientConfigKey.OkToRetryOnAllOper import static com.netflix.client.config.CommonClientConfigKey.ReadTimeout; import static com.netflix.client.config.DefaultClientConfigImpl.DEFAULT_MAX_AUTO_RETRIES; import static com.netflix.client.config.DefaultClientConfigImpl.DEFAULT_MAX_AUTO_RETRIES_NEXT_SERVER; +import static feign.Request.HttpMethod.GET; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; public class FeignLoadBalancerTests { @@ -96,19 +95,27 @@ public class FeignLoadBalancerTests { this.feignLoadBalancer = new FeignLoadBalancer(this.lb, this.config, this.inspector); - Request request = new RequestTemplate().method("GET").append("http://foo/") + Request request = new RequestTemplate() + .method(GET) + .target("http://foo/") + .resolve(new HashMap<>()) .request(); RibbonRequest ribbonRequest = new RibbonRequest(this.delegate, request, new URI(request.url())); - Response response = Response.create(200, "Test", - Collections.> emptyMap(), new byte[0]); + Response response = Response.builder() + .request(request) + .status(200) + .reason("Test") + .headers(Collections.emptyMap()) + .body(new byte[0]) + .build(); when(this.delegate.execute(any(Request.class), any(Options.class))) .thenReturn(response); RibbonResponse resp = this.feignLoadBalancer.execute(ribbonRequest, null); - assertThat(resp.getRequestedURI(), is(new URI("http://foo/"))); + assertThat(resp.getRequestedURI(), is(new URI("http://foo"))); } @Test @@ -159,7 +166,7 @@ public class FeignLoadBalancerTests { @Test public void testRibbonRequestURLEncode() throws Exception { String url = "http://foo/?name=%7bcookie";//name={cookie - Request request = Request.create("GET",url,new HashMap(),null,null); + Request request = Request.create(GET, url, new HashMap<>(), null, null); assertThat(request.url(),is(url)); @@ -191,11 +198,15 @@ public class FeignLoadBalancerTests { builder.withServerLocator(request.getRequest().headers().get("c_ip")); } }; - Request request = new RequestTemplate().method("GET").request(); + Request request = new RequestTemplate().method(GET).resolve(new HashMap<>()).request(); RibbonResponse resp = this.feignLoadBalancer.executeWithLoadBalancer(new RibbonRequest(this.delegate, request, new URI(request.url())), null); assertThat(resp.getRequestedURI().getPort(), is(7777)); - request = new RequestTemplate().method("GET").header("c_ip", "666").request(); + request = new RequestTemplate() + .method(GET) + .header("c_ip", "666") + .resolve(new HashMap<>()) + .request(); resp = this.feignLoadBalancer.executeWithLoadBalancer(new RibbonRequest(this.delegate, request, new URI(request.url())), null); assertThat(resp.getRequestedURI().getPort(), is(6666)); diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/FeignRibbonClientPathTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/FeignRibbonClientPathTests.java index 6568965e..b3d57fcc 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/FeignRibbonClientPathTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/FeignRibbonClientPathTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,21 +16,20 @@ package org.springframework.cloud.openfeign.ribbon; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - +import com.netflix.loadbalancer.Server; +import com.netflix.loadbalancer.ServerList; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.cloud.netflix.ribbon.RibbonClients; +import org.springframework.cloud.netflix.ribbon.StaticServerList; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.netflix.ribbon.RibbonClient; -import org.springframework.cloud.netflix.ribbon.StaticServerList; import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -41,8 +40,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import com.netflix.loadbalancer.Server; -import com.netflix.loadbalancer.ServerList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * @author Venil Noronha diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/FeignRibbonClientTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/FeignRibbonClientTests.java index ab7fc108..f7b7c167 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/FeignRibbonClientTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/FeignRibbonClientTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package org.springframework.cloud.openfeign.ribbon; +import java.util.HashMap; + import com.netflix.client.config.CommonClientConfigKey; import com.netflix.client.config.DefaultClientConfigImpl; import com.netflix.client.config.IClientConfig; @@ -31,11 +33,13 @@ import feign.RequestTemplate; import org.hamcrest.CustomMatcher; import org.junit.Before; import org.junit.Test; + import org.springframework.cloud.netflix.ribbon.DefaultServerIntrospector; import org.springframework.cloud.netflix.ribbon.ServerIntrospector; import org.springframework.cloud.netflix.ribbon.SpringClientFactory; -import static org.mockito.Matchers.any; +import static feign.Request.HttpMethod.GET; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -91,7 +95,10 @@ public class FeignRibbonClientTests { @Test public void remoteRequestIsSentAtRoot() throws Exception { - Request request = new RequestTemplate().method("GET").append("http://foo") + Request request = new RequestTemplate() + .method(GET) + .target("http://foo") + .resolve(new HashMap<>()) .request(); this.client.execute(request, new Options()); RequestMatcher matcher = new RequestMatcher("http://foo.com:8000/"); @@ -101,7 +108,10 @@ public class FeignRibbonClientTests { @Test public void remoteRequestIsSent() throws Exception { - Request request = new RequestTemplate().method("GET").append("http://foo/") + Request request = new RequestTemplate() + .method(GET) + .target("http://foo/") + .resolve(new HashMap<>()) .request(); this.client.execute(request, new Options()); RequestMatcher matcher = new RequestMatcher("http://foo.com:8000/"); @@ -111,7 +121,10 @@ public class FeignRibbonClientTests { @Test public void remoteRequestIsSecure() throws Exception { - Request request = new RequestTemplate().method("GET").append("https://foo/") + Request request = new RequestTemplate() + .method(GET) + .target("https://foo/") + .resolve(new HashMap<>()) .request(); this.client.execute(request, new Options()); RequestMatcher matcher = new RequestMatcher("https://foo.com:8000/"); diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/RetryableFeignLoadBalancerTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/RetryableFeignLoadBalancerTests.java index b4fd8afc..32b3add0 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/RetryableFeignLoadBalancerTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/RetryableFeignLoadBalancerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,25 +17,31 @@ package org.springframework.cloud.openfeign.ribbon; -import feign.Client; -import feign.Request; -import feign.Response; - import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.URI; -import java.nio.charset.StandardCharsets; -import java.util.Collection; +import java.nio.charset.Charset; import java.util.HashMap; import java.util.List; + +import com.netflix.client.DefaultLoadBalancerRetryHandler; +import com.netflix.client.RequestSpecificRetryHandler; +import com.netflix.client.config.CommonClientConfigKey; +import com.netflix.client.config.IClientConfig; +import com.netflix.loadbalancer.ILoadBalancer; +import com.netflix.loadbalancer.Server; +import feign.Client; +import feign.Request; +import feign.Response; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; + import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory; import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryPolicy; @@ -46,7 +52,6 @@ import org.springframework.cloud.netflix.ribbon.RibbonLoadBalancedRetryPolicy; import org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerContext; import org.springframework.cloud.netflix.ribbon.ServerIntrospector; import org.springframework.cloud.netflix.ribbon.SpringClientFactory; -import org.springframework.http.HttpRequest; import org.springframework.retry.RetryCallback; import org.springframework.retry.RetryContext; import org.springframework.retry.RetryListener; @@ -55,13 +60,6 @@ import org.springframework.retry.backoff.BackOffContext; import org.springframework.retry.backoff.BackOffInterruptedException; import org.springframework.retry.backoff.BackOffPolicy; -import com.netflix.client.DefaultLoadBalancerRetryHandler; -import com.netflix.client.RequestSpecificRetryHandler; -import com.netflix.client.config.CommonClientConfigKey; -import com.netflix.client.config.IClientConfig; -import com.netflix.loadbalancer.ILoadBalancer; -import com.netflix.loadbalancer.Server; - import static com.netflix.client.config.CommonClientConfigKey.ConnectTimeout; import static com.netflix.client.config.CommonClientConfigKey.MaxAutoRetries; import static com.netflix.client.config.CommonClientConfigKey.MaxAutoRetriesNextServer; @@ -69,15 +67,16 @@ import static com.netflix.client.config.CommonClientConfigKey.OkToRetryOnAllOper import static com.netflix.client.config.CommonClientConfigKey.ReadTimeout; import static com.netflix.client.config.DefaultClientConfigImpl.DEFAULT_MAX_AUTO_RETRIES; import static com.netflix.client.config.DefaultClientConfigImpl.DEFAULT_MAX_AUTO_RETRIES_NEXT_SERVER; +import static feign.Request.HttpMethod.GET; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; @@ -88,6 +87,7 @@ import static org.mockito.Mockito.when; /** * @author Ryan Baxter * @author Gang Li + * @author Olga Maciaszek-Sharma */ public class RetryableFeignLoadBalancerTests { @Mock @@ -126,12 +126,15 @@ public class RetryableFeignLoadBalancerTests { doReturn("404,502,foo, ,").when(config).getPropertyAsString(eq(RibbonLoadBalancedRetryPolicy.RETRYABLE_STATUS_CODES),eq("")); doReturn(config).when(clientFactory).getClientConfig(eq("default")); RibbonLoadBalancedRetryFactory loadBalancedRetryFactory = new RibbonLoadBalancedRetryFactory(clientFactory); - HttpRequest springRequest = mock(HttpRequest.class); - Request feignRequest = Request.create("GET", "http://foo", new HashMap>(), - new byte[]{}, StandardCharsets.UTF_8); + Request feignRequest = Request.create(GET, "http://foo", new HashMap<>(), + new byte[] {}, UTF_8); Client client = mock(Client.class); FeignLoadBalancer.RibbonRequest request = new FeignLoadBalancer.RibbonRequest(client, feignRequest, new URI("http://foo")); - Response response = Response.builder().status(200).headers(new HashMap>()).build(); + Response response = Response.builder() + .status(200) + .request(feignRequest) + .headers(new HashMap<>()) + .build(); doReturn(response).when(client).execute(any(Request.class), any(Request.Options.class)); RetryableFeignLoadBalancer feignLb = new RetryableFeignLoadBalancer(lb, config, inspector, loadBalancedRetryFactory); FeignLoadBalancer.RibbonResponse ribbonResponse = feignLb.execute(request, null); @@ -141,9 +144,8 @@ public class RetryableFeignLoadBalancerTests { @Test public void executeNeverRetry() throws Exception { - HttpRequest springRequest = mock(HttpRequest.class); - Request feignRequest = Request.create("GET", "http://foo", new HashMap>(), - new byte[]{}, StandardCharsets.UTF_8); + Request feignRequest = Request.create(GET, "http://foo", new HashMap<>(), + new byte[] {}, UTF_8); Client client = mock(Client.class); FeignLoadBalancer.RibbonRequest request = new FeignLoadBalancer.RibbonRequest(client, feignRequest, new URI("http://foo")); doThrow(new IOException("boom")).when(client).execute(any(Request.class), any(Request.Options.class)); @@ -192,12 +194,15 @@ public class RetryableFeignLoadBalancerTests { return backOffPolicy; } }; - HttpRequest springRequest = mock(HttpRequest.class); - Request feignRequest = Request.create("GET", "http://foo", new HashMap>(), - new byte[]{}, StandardCharsets.UTF_8); + Request feignRequest = Request.create(GET, "http://foo", new HashMap<>(), + new byte[] {}, UTF_8); Client client = mock(Client.class); FeignLoadBalancer.RibbonRequest request = new FeignLoadBalancer.RibbonRequest(client, feignRequest, new URI("http://foo")); - Response response = Response.builder().status(200).headers(new HashMap>()).build(); + Response response = Response.builder() + .status(200) + .request(feignRequest) + .headers(new HashMap<>()) + .build(); doThrow(new IOException("boom")).doReturn(response).when(client).execute(any(Request.class), any(Request.Options.class)); RetryableFeignLoadBalancer feignLb = new RetryableFeignLoadBalancer(lb, config, inspector, loadBalancedRetryFactory); @@ -227,13 +232,20 @@ public class RetryableFeignLoadBalancerTests { return backOffPolicy; } }; - HttpRequest springRequest = mock(HttpRequest.class); - Request feignRequest = Request.create("GET", "http://foo", new HashMap>(), - new byte[]{}, StandardCharsets.UTF_8); + Request feignRequest = Request.create(GET, "http://foo", new HashMap<>(), + new byte[] {}, UTF_8); Client client = mock(Client.class); FeignLoadBalancer.RibbonRequest request = new FeignLoadBalancer.RibbonRequest(client, feignRequest, new URI("http://foo")); - Response response = Response.builder().status(200).headers(new HashMap>()).build(); - Response fourOFourResponse = Response.builder().status(404).headers(new HashMap>()).build(); + Response response = Response + .builder() + .request(feignRequest) + .status(200) + .headers(new HashMap<>()) + .build(); + Response fourOFourResponse = Response.builder() + .request(feignRequest) + .status(404) + .headers(new HashMap<>()).build(); doReturn(fourOFourResponse).doReturn(response).when(client).execute(any(Request.class), any(Request.Options.class)); RetryableFeignLoadBalancer feignLb = new RetryableFeignLoadBalancer(lb, config, inspector, loadBalancedRetryFactory); FeignLoadBalancer.RibbonResponse ribbonResponse = feignLb.execute(request, null); @@ -247,7 +259,7 @@ public class RetryableFeignLoadBalancerTests { int retriesNextServer = 0; when(this.config.get(MaxAutoRetriesNextServer, DEFAULT_MAX_AUTO_RETRIES_NEXT_SERVER)).thenReturn(retriesNextServer); - doReturn(new Server("foo", 80)).when(lb).chooseServer(anyObject()); + doReturn(new Server("foo", 80)).when(lb).chooseServer(any()); RibbonLoadBalancerContext lbContext = new RibbonLoadBalancerContext(lb, config); SpringClientFactory clientFactory = mock(SpringClientFactory.class); IClientConfig config = mock(IClientConfig.class); @@ -266,18 +278,25 @@ public class RetryableFeignLoadBalancerTests { return backOffPolicy; } }; - HttpRequest springRequest = mock(HttpRequest.class); - Request feignRequest = Request.create("GET", "http://foo", new HashMap>(), - new byte[]{}, StandardCharsets.UTF_8); + Request feignRequest = Request.create(GET, "http://foo", new HashMap<>(), + new byte[] {}, UTF_8); Client client = mock(Client.class); FeignLoadBalancer.RibbonRequest request = new FeignLoadBalancer.RibbonRequest(client, feignRequest, new URI("http://foo")); - Response response = Response.builder().status(404).headers(new HashMap>()).build(); - Response fourOFourResponse = Response.builder().status(404).headers(new HashMap>()).build(); + Response response = Response.builder() + .request(feignRequest) + .status(404) + .headers(new HashMap<>()) + .build(); + Response fourOFourResponse = Response.builder() + .request(feignRequest) + .status(404) + .headers(new HashMap<>()) + .build(); doReturn(fourOFourResponse).doReturn(response).when(client).execute(any(Request.class), any(Request.Options.class)); RetryableFeignLoadBalancer feignLb = new RetryableFeignLoadBalancer(lb, config, inspector, loadBalancedRetryFactory); FeignLoadBalancer.RibbonResponse ribbonResponse = feignLb.execute(request, null); assertEquals(404, ribbonResponse.toResponse().status()); - assertEquals(new Integer(0), ribbonResponse.toResponse().body().length()); + assertEquals(Integer.valueOf(0), ribbonResponse.toResponse().body().length()); verify(client, times(2)).execute(any(Request.class), any(Request.Options.class)); assertEquals(1, backOffPolicy.getCount()); } @@ -288,12 +307,15 @@ public class RetryableFeignLoadBalancerTests { SpringClientFactory clientFactory = mock(SpringClientFactory.class); doReturn(lbContext).when(clientFactory).getLoadBalancerContext(any(String.class)); RibbonLoadBalancedRetryFactory loadBalancedRetryFactory = new RibbonLoadBalancedRetryFactory(clientFactory); - HttpRequest springRequest = mock(HttpRequest.class); - Request feignRequest = Request.create("GET", "http://foo", new HashMap>(), - new byte[]{}, StandardCharsets.UTF_8); + Request feignRequest = Request.create(GET, "http://foo", new HashMap<>(), + new byte[] {}, UTF_8); Client client = mock(Client.class); FeignLoadBalancer.RibbonRequest request = new FeignLoadBalancer.RibbonRequest(client, feignRequest, new URI("http://foo")); - Response response = Response.builder().status(200).headers(new HashMap>()).build(); + Response response = Response.builder() + .request(feignRequest) + .status(200) + .headers(new HashMap<>()) + .build(); doReturn(response).when(client).execute(any(Request.class), any(Request.Options.class)); RetryableFeignLoadBalancer feignLb = new RetryableFeignLoadBalancer(lb, config, inspector, loadBalancedRetryFactory); RequestSpecificRetryHandler retryHandler = feignLb.getRequestSpecificRetryHandler(request, config); @@ -308,12 +330,15 @@ public class RetryableFeignLoadBalancerTests { SpringClientFactory clientFactory = mock(SpringClientFactory.class); doReturn(lbContext).when(clientFactory).getLoadBalancerContext(any(String.class)); RibbonLoadBalancedRetryFactory loadBalancedRetryFactory = new RibbonLoadBalancedRetryFactory(clientFactory); - HttpRequest springRequest = mock(HttpRequest.class); - Request feignRequest = Request.create("GET", "http://foo", new HashMap>(), - new byte[]{}, StandardCharsets.UTF_8); + Request feignRequest = Request + .create(GET, "http://foo", new HashMap<>(), + new byte[] {}, UTF_8); Client client = mock(Client.class); FeignLoadBalancer.RibbonRequest request = new FeignLoadBalancer.RibbonRequest(client, feignRequest, new URI("http://foo")); - Response response = Response.builder().status(200).headers(new HashMap>()).build(); + Response response = Response.builder() + .request(feignRequest) + .status(200).headers(new HashMap<>()) + .build(); doReturn(response).when(client).execute(any(Request.class), any(Request.Options.class)); final Server server = new Server("foo", 80); RetryableFeignLoadBalancer feignLb = new RetryableFeignLoadBalancer(new ILoadBalancer() { @@ -379,12 +404,15 @@ public class RetryableFeignLoadBalancerTests { return backOffPolicy; } }; - HttpRequest springRequest = mock(HttpRequest.class); - Request feignRequest = Request.create("GET", "http://listener", new HashMap>(), - new byte[]{}, StandardCharsets.UTF_8); + Request feignRequest = Request.create(GET, "http://listener", new HashMap<>(), + new byte[] {}, UTF_8); Client client = mock(Client.class); FeignLoadBalancer.RibbonRequest request = new FeignLoadBalancer.RibbonRequest(client, feignRequest, new URI("http://listener")); - Response response = Response.builder().status(200).headers(new HashMap>()).build(); + Response response = Response.builder() + .request(feignRequest) + .status(200) + .headers(new HashMap<>()) + .build(); doThrow(new IOException("boom")).doReturn(response).when(client).execute(any(Request.class), any(Request.Options.class)); RetryableFeignLoadBalancer feignLb = new RetryableFeignLoadBalancer(lb, config, inspector, loadBalancedRetryFactory); @@ -408,7 +436,6 @@ public class RetryableFeignLoadBalancerTests { doReturn("").when(config).getPropertyAsString(eq(RibbonLoadBalancedRetryPolicy.RETRYABLE_STATUS_CODES),eq("")); doReturn(config).when(clientFactory).getClientConfig(eq("default")); doReturn(lbContext).when(clientFactory).getLoadBalancerContext(any(String.class)); - Response response = Response.builder().status(200).headers(new HashMap>()).build(); MyBackOffPolicy backOffPolicy = new MyBackOffPolicy(); MyRetryListenerNotRetry myRetryListenerNotRetry = new MyRetryListenerNotRetry(); RibbonLoadBalancedRetryFactory loadBalancedRetryFactory = new RibbonLoadBalancedRetryFactory(clientFactory){ @@ -422,9 +449,8 @@ public class RetryableFeignLoadBalancerTests { return backOffPolicy; } }; - HttpRequest springRequest = mock(HttpRequest.class); - Request feignRequest = Request.create("GET", "http://listener", new HashMap>(), - new byte[]{}, StandardCharsets.UTF_8); + Request feignRequest = Request.create(GET, "http://listener", new HashMap<>(), + new byte[] {}, UTF_8); Client client = mock(Client.class); FeignLoadBalancer.RibbonRequest request = new FeignLoadBalancer.RibbonRequest(client, feignRequest, new URI("http://listener")); RetryableFeignLoadBalancer feignLb = new RetryableFeignLoadBalancer(lb, config, inspector, loadBalancedRetryFactory); @@ -451,12 +477,15 @@ public class RetryableFeignLoadBalancerTests { return backOffPolicy; } }; - HttpRequest springRequest = mock(HttpRequest.class); - Request feignRequest = Request.create("GET", "http://listener", new HashMap>(), - new byte[]{}, StandardCharsets.UTF_8); + Request feignRequest = Request.create(GET, "http://listener", new HashMap<>(), + new byte[] {}, UTF_8); Client client = mock(Client.class); FeignLoadBalancer.RibbonRequest request = new FeignLoadBalancer.RibbonRequest(client, feignRequest, new URI("http://listener")); - Response response = Response.builder().status(200).headers(new HashMap>()).build(); + Response response = Response.builder() + .request(feignRequest) + .status(200) + .headers(new HashMap<>()) + .build(); doThrow(new IOException("boom")).doReturn(response).when(client).execute(any(Request.class), any(Request.Options.class)); RetryableFeignLoadBalancer feignLb = new RetryableFeignLoadBalancer(lb, config, inspector, loadBalancedRetryPolicyFactory); FeignLoadBalancer.RibbonResponse ribbonResponse = feignLb.execute(request, null); @@ -486,12 +515,14 @@ public class RetryableFeignLoadBalancerTests { return backOffPolicy; } }; - HttpRequest springRequest = mock(HttpRequest.class); - Request feignRequest = Request.create("GET", "http://foo", new HashMap>(), - new byte[]{}, StandardCharsets.UTF_8); + Request feignRequest = Request.create(GET, "http://foo", new HashMap<>(), + new byte[] {}, UTF_8); Client client = mock(Client.class); FeignLoadBalancer.RibbonRequest request = new FeignLoadBalancer.RibbonRequest(client, feignRequest, new URI("http://foo")); - Response fourOFourResponse = Response.builder().status(404).headers(new HashMap>()) + Response fourOFourResponse = Response.builder() + .request(feignRequest) + .status(404) + .headers(new HashMap<>()) .body(new Response.Body() { //set content into response @Override public Integer length() { @@ -510,7 +541,12 @@ public class RetryableFeignLoadBalancerTests { @Override public Reader asReader() throws IOException { - return new InputStreamReader(asInputStream(), "UTF-8"); + return new InputStreamReader(asInputStream(), UTF_8); + } + + @Override + public Reader asReader(Charset charset) throws IOException { + return new InputStreamReader(asInputStream(), charset); } @Override diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/RibbonResponseStatusCodeExceptionTest.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/RibbonResponseStatusCodeExceptionTest.java index 17559294..3b8469d2 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/RibbonResponseStatusCodeExceptionTest.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/ribbon/RibbonResponseStatusCodeExceptionTest.java @@ -15,9 +15,6 @@ */ package org.springframework.cloud.openfeign.ribbon; -import feign.Request; -import feign.Response; - import java.io.ByteArrayInputStream; import java.net.URI; import java.nio.charset.Charset; @@ -26,11 +23,16 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; + +import feign.Request; +import feign.Response; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; + import org.springframework.util.StreamUtils; +import static feign.Request.HttpMethod.GET; import static org.junit.Assert.assertEquals; /** @@ -45,7 +47,7 @@ public class RibbonResponseStatusCodeExceptionTest { List fooValues = new ArrayList(); fooValues.add("bar"); headers.put("foo", fooValues); - Request request = Request.create("GET", "http://service.com", + Request request = Request.create(GET, "http://service.com", new HashMap>(), new byte[]{}, Charset.defaultCharset()); byte[] body = "foo".getBytes(); ByteArrayInputStream is = new ByteArrayInputStream(body); diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringEncoderTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringEncoderTests.java index fcc9b53e..72a595a4 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringEncoderTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringEncoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,10 +21,14 @@ import java.io.IOException; import java.lang.reflect.Type; import java.nio.charset.Charset; import java.util.Collection; +import java.util.List; +import feign.RequestTemplate; +import feign.codec.EncodeException; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentMatcher; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -46,16 +50,18 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; - -import feign.RequestTemplate; -import feign.codec.EncodeException; +import static org.springframework.http.HttpHeaders.CONTENT_TYPE; +import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE; /** * @author Spencer Gibb + * @author Olga Maciaszek-Sharma */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = SpringEncoderTests.Application.class, webEnvironment = WebEnvironment.RANDOM_PORT, value = { @@ -85,8 +91,8 @@ public class SpringEncoderTests { String header = contentTypeHeader.iterator().next(); assertThat("content type header is wrong", header, is("application/mytype")); - assertThat("request charset is null", request.charset(), is(notNullValue())); - assertThat("request charset is wrong", request.charset(), is(Charset.forName("UTF-8"))); + assertThat("request charset is null", request.requestCharset(), is(notNullValue())); + assertThat("request charset is wrong", request.requestCharset(), is(Charset.forName("UTF-8"))); } @Test @@ -97,7 +103,9 @@ public class SpringEncoderTests { encoder.encode("hi".getBytes(), null, request); - assertThat("request charset is not null", request.charset(), is(nullValue())); + assertThat("Request Content-Type is not octet-stream", + ((List) request.headers().get(CONTENT_TYPE)).get(0), + equalTo(APPLICATION_OCTET_STREAM_VALUE)); } @Test(expected = EncodeException.class) @@ -109,7 +117,7 @@ public class SpringEncoderTests { MultipartFile multipartFile = new MockMultipartFile("test_multipart_file", "hi".getBytes()); encoder.encode(multipartFile, MultipartFile.class, request); - assertThat("request charset is not null", request.charset(), is(nullValue())); + assertThat("request charset is not null", request.requestCharset(), is(nullValue())); } @Test @@ -122,7 +130,9 @@ public class SpringEncoderTests { MultipartFile multipartFile = new MockMultipartFile("test_multipart_file", "hi".getBytes()); encoder.encode(multipartFile, MultipartFile.class, request); - assertThat("request charset is not null", request.charset(), is(nullValue())); + assertThat("Request Content-Type is not multipart/form-data", + (String) ((List) request.headers().get(CONTENT_TYPE)).get(0), + containsString(MediaType.MULTIPART_FORM_DATA_VALUE)); } class MediaTypeMatcher implements ArgumentMatcher { @@ -192,10 +202,7 @@ public class SpringEncoderTests { @Override public boolean canWrite(Class clazz, MediaType mediaType) { - if (clazz == String.class) { - return true; - } - return false; + return clazz == String.class; } @Override diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java index 57f511f6..663c9f08 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java @@ -27,6 +27,8 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import feign.MethodMetadata; import feign.Param; import org.junit.Before; import org.junit.Test; @@ -51,13 +53,12 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; -import com.fasterxml.jackson.annotation.JsonAutoDetect; - +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; - -import feign.MethodMetadata; +import static org.springframework.web.util.UriUtils.encode; /** * @author chadjaros @@ -187,7 +188,7 @@ public class SpringMvcContractTests { MethodMetadata data = this.contract .parseAndValidateMetadata(method.getDeclaringClass(), method); - assertEquals("", data.template().url()); + assertEquals("/", data.template().url()); assertEquals("POST", data.template().method()); assertEquals(MediaType.APPLICATION_JSON_VALUE, data.template().headers().get("Accept").iterator().next()); @@ -201,7 +202,7 @@ public class SpringMvcContractTests { MethodMetadata data = this.contract .parseAndValidateMetadata(method.getDeclaringClass(), method); - assertEquals("", data.template().url()); + assertEquals("/", data.template().url()); assertEquals("POST", data.template().method()); assertEquals(MediaType.APPLICATION_JSON_VALUE, data.template().headers().get("Accept").iterator().next()); @@ -215,7 +216,8 @@ public class SpringMvcContractTests { MethodMetadata data = this.contract .parseAndValidateMetadata(method.getDeclaringClass(), method); - assertEquals("/advanced/test/{id}", data.template().url()); + assertEquals("/advanced/test/{id}?amount=" + encode("{amount}", UTF_8), + data.template().url()); assertEquals("PUT", data.template().method()); assertEquals(MediaType.APPLICATION_JSON_VALUE, data.template().headers().get("Accept").iterator().next()); @@ -238,7 +240,8 @@ public class SpringMvcContractTests { MethodMetadata data = this.contract .parseAndValidateMetadata(method.getDeclaringClass(), method); - assertEquals("/advanced/test/{id}", data.template().url()); + assertEquals("/advanced/test/{id}?amount=" + encode("{amount}", UTF_8), + data.template().url()); assertEquals("PUT", data.template().method()); assertEquals(MediaType.APPLICATION_JSON_VALUE, data.template().headers().get("Accept").iterator().next()); @@ -261,7 +264,8 @@ public class SpringMvcContractTests { MethodMetadata data = this.contract .parseAndValidateMetadata(method.getDeclaringClass(), method); - assertEquals("/advanced/test2", data.template().url()); + assertEquals("/advanced/test2?amount=" + encode("{amount}", UTF_8), + data.template().url()); assertEquals("PUT", data.template().method()); assertEquals(MediaType.APPLICATION_JSON_VALUE, data.template().headers().get("Accept").iterator().next()); @@ -334,7 +338,7 @@ public class SpringMvcContractTests { MethodMetadata data = this.contract .parseAndValidateMetadata(method.getDeclaringClass(), method); - assertEquals("", data.template().url()); + assertEquals("/", data.template().url()); assertEquals("GET", data.template().method()); assertEquals(MediaType.APPLICATION_JSON_VALUE, data.template().headers().get("Accept").iterator().next()); @@ -347,7 +351,8 @@ public class SpringMvcContractTests { MethodMetadata data = this.contract .parseAndValidateMetadata(method.getDeclaringClass(), method); - assertEquals("/test", data.template().url()); + assertEquals("/test?id=" + encode("{id}", UTF_8), + data.template().url()); assertEquals("GET", data.template().method()); assertEquals("[{id}]", data.template().queries().get("id").toString()); assertNotNull(data.indexToExpander().get(0)); @@ -360,7 +365,7 @@ public class SpringMvcContractTests { MethodMetadata data = this.contract .parseAndValidateMetadata(method.getDeclaringClass(), method); - assertEquals("/test", data.template().url()); + assertEquals("/test?id=" + encode("{id}", UTF_8), data.template().url()); assertEquals("GET", data.template().method()); assertEquals("[{id}]", data.template().queries().get("id").toString()); assertNotNull(data.indexToExpander().get(0)); @@ -400,7 +405,7 @@ public class SpringMvcContractTests { assertEquals("/test/{id}", data.template().url()); assertEquals("GET", data.template().method()); - assertEquals(true, data.template().headers().isEmpty()); + assertTrue(data.template().headers().isEmpty()); } @Test @@ -413,7 +418,8 @@ public class SpringMvcContractTests { MethodMetadata data = this.contract .parseAndValidateMetadata(method.getDeclaringClass(), method); - assertEquals("/advanced/testfallback/{id}", data.template().url()); + assertEquals("/advanced/testfallback/{id}?amount=" + encode("{amount}", UTF_8), data + .template().url()); assertEquals("PUT", data.template().method()); assertEquals(MediaType.APPLICATION_JSON_VALUE, data.template().headers().get("Accept").iterator().next()); @@ -483,7 +489,8 @@ public class SpringMvcContractTests { MethodMetadata data = this.contract .parseAndValidateMetadata(method.getDeclaringClass(), method); - assertEquals("/queryMap", data.template().url()); + assertEquals("/queryMap?aParam=" + encode("{aParam}", UTF_8), + data.template().url()); assertEquals("GET", data.template().method()); assertEquals(0, data.queryMapIndex().intValue()); Map> params = data.template().queries(); @@ -497,7 +504,8 @@ public class SpringMvcContractTests { MethodMetadata data = this.contract .parseAndValidateMetadata(method.getDeclaringClass(), method); - assertEquals("/queryMapObject", data.template().url()); + assertEquals("/queryMapObject?aParam=" + encode("{aParam}", UTF_8), + data.template().url()); assertEquals("GET", data.template().method()); assertEquals(0, data.queryMapIndex().intValue()); Map> params = data.template().queries(); diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/ApacheHttpClientConfigurationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/ApacheHttpClientConfigurationTests.java index 006fe6e7..ead7604a 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/ApacheHttpClientConfigurationTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/ApacheHttpClientConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,8 @@ import java.io.IOException; import java.lang.reflect.Field; import java.util.concurrent.TimeUnit; +import feign.Client; +import feign.httpclient.ApacheHttpClient; import org.apache.http.Header; import org.apache.http.StatusLine; import org.apache.http.client.HttpClient; @@ -36,6 +38,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.MockingDetails; import org.mockito.Mockito; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -55,14 +58,11 @@ import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockingDetails; -import feign.Client; -import feign.httpclient.ApacheHttpClient; - /** * @author Ryan Baxter */ diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientScanningTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientScanningTests.java index f426a30e..80e6aab0 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientScanningTests.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientScanningTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,18 +16,21 @@ package org.springframework.cloud.openfeign.valid.scanning; +import com.netflix.loadbalancer.Server; +import com.netflix.loadbalancer.ServerList; +import feign.Client; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.cloud.netflix.ribbon.RibbonClients; +import org.springframework.cloud.netflix.ribbon.StaticServerList; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.netflix.ribbon.RibbonClient; -import org.springframework.cloud.netflix.ribbon.StaticServerList; import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -38,11 +41,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import com.netflix.loadbalancer.Server; -import com.netflix.loadbalancer.ServerList; - -import feign.Client; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; diff --git a/spring-cloud-openfeign-dependencies/pom.xml b/spring-cloud-openfeign-dependencies/pom.xml index ded6b0fb..9563f9eb 100644 --- a/spring-cloud-openfeign-dependencies/pom.xml +++ b/spring-cloud-openfeign-dependencies/pom.xml @@ -13,7 +13,7 @@ spring-cloud-openfeign-dependencies Spring Cloud OpenFeign Dependencies - 9.7.0 + 10.1.0 3.3.0