Merge remote-tracking branch 'origin/2.2.x'
# Conflicts: # docs/pom.xml # pom.xml # spring-cloud-openfeign-core/pom.xml # spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientOverrideDefaultsTests.java # spring-cloud-openfeign-dependencies/pom.xml # spring-cloud-starter-openfeign/pom.xml
This commit is contained in:
@@ -561,7 +561,7 @@ If a map is passed as the method argument, the `@MatrixVariable` path segment is
|
||||
If a different object is passed, either the `name` provided in the `@MatrixVariable` annotation (if defined) or the annotated variable name is
|
||||
joined with the provided method argument using `=`.
|
||||
|
||||
IMPORTANT:: Even though, on the server side, Spring does not require the users to name the path segment placeholder same as the matrix variable name, since it would be too ambiguous on the client side, Sprig Cloud OpenFeign requires that you add a path segment placeholder with a name matching either the `name` provided in the `@MatrixVariable` annotation (if defined) or the annotated variable name.
|
||||
IMPORTANT:: Even though, on the server side, Spring does not require the users to name the path segment placeholder same as the matrix variable name, since it would be too ambiguous on the client side, Spring Cloud OpenFeign requires that you add a path segment placeholder with a name matching either the `name` provided in the `@MatrixVariable` annotation (if defined) or the annotated variable name.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import feign.QueryMapEncoder;
|
||||
import feign.Request;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.RequestLine;
|
||||
import feign.RequestTemplate;
|
||||
import feign.Retryer;
|
||||
import feign.auth.BasicAuthRequestInterceptor;
|
||||
import feign.codec.Decoder;
|
||||
@@ -32,8 +31,7 @@ import feign.codec.ErrorDecoder;
|
||||
import feign.optionals.OptionalDecoder;
|
||||
import feign.querymap.BeanQueryMapEncoder;
|
||||
import feign.slf4j.Slf4jLogger;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -43,7 +41,6 @@ import org.springframework.cloud.openfeign.support.SpringMvcContract;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
@@ -52,10 +49,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = FeignClientOverrideDefaultsTests.TestConfiguration.class)
|
||||
@DirtiesContext
|
||||
public class FeignClientOverrideDefaultsTests {
|
||||
class FeignClientOverrideDefaultsTests {
|
||||
|
||||
@Autowired
|
||||
private FeignContext context;
|
||||
@@ -67,85 +63,83 @@ public class FeignClientOverrideDefaultsTests {
|
||||
private BarClient bar;
|
||||
|
||||
@Test
|
||||
public void clientsAvailable() {
|
||||
assertThat(this.foo).isNotNull();
|
||||
assertThat(this.bar).isNotNull();
|
||||
void clientsAvailable() {
|
||||
assertThat(foo).isNotNull();
|
||||
assertThat(bar).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overrideDecoder() {
|
||||
Decoder.Default.class.cast(this.context.getInstance("foo", Decoder.class));
|
||||
OptionalDecoder.class.cast(this.context.getInstance("bar", Decoder.class));
|
||||
void overrideDecoder() {
|
||||
Decoder.Default.class.cast(context.getInstance("foo", Decoder.class));
|
||||
OptionalDecoder.class.cast(context.getInstance("bar", Decoder.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overrideEncoder() {
|
||||
Encoder.Default.class.cast(this.context.getInstance("foo", Encoder.class));
|
||||
PageableSpringEncoder.class.cast(this.context.getInstance("bar", Encoder.class));
|
||||
void overrideEncoder() {
|
||||
Encoder.Default.class.cast(context.getInstance("foo", Encoder.class));
|
||||
PageableSpringEncoder.class.cast(context.getInstance("bar", Encoder.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overrideLogger() {
|
||||
Logger.JavaLogger.class.cast(this.context.getInstance("foo", Logger.class));
|
||||
Slf4jLogger.class.cast(this.context.getInstance("bar", Logger.class));
|
||||
void overrideLogger() {
|
||||
Logger.JavaLogger.class.cast(context.getInstance("foo", Logger.class));
|
||||
Slf4jLogger.class.cast(context.getInstance("bar", Logger.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overrideContract() {
|
||||
Contract.Default.class.cast(this.context.getInstance("foo", Contract.class));
|
||||
SpringMvcContract.class.cast(this.context.getInstance("bar", Contract.class));
|
||||
void overrideContract() {
|
||||
Contract.Default.class.cast(context.getInstance("foo", Contract.class));
|
||||
SpringMvcContract.class.cast(context.getInstance("bar", Contract.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overrideLoggerLevel() {
|
||||
assertThat(this.context.getInstance("foo", Logger.Level.class)).isNull();
|
||||
assertThat(this.context.getInstance("bar", Logger.Level.class))
|
||||
void overrideLoggerLevel() {
|
||||
assertThat(context.getInstance("foo", Logger.Level.class)).isNull();
|
||||
assertThat(context.getInstance("bar", Logger.Level.class))
|
||||
.isEqualTo(Logger.Level.HEADERS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overrideRetryer() {
|
||||
assertThat(this.context.getInstance("foo", Retryer.class))
|
||||
void overrideRetryer() {
|
||||
assertThat(context.getInstance("foo", Retryer.class))
|
||||
.isEqualTo(Retryer.NEVER_RETRY);
|
||||
Retryer.Default.class.cast(this.context.getInstance("bar", Retryer.class));
|
||||
Retryer.Default.class.cast(context.getInstance("bar", Retryer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overrideErrorDecoder() {
|
||||
assertThat(this.context.getInstance("foo", ErrorDecoder.class)).isNull();
|
||||
ErrorDecoder.Default.class
|
||||
.cast(this.context.getInstance("bar", ErrorDecoder.class));
|
||||
void overrideErrorDecoder() {
|
||||
assertThat(context.getInstance("foo", ErrorDecoder.class)).isNull();
|
||||
ErrorDecoder.Default.class.cast(context.getInstance("bar", ErrorDecoder.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overrideRequestOptions() {
|
||||
assertThat(this.context.getInstance("foo", Request.Options.class)).isNull();
|
||||
Request.Options options = this.context.getInstance("bar", Request.Options.class);
|
||||
void overrideRequestOptions() {
|
||||
assertThat(context.getInstance("foo", Request.Options.class)).isNull();
|
||||
Request.Options options = context.getInstance("bar", Request.Options.class);
|
||||
assertThat(options.connectTimeoutMillis()).isEqualTo(1);
|
||||
assertThat(options.readTimeoutMillis()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overrideQueryMapEncoder() {
|
||||
void overrideQueryMapEncoder() {
|
||||
QueryMapEncoder.Default.class
|
||||
.cast(this.context.getInstance("foo", QueryMapEncoder.class));
|
||||
BeanQueryMapEncoder.class
|
||||
.cast(this.context.getInstance("bar", QueryMapEncoder.class));
|
||||
.cast(context.getInstance("foo", QueryMapEncoder.class));
|
||||
BeanQueryMapEncoder.class.cast(context.getInstance("bar", QueryMapEncoder.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addRequestInterceptor() {
|
||||
assertThat(this.context.getInstances("foo", RequestInterceptor.class).size())
|
||||
void addRequestInterceptor() {
|
||||
assertThat(context.getInstances("foo", RequestInterceptor.class).size())
|
||||
.isEqualTo(1);
|
||||
assertThat(this.context.getInstances("bar", RequestInterceptor.class).size())
|
||||
assertThat(context.getInstances("bar", RequestInterceptor.class).size())
|
||||
.isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exceptionPropagationPolicy() {
|
||||
assertThat(this.context.getInstances("foo", ExceptionPropagationPolicy.class))
|
||||
.isNull();
|
||||
assertThat(this.context.getInstances("bar", ExceptionPropagationPolicy.class))
|
||||
void exceptionPropagationPolicy() {
|
||||
assertThat(context.getInstances("foo", ExceptionPropagationPolicy.class))
|
||||
.isEmpty();
|
||||
assertThat(context.getInstances("bar", ExceptionPropagationPolicy.class))
|
||||
.containsValues(ExceptionPropagationPolicy.UNWRAP);
|
||||
}
|
||||
|
||||
@@ -174,10 +168,7 @@ public class FeignClientOverrideDefaultsTests {
|
||||
|
||||
@Bean
|
||||
RequestInterceptor defaultRequestInterceptor() {
|
||||
return new RequestInterceptor() {
|
||||
@Override
|
||||
public void apply(RequestTemplate template) {
|
||||
}
|
||||
return template -> {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user