diff --git a/docs/modules/ROOT/pages/spring-cloud-openfeign.adoc b/docs/modules/ROOT/pages/spring-cloud-openfeign.adoc
index 28e323171..eb1664bc0 100644
--- a/docs/modules/ROOT/pages/spring-cloud-openfeign.adoc
+++ b/docs/modules/ROOT/pages/spring-cloud-openfeign.adoc
@@ -1074,6 +1074,61 @@ The URL provided in the configuration properties remains unused.
|===
+[[testing-feign-clients]]
+=== Testing Feign Clients
+
+The `spring-cloud-openfeign-test` module provides a `@FeignClientTest` annotation for tests that focus only on the Feign clients of an application, like the test slices of Spring Boot, such as `@RestClientTest`.
+To use it, add the module to the test dependencies of your project, next to `spring-cloud-starter-openfeign`:
+
+[source,xml,indent=0]
+----
+
+ org.springframework.cloud
+ spring-cloud-openfeign-test
+ test
+
+----
+
+A `@FeignClientTest` test only enables the Feign, HTTP message converter and JSON auto-configuration.
+Component scanning is limited to the configuration classes annotated with `@EnableFeignClients` and to the components that customize Feign clients, such as `RequestInterceptor`, `ErrorDecoder` or `FeignBuilderCustomizer` components.
+The `@Bean` methods of other configuration classes are not loaded, so import the beans that a test needs with `@Import`.
+The auto-configuration of circuit breakers, Micrometer and caching is not enabled either, so a fallback is not used unless the test enables it, for example with `@ImportAutoConfiguration`.
+The Feign clients are the ones that the `@EnableFeignClients` annotation of the application registers, and a client is only created when it is injected, so the clients that a test does not use need no configuration.
+
+A test points a client at a stub server, such as WireMock, with the `spring.cloud.openfeign.client.config..url` property, as in the following example.
+For a client with a `url` attribute, which takes precedence over that property, set the property that the attribute reads instead.
+
+[source,java,indent=0]
+----
+@FeignClientTest
+class GreetingClientTests {
+
+ @RegisterExtension
+ static WireMockExtension wireMock = WireMockExtension.newInstance()
+ .options(wireMockConfig().dynamicPort())
+ .build();
+
+ @DynamicPropertySource
+ static void greetingsUrl(DynamicPropertyRegistry registry) {
+ registry.add("spring.cloud.openfeign.client.config.greetings.url", wireMock::baseUrl);
+ }
+
+ @Autowired
+ private GreetingClient greetingClient;
+
+ @Test
+ void greet() {
+ wireMock.stubFor(get("/greetings/Ada").willReturn(okJson("{\"message\":\"Hello Ada\"}")));
+
+ assertThat(this.greetingClient.greet("Ada").message()).isEqualTo("Hello Ada");
+ }
+
+}
+----
+
+To use the Feign clients in another test slice, such as `@WebMvcTest`, add the `@AutoConfigureFeign` annotation to the test, which enables the same auto-configuration.
+It does not change the component scanning of that slice.
+
[[aot-and-native-image-support]]
=== AOT and Native Image Support
diff --git a/pom.xml b/pom.xml
index 9f63dc3c7..07b6ca62a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -186,6 +186,7 @@
spring-cloud-openfeign-dependenciesspring-cloud-openfeign-core
+ spring-cloud-openfeign-testspring-cloud-starter-openfeigndocs
diff --git a/spring-cloud-openfeign-dependencies/pom.xml b/spring-cloud-openfeign-dependencies/pom.xml
index 15cf430c4..d1af43a9f 100644
--- a/spring-cloud-openfeign-dependencies/pom.xml
+++ b/spring-cloud-openfeign-dependencies/pom.xml
@@ -24,6 +24,11 @@
spring-cloud-openfeign-core${project.version}
+
+ org.springframework.cloud
+ spring-cloud-openfeign-test
+ ${project.version}
+ org.springframework.cloudspring-cloud-starter-openfeign
diff --git a/spring-cloud-openfeign-test/pom.xml b/spring-cloud-openfeign-test/pom.xml
new file mode 100644
index 000000000..20dfb7326
--- /dev/null
+++ b/spring-cloud-openfeign-test/pom.xml
@@ -0,0 +1,89 @@
+
+
+ 4.0.0
+
+ org.springframework.cloud
+ spring-cloud-openfeign
+ 5.1.0-SNAPSHOT
+ ..
+
+
+ https://github.com/spring-cloud/spring-cloud-openfeign
+
+ spring-cloud-openfeign-test
+ jar
+ Spring Cloud OpenFeign Test
+ Spring Cloud OpenFeign Test
+
+ ${basedir}/..
+
+
+
+ org.springframework.cloud
+ spring-cloud-openfeign-core
+
+
+ org.springframework.boot
+ spring-boot-test-autoconfigure
+
+
+ org.springframework.boot
+ spring-boot-http-converter
+
+
+ io.github.openfeign
+ feign-core
+
+
+ org.springframework
+ spring-test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-jackson
+ test
+
+
+ org.springframework.boot
+ spring-boot-webmvc-test
+ test
+
+
+ io.github.openfeign
+ feign-slf4j
+ test
+
+
+ jakarta.servlet
+ jakarta.servlet-api
+ test
+
+
+ org.springframework.cloud
+ spring-cloud-commons
+ test
+
+
+ org.springframework.cloud
+ spring-cloud-context
+ test
+
+
+ org.junit.platform
+ junit-platform-launcher
+ test
+
+
+
diff --git a/spring-cloud-openfeign-test/src/main/java/org/springframework/cloud/openfeign/test/autoconfigure/AutoConfigureFeign.java b/spring-cloud-openfeign-test/src/main/java/org/springframework/cloud/openfeign/test/autoconfigure/AutoConfigureFeign.java
new file mode 100644
index 000000000..a912ba8a3
--- /dev/null
+++ b/spring-cloud-openfeign-test/src/main/java/org/springframework/cloud/openfeign/test/autoconfigure/AutoConfigureFeign.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2013-present 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.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.cloud.openfeign.test.autoconfigure;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.json.AutoConfigureJson;
+
+/**
+ * Annotation that can be applied to a test class to enable the auto-configuration of
+ * Feign clients, such as in another test slice than
+ * {@link FeignClientTest @FeignClientTest}. It does not change the component scanning of
+ * that slice.
+ *
+ * @author Sharang Gupta
+ * @since 5.1.0
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+@AutoConfigureJson
+@ImportAutoConfiguration
+public @interface AutoConfigureFeign {
+
+}
diff --git a/spring-cloud-openfeign-test/src/main/java/org/springframework/cloud/openfeign/test/autoconfigure/FeignClientTest.java b/spring-cloud-openfeign-test/src/main/java/org/springframework/cloud/openfeign/test/autoconfigure/FeignClientTest.java
new file mode 100644
index 000000000..9c0ec4372
--- /dev/null
+++ b/spring-cloud-openfeign-test/src/main/java/org/springframework/cloud/openfeign/test/autoconfigure/FeignClientTest.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2013-present 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.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.cloud.openfeign.test.autoconfigure;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration;
+import org.springframework.boot.test.context.filter.annotation.TypeExcludeFilters;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.core.annotation.AliasFor;
+import org.springframework.core.env.Environment;
+import org.springframework.test.context.BootstrapWith;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+/**
+ * Annotation for a test that focuses only on the
+ * {@link FeignClient @FeignClient} interfaces of an application.
+ *
+ * Using this annotation only enables the auto-configuration that is relevant to Feign
+ * clients: the Feign, HTTP message converter and JSON auto-configuration. Similarly,
+ * component scanning is limited to the configuration classes annotated with
+ * {@link EnableFeignClients @EnableFeignClients} and to the components that customize
+ * Feign clients, such as {@code RequestInterceptor}, {@code ErrorDecoder} or
+ * {@code FeignBuilderCustomizer} components, as well as {@code JacksonModule} and
+ * {@code @JacksonComponent} beans. The {@code @Bean} methods of other configuration
+ * classes are not loaded, so the beans they declare need an
+ * {@link org.springframework.context.annotation.Import @Import}. The auto-configuration
+ * of circuit breakers, Micrometer and caching is not enabled either.
+ *
+ * The Feign clients are the ones that the {@code @EnableFeignClients} annotation of the
+ * application registers. A test points a client at a stub server, such as WireMock, with
+ * the {@code spring.cloud.openfeign.client.config..url} property, or with the
+ * property that the {@code url} attribute of its {@code @FeignClient} reads, since that
+ * attribute takes precedence. A client is only created when it is injected, so the
+ * clients that a test does not use need no configuration.
+ *
+ * For more fine-grained control, the {@link AutoConfigureFeign @AutoConfigureFeign}
+ * annotation adds the same auto-configuration to another test slice.
+ *
+ * @author Sharang Gupta
+ * @since 5.1.0
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+@BootstrapWith(FeignClientTestContextBootstrapper.class)
+@ExtendWith(SpringExtension.class)
+@OverrideAutoConfiguration(enabled = false)
+@TypeExcludeFilters(FeignClientTypeExcludeFilter.class)
+@AutoConfigureFeign
+@ImportAutoConfiguration
+public @interface FeignClientTest {
+
+ /**
+ * Properties in form {@literal key=value} that should be added to the Spring
+ * {@link Environment} before the test runs.
+ * @return the properties to add
+ */
+ String[] properties() default {};
+
+ /**
+ * Determines if default filtering should be used with
+ * {@link SpringBootApplication @SpringBootApplication}. By default, only the
+ * configuration classes annotated with {@code @EnableFeignClients} and the beans that
+ * customize Feign clients are included.
+ * @see #includeFilters()
+ * @see #excludeFilters()
+ * @return if default filters should be used
+ */
+ boolean useDefaultFilters() default true;
+
+ /**
+ * A set of include filters which can be used to add otherwise filtered beans to the
+ * application context.
+ * @return include filters to apply
+ */
+ ComponentScan.Filter[] includeFilters() default {};
+
+ /**
+ * A set of exclude filters which can be used to filter beans that would otherwise be
+ * added to the application context.
+ * @return exclude filters to apply
+ */
+ ComponentScan.Filter[] excludeFilters() default {};
+
+ /**
+ * Auto-configuration exclusions that should be applied for this test.
+ * @return auto-configuration exclusions to apply
+ */
+ @AliasFor(annotation = ImportAutoConfiguration.class, attribute = "exclude")
+ Class>[] excludeAutoConfiguration() default {};
+
+}
diff --git a/spring-cloud-openfeign-test/src/main/java/org/springframework/cloud/openfeign/test/autoconfigure/FeignClientTestContextBootstrapper.java b/spring-cloud-openfeign-test/src/main/java/org/springframework/cloud/openfeign/test/autoconfigure/FeignClientTestContextBootstrapper.java
new file mode 100644
index 000000000..3ad145503
--- /dev/null
+++ b/spring-cloud-openfeign-test/src/main/java/org/springframework/cloud/openfeign/test/autoconfigure/FeignClientTestContextBootstrapper.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2013-present 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.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.cloud.openfeign.test.autoconfigure;
+
+import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper;
+import org.springframework.test.context.TestContextBootstrapper;
+
+/**
+ * {@link TestContextBootstrapper} for {@link FeignClientTest @FeignClientTest} support.
+ *
+ * @author Sharang Gupta
+ */
+class FeignClientTestContextBootstrapper extends TestSliceTestContextBootstrapper {
+
+}
diff --git a/spring-cloud-openfeign-test/src/main/java/org/springframework/cloud/openfeign/test/autoconfigure/FeignClientTypeExcludeFilter.java b/spring-cloud-openfeign-test/src/main/java/org/springframework/cloud/openfeign/test/autoconfigure/FeignClientTypeExcludeFilter.java
new file mode 100644
index 000000000..aa978db7f
--- /dev/null
+++ b/spring-cloud-openfeign-test/src/main/java/org/springframework/cloud/openfeign/test/autoconfigure/FeignClientTypeExcludeFilter.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2013-present 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.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.cloud.openfeign.test.autoconfigure;
+
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import feign.Capability;
+import feign.Client;
+import feign.Contract;
+import feign.Logger;
+import feign.QueryMapEncoder;
+import feign.RequestInterceptor;
+import feign.ResponseInterceptor;
+import feign.Retryer;
+import feign.codec.Decoder;
+import feign.codec.Encoder;
+import feign.codec.ErrorDecoder;
+
+import org.springframework.boot.context.TypeExcludeFilter;
+import org.springframework.boot.http.converter.autoconfigure.ClientHttpMessageConvertersCustomizer;
+import org.springframework.boot.test.context.filter.annotation.StandardAnnotationCustomizableTypeExcludeFilter;
+import org.springframework.cloud.openfeign.AnnotatedParameterProcessor;
+import org.springframework.cloud.openfeign.CircuitBreakerNameResolver;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.cloud.openfeign.FeignBuilderCustomizer;
+import org.springframework.cloud.openfeign.FeignFormatterRegistrar;
+import org.springframework.cloud.openfeign.FeignLoggerFactory;
+import org.springframework.cloud.openfeign.clientconfig.FeignClientConfigurer;
+import org.springframework.cloud.openfeign.support.HttpMessageConverterCustomizer;
+import org.springframework.util.ClassUtils;
+
+/**
+ * {@link TypeExcludeFilter} for {@link FeignClientTest @FeignClientTest}.
+ *
+ * @author Sharang Gupta
+ */
+class FeignClientTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter {
+
+ private static final String[] OPTIONAL_INCLUDES = { "tools.jackson.databind.JacksonModule",
+ "org.springframework.boot.jackson.JacksonComponent", "com.fasterxml.jackson.databind.Module",
+ "org.springframework.boot.jackson2.JsonComponent" };
+
+ private static final Set> KNOWN_INCLUDES;
+
+ static {
+ Set> includes = new LinkedHashSet<>();
+ includes.add(EnableFeignClients.class);
+ includes.add(RequestInterceptor.class);
+ includes.add(ResponseInterceptor.class);
+ includes.add(Encoder.class);
+ includes.add(Decoder.class);
+ includes.add(ErrorDecoder.class);
+ includes.add(Contract.class);
+ includes.add(Retryer.class);
+ includes.add(Logger.class);
+ includes.add(Capability.class);
+ includes.add(QueryMapEncoder.class);
+ includes.add(Client.class);
+ includes.add(FeignBuilderCustomizer.class);
+ includes.add(FeignFormatterRegistrar.class);
+ includes.add(FeignLoggerFactory.class);
+ includes.add(AnnotatedParameterProcessor.class);
+ includes.add(FeignClientConfigurer.class);
+ includes.add(FallbackFactory.class);
+ includes.add(CircuitBreakerNameResolver.class);
+ includes.add(HttpMessageConverterCustomizer.class);
+ includes.add(ClientHttpMessageConvertersCustomizer.class);
+ for (String optionalInclude : OPTIONAL_INCLUDES) {
+ try {
+ includes.add(ClassUtils.forName(optionalInclude, null));
+ }
+ catch (Exception ex) {
+ // Ignore
+ }
+ }
+ KNOWN_INCLUDES = Collections.unmodifiableSet(includes);
+ }
+
+ FeignClientTypeExcludeFilter(Class> testClass) {
+ super(testClass);
+ }
+
+ @Override
+ protected Set> getKnownIncludes() {
+ return KNOWN_INCLUDES;
+ }
+
+}
diff --git a/spring-cloud-openfeign-test/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.test.autoconfigure.AutoConfigureFeign.imports b/spring-cloud-openfeign-test/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.test.autoconfigure.AutoConfigureFeign.imports
new file mode 100644
index 000000000..9e693fbf1
--- /dev/null
+++ b/spring-cloud-openfeign-test/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.test.autoconfigure.AutoConfigureFeign.imports
@@ -0,0 +1,6 @@
+org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration
+org.springframework.cloud.openfeign.FeignAutoConfiguration
+org.springframework.cloud.openfeign.encoding.FeignAcceptGzipEncodingAutoConfiguration
+org.springframework.cloud.openfeign.encoding.FeignContentGzipEncodingAutoConfiguration
+org.springframework.cloud.openfeign.hateoas.FeignHalAutoConfiguration
+org.springframework.cloud.openfeign.loadbalancer.FeignLoadBalancerAutoConfiguration
diff --git a/spring-cloud-openfeign-test/src/test/java/org/springframework/cloud/openfeign/test/autoconfigure/FeignClientTypeExcludeFilterTests.java b/spring-cloud-openfeign-test/src/test/java/org/springframework/cloud/openfeign/test/autoconfigure/FeignClientTypeExcludeFilterTests.java
new file mode 100644
index 000000000..b39d9ac69
--- /dev/null
+++ b/spring-cloud-openfeign-test/src/test/java/org/springframework/cloud/openfeign/test/autoconfigure/FeignClientTypeExcludeFilterTests.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2013-present 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.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.cloud.openfeign.test.autoconfigure;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import feign.RequestInterceptor;
+import feign.RequestTemplate;
+import feign.Response;
+import feign.Target;
+import feign.codec.ErrorDecoder;
+import org.junit.jupiter.api.Test;
+
+import org.springframework.boot.http.converter.autoconfigure.ClientHttpMessageConvertersCustomizer;
+import org.springframework.cloud.openfeign.CircuitBreakerNameResolver;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.cloud.openfeign.clientconfig.FeignClientConfigurer;
+import org.springframework.cloud.openfeign.support.HttpMessageConverterCustomizer;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.type.classreading.MetadataReader;
+import org.springframework.core.type.classreading.MetadataReaderFactory;
+import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.HttpMessageConverters;
+import org.springframework.stereotype.Service;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Tests for {@link FeignClientTypeExcludeFilter}.
+ *
+ * @author Sharang Gupta
+ */
+class FeignClientTypeExcludeFilterTests {
+
+ private final MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
+
+ @Test
+ void doesNotExcludeTheComponentsThatCustomizeFeignClients() throws IOException {
+ FeignClientTypeExcludeFilter filter = new FeignClientTypeExcludeFilter(WithDefaultFilters.class);
+
+ assertThat(excludes(filter, ExampleFeignClientsConfiguration.class)).isFalse();
+ assertThat(excludes(filter, ExampleRequestInterceptor.class)).isFalse();
+ assertThat(excludes(filter, ExampleErrorDecoder.class)).isFalse();
+ assertThat(excludes(filter, ExampleFallbackFactory.class)).isFalse();
+ assertThat(excludes(filter, ExampleCircuitBreakerNameResolver.class)).isFalse();
+ assertThat(excludes(filter, ExampleFeignClientConfigurer.class)).isFalse();
+ assertThat(excludes(filter, ExampleHttpMessageConverterCustomizer.class)).isFalse();
+ assertThat(excludes(filter, ExampleClientHttpMessageConvertersCustomizer.class)).isFalse();
+ }
+
+ @Test
+ void excludesOtherComponents() throws IOException {
+ FeignClientTypeExcludeFilter filter = new FeignClientTypeExcludeFilter(WithDefaultFilters.class);
+
+ assertThat(excludes(filter, ExampleService.class)).isTrue();
+ }
+
+ @Test
+ void excludesTheComponentsThatCustomizeFeignClientsWithoutDefaultFilters() throws IOException {
+ FeignClientTypeExcludeFilter filter = new FeignClientTypeExcludeFilter(WithoutDefaultFilters.class);
+
+ assertThat(excludes(filter, ExampleRequestInterceptor.class)).isTrue();
+ }
+
+ private boolean excludes(FeignClientTypeExcludeFilter filter, Class> type) throws IOException {
+ MetadataReader metadataReader = this.metadataReaderFactory.getMetadataReader(type.getName());
+ return filter.match(metadataReader, this.metadataReaderFactory);
+ }
+
+ @FeignClientTest
+ static class WithDefaultFilters {
+
+ }
+
+ @FeignClientTest(useDefaultFilters = false)
+ static class WithoutDefaultFilters {
+
+ }
+
+ @Configuration(proxyBeanMethods = false)
+ @EnableFeignClients
+ static class ExampleFeignClientsConfiguration {
+
+ }
+
+ static class ExampleRequestInterceptor implements RequestInterceptor {
+
+ @Override
+ public void apply(RequestTemplate template) {
+ }
+
+ }
+
+ static class ExampleErrorDecoder implements ErrorDecoder {
+
+ @Override
+ public Exception decode(String methodKey, Response response) {
+ return new IllegalStateException(methodKey);
+ }
+
+ }
+
+ static class ExampleFallbackFactory implements FallbackFactory