From cb3e631d4037ba93116f8495931160fb4a69811f Mon Sep 17 00:00:00 2001 From: Olga MaciaszekSharma Date: Fri, 15 Sep 2023 18:10:24 +0200 Subject: [PATCH] Initial commit --- .editorconfig | 14 - .flattened-pom.xml | 134 ++ .github/CONTRIBUTING.md | 45 - .github/ISSUE_TEMPLATE.md | 20 - .github/ISSUE_TEMPLATE/bug_report.md | 17 - .github/ISSUE_TEMPLATE/feature_request.md | 20 - .github/workflows/deploy-docs.yml | 53 + .github/workflows/maven.yml | 33 - .gitignore | 35 +- .java-version | 1 - .mvn/maven.config | 2 - .mvn/wrapper/MavenWrapperDownloader.java | 117 + .mvn/wrapper/maven-wrapper.jar | Bin 62547 -> 50710 bytes .mvn/wrapper/maven-wrapper.properties | 20 +- .sdkmanrc | 3 - .settings.xml | 68 - .springformat | 0 Guardfile | 11 - LICENSE.txt | 202 -- README.adoc | 361 +-- ...antora-playbook.yml => antora-playbook.yml | 33 +- asciidoctor.css | 2011 ----------------- codecov.yml | 7 - docs/.flattened-pom.xml | 106 + docs/.github/workflows/deploy-docs.yml | 32 - docs/antora.yml | 12 - docs/modules/ROOT/nav.adoc | 9 - docs/modules/ROOT/pages/README.adoc | 27 - docs/modules/ROOT/pages/_attributes.adoc | 16 - docs/modules/ROOT/pages/_configprops.adoc | 37 - docs/modules/ROOT/pages/appendix.adoc | 13 - docs/modules/ROOT/pages/index.adoc | 0 docs/modules/ROOT/pages/intro.adoc | 3 - docs/modules/ROOT/pages/sagan-boot.adoc | 0 docs/modules/ROOT/pages/sagan-index.adoc | 41 - .../ROOT/pages/spring-cloud-openfeign.adoc | 957 -------- docs/pom.xml | 71 - docs/src/main/asciidoc/ghpages.sh | 330 --- mvnw | 224 +- mvnw.cmd | 57 +- pom.xml | 270 +-- .../.flattened-pom.xml | 302 +++ spring-cloud-openfeign-core/pom.xml | 247 -- .../AnnotatedParameterProcessor.java | 83 - .../cloud/openfeign/CachingCapability.java | 42 - .../openfeign/CircuitBreakerNameResolver.java | 34 - .../cloud/openfeign/CollectionFormat.java | 42 - .../openfeign/DefaultFeignLoggerFactory.java | 39 - .../cloud/openfeign/DefaultTargeter.java | 33 - .../cloud/openfeign/EnableFeignClients.java | 90 - .../cloud/openfeign/FallbackFactory.java | 87 - .../openfeign/FeignAutoConfiguration.java | 421 ---- .../openfeign/FeignBuilderCustomizer.java | 31 - .../FeignCachingInvocationHandlerFactory.java | 82 - .../cloud/openfeign/FeignCircuitBreaker.java | 101 - ...FeignCircuitBreakerDisabledConditions.java | 40 - .../FeignCircuitBreakerInvocationHandler.java | 192 -- .../FeignCircuitBreakerTargeter.java | 116 - .../cloud/openfeign/FeignClient.java | 119 - .../cloud/openfeign/FeignClientBuilder.java | 130 -- .../cloud/openfeign/FeignClientFactory.java | 80 - .../openfeign/FeignClientFactoryBean.java | 675 ------ ...FeignClientMicrometerEnabledCondition.java | 52 - .../openfeign/FeignClientProperties.java | 383 ---- .../openfeign/FeignClientSpecification.java | 95 - .../openfeign/FeignClientsConfiguration.java | 261 --- .../openfeign/FeignClientsRegistrar.java | 502 ---- .../openfeign/FeignErrorDecoderFactory.java | 37 - .../openfeign/FeignFormatterRegistrar.java | 29 - .../cloud/openfeign/FeignLoggerFactory.java | 35 - .../cloud/openfeign/OptionsFactoryBean.java | 86 - .../cloud/openfeign/PropertyBasedTarget.java | 49 - .../openfeign/RefreshableHardCodedTarget.java | 42 - .../cloud/openfeign/RefreshableUrl.java | 38 - .../openfeign/RefreshableUrlFactoryBean.java | 75 - .../cloud/openfeign/SpringQueryMap.java | 35 - .../cloud/openfeign/Targeter.java | 30 - .../CookieValueParameterProcessor.java | 69 - .../MatrixVariableParameterProcessor.java | 80 - .../PathVariableParameterProcessor.java | 79 - .../QueryMapParameterProcessor.java | 53 - .../RequestHeaderParameterProcessor.java | 70 - .../RequestParamParameterProcessor.java | 71 - .../RequestPartParameterProcessor.java | 61 - .../aot/FeignChildContextInitializer.java | 126 -- ...BeanFactoryInitializationAotProcessor.java | 215 -- .../clientconfig/FeignClientConfigurer.java | 45 - .../Http2ClientFeignConfiguration.java | 45 - .../HttpClient5FeignConfiguration.java | 149 -- .../encoding/BaseRequestInterceptor.java | 62 - ...gnAcceptGzipEncodingAutoConfiguration.java | 56 - .../FeignAcceptGzipEncodingInterceptor.java | 50 - .../FeignClientEncodingProperties.java | 82 - ...nContentGzipEncodingAutoConfiguration.java | 53 - .../FeignContentGzipEncodingInterceptor.java | 109 - .../openfeign/encoding/HttpEncoding.java | 56 - ...OkHttpFeignClientBeanMissingCondition.java | 51 - .../hateoas/FeignHalAutoConfiguration.java | 49 - .../hateoas/WebConvertersCustomizer.java | 41 - ...DefaultFeignLoadBalancerConfiguration.java | 71 - .../FeignBlockingLoadBalancerClient.java | 165 -- .../FeignLoadBalancerAutoConfiguration.java | 67 - ...2ClientFeignLoadBalancerConfiguration.java | 76 - ...Client5FeignLoadBalancerConfiguration.java | 82 - .../LoadBalancerFeignRequestTransformer.java | 47 - ...adBalancerResponseStatusCodeException.java | 46 - .../loadbalancer/LoadBalancerUtils.java | 95 - .../OkHttpFeignLoadBalancerConfiguration.java | 77 - .../OnRetryNotEnabledCondition.java | 55 - ...ryableFeignBlockingLoadBalancerClient.java | 281 --- .../XForwardedHeadersTransformer.java | 63 - .../OAuth2AccessTokenInterceptor.java | 144 -- .../openfeign/support/AbstractFormWriter.java | 87 - .../support/EmptyObjectProvider.java | 54 - .../support/FeignEncoderProperties.java | 44 - .../support/FeignHttpClientProperties.java | 401 ---- .../cloud/openfeign/support/FeignUtils.java | 51 - .../HttpMessageConverterCustomizer.java | 33 - .../openfeign/support/JsonFormWriter.java | 46 - .../openfeign/support/PageJacksonModule.java | 216 -- .../support/PageableSpringEncoder.java | 129 -- .../PageableSpringQueryMapEncoder.java | 106 - .../support/ResponseEntityDecoder.java | 90 - .../openfeign/support/SortJacksonModule.java | 55 - .../openfeign/support/SortJsonComponent.java | 93 - .../openfeign/support/SpringDecoder.java | 126 -- .../openfeign/support/SpringEncoder.java | 265 --- .../openfeign/support/SpringMvcContract.java | 468 ---- ...itional-spring-configuration-metadata.json | 96 - .../resources/META-INF/spring/aot.factories | 2 - ...ot.autoconfigure.AutoConfiguration.imports | 5 - ...erInitFeignClientUsingConfigurerTests.java | 169 -- .../EnableFeignClientsSpringDataTests.java | 50 - .../openfeign/EnableFeignClientsTests.java | 92 - .../FeignAutoConfigurationTests.java | 140 -- .../FeignBuilderCustomizerTests.java | 256 --- .../openfeign/FeignClientBuilderTests.java | 179 -- .../openfeign/FeignClientCacheTests.java | 124 - .../FeignClientConfigurationTests.java | 152 -- ...lientDisabledClientLevelFeaturesTests.java | 124 - .../FeignClientDisabledFeaturesTests.java | 119 - .../FeignClientErrorDecoderTests.java | 172 -- .../openfeign/FeignClientFactoryTest.java | 120 - .../openfeign/FeignClientFactoryTests.java | 163 -- ...ClientMicrometerEnabledConditionTests.java | 225 -- .../FeignClientOverrideDefaultsTests.java | 337 --- .../openfeign/FeignClientPropertiesTests.java | 90 - .../FeignClientUsingPropertiesTests.java | 488 ---- ...FeignClientWithRefreshableOptionsTest.java | 185 -- ...ientsMicrometerAutoConfigurationTests.java | 84 - ...FeignClientsRegistrarIntegrationTests.java | 95 - .../openfeign/FeignClientsRegistrarTests.java | 201 -- .../openfeign/FeignCompressionTests.java | 89 - .../FeignErrorDecoderFactoryTests.java | 119 - .../FeignHttp2ClientConfigurationTests.java | 70 - .../FeignHttpClient5ConfigurationTests.java | 75 - .../openfeign/FeignHttpClientUrlTests.java | 209 -- ...ientUrlWithRetryableLoadBalancerTests.java | 211 -- .../openfeign/FeignLoggerFactoryTests.java | 124 - .../FeignOkHttpConfigurationTests.java | 90 - .../cloud/openfeign/GzipDecodingTests.java | 172 -- ...zyInitFeignClientUsingConfigurerTests.java | 176 -- .../openfeign/MicrometerPropertiesTests.java | 78 - .../NonRefreshableFeignClientUrlTests.java | 117 - .../cloud/openfeign/OptionsTestClient.java | 81 - .../RefreshableFeignClientUrlTests.java | 150 -- .../cloud/openfeign/SpringDecoderTests.java | 272 --- .../cloud/openfeign/UrlTestClient.java | 104 - .../cloud/openfeign/aot/FeignAotTests.java | 171 -- ...actoryInitializationAotProcessorTests.java | 197 -- .../beans/BeansFeignClientTests.java | 171 -- .../beans/FeignClientMockBeanTests.java | 83 - .../cloud/openfeign/beans/TestClient.java | 31 - .../openfeign/beans/extra/TestClient.java | 29 - .../circuitbreaker/AsyncCircuitBreaker.java | 60 - .../AsyncCircuitBreakerTests.java | 201 -- .../CircuitBreakerAutoConfigurationTests.java | 81 - .../circuitbreaker/CircuitBreakerTests.java | 284 --- .../CircuitBreakerWithNoFallbackTests.java | 155 -- .../FallbackSupportFactoryBeanTests.java | 134 -- .../cloud/openfeign/circuitbreaker/Hello.java | 60 - .../circuitbreaker/MyCircuitBreaker.java | 59 - .../encoding/FeignAcceptEncodingTests.java | 94 - .../encoding/FeignContentEncodingTests.java | 95 - .../encoding/FeignPageableEncodingTests.java | 291 --- .../cloud/openfeign/encoding/Invoices.java | 49 - .../encoding/app/client/InvoiceClient.java | 60 - .../encoding/app/domain/Invoice.java | 48 - .../app/resource/InvoiceResource.java | 126 -- .../proto/ProtobufNotInClasspathTest.java | 47 - .../proto/ProtobufSpringEncoderTests.java | 143 -- .../encoding/proto/ProtobufTest.java | 68 - .../openfeign/encoding/proto/Request.java | 575 ----- .../encoding/proto/RequestOrBuilder.java | 41 - .../feignclientsregistrar/TopLevelClient.java | 28 - .../sub/SubLevelClient.java | 28 - ...FeignHalAutoConfigurationContextTests.java | 66 - .../openfeign/hateoas/FeignHalTests.java | 102 - .../hateoas/app/FeignHalApplication.java | 58 - .../openfeign/hateoas/app/FeignHalClient.java | 40 - .../hateoas/app/FeignHalConfiguration.java | 29 - .../hateoas/app/FeignHalController.java | 59 - .../openfeign/hateoas/app/MarsRover.java | 34 - .../invalid/FeignClientValidationTests.java | 119 - .../FeignBlockingLoadBalancerClientTests.java | 288 --- ...ignLoadBalancerAutoConfigurationTests.java | 161 -- ...eFeignBlockingLoadBalancerClientTests.java | 403 ---- .../XForwardedHeadersTransformerTests.java | 97 - .../protocol/FeignOkHttpProtocolsTests.java | 79 - .../OAuth2AccessTokenInterceptorTests.java | 128 -- .../support/AbstractFormWriterTests.java | 62 - ...ractSpringMvcContractIntegrationTests.java | 112 - .../FeignHttpClientPropertiesTests.java | 132 -- .../support/PageJacksonModuleTests.java | 159 -- .../support/PageableEncoderTests.java | 136 -- ...PageableEncoderWithSpringDataWebTests.java | 52 - .../PageableSpringQueryMapEncoderTests.java | 124 - ...QueryMapEncoderWithSpringDataWebTests.java | 52 - .../support/PageableSupportTest.java | 101 - .../support/SortJacksonModuleTests.java | 89 - .../openfeign/support/SpringEncoderTests.java | 354 --- .../SpringMvcContractIntegrationTests.java | 54 - ...ContractSlashEncodingIntegrationTests.java | 48 - .../support/SpringMvcContractTests.java | 923 -------- .../ApacheHttpClient5ConfigurationTests.java | 176 -- .../test/EqualsAndHashCodeAssert.java | 110 - .../test/Http2ClientConfigurationTests.java | 81 - .../test/NoSecurityConfiguration.java | 33 - .../test/OkHttpClientConfigurationTests.java | 83 - .../openfeign/testclients/TestClient.java | 31 - .../valid/FeignClientNotPrimaryTests.java | 161 -- .../valid/FeignClientValidationTests.java | 111 - .../valid/FeignHttp2ClientTests.java | 256 --- .../openfeign/valid/FeignHttpClientTests.java | 255 --- .../openfeign/valid/FeignOkHttpTests.java | 256 --- .../valid/IterableParameterTests.java | 102 - .../valid/ValidFeignClientTests.java | 801 ------- .../scanning/FeignClientEnvVarTests.java | 91 - .../scanning/FeignClientScanningTests.java | 122 - .../src/test/resources/application.yml | 31 - .../src/test/resources/dummy.pdf | Bin 13264 -> 0 bytes .../resources/feign-properties.properties | 30 - .../feign-refreshable-properties.properties | 13 - .../src/test/resources/logback-test.xml | 11 - spring-cloud-openfeign-dependencies/pom.xml | 113 - .../.flattened-pom.xml | 144 ++ spring-cloud-starter-openfeign/pom.xml | 56 - src/checkstyle/checkstyle-suppressions.xml | 19 - supplemental-ui/partials/nav-search.hbs | 11 + supplemental-ui/partials/search.hbs | 27 + 250 files changed, 1123 insertions(+), 30628 deletions(-) delete mode 100644 .editorconfig create mode 100644 .flattened-pom.xml delete mode 100644 .github/CONTRIBUTING.md delete mode 100644 .github/ISSUE_TEMPLATE.md delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/workflows/deploy-docs.yml delete mode 100644 .github/workflows/maven.yml delete mode 100644 .java-version delete mode 100644 .mvn/maven.config create mode 100644 .mvn/wrapper/MavenWrapperDownloader.java delete mode 100644 .sdkmanrc delete mode 100644 .settings.xml delete mode 100644 .springformat delete mode 100644 Guardfile delete mode 100644 LICENSE.txt rename docs/antora-playbook.yml => antora-playbook.yml (61%) delete mode 100644 asciidoctor.css delete mode 100644 codecov.yml create mode 100644 docs/.flattened-pom.xml delete mode 100644 docs/.github/workflows/deploy-docs.yml delete mode 100644 docs/antora.yml delete mode 100644 docs/modules/ROOT/nav.adoc delete mode 100644 docs/modules/ROOT/pages/README.adoc delete mode 100644 docs/modules/ROOT/pages/_attributes.adoc delete mode 100644 docs/modules/ROOT/pages/_configprops.adoc delete mode 100644 docs/modules/ROOT/pages/appendix.adoc delete mode 100644 docs/modules/ROOT/pages/index.adoc delete mode 100644 docs/modules/ROOT/pages/intro.adoc delete mode 100644 docs/modules/ROOT/pages/sagan-boot.adoc delete mode 100644 docs/modules/ROOT/pages/sagan-index.adoc delete mode 100644 docs/modules/ROOT/pages/spring-cloud-openfeign.adoc delete mode 100644 docs/pom.xml delete mode 100755 docs/src/main/asciidoc/ghpages.sh create mode 100644 spring-cloud-openfeign-core/.flattened-pom.xml delete mode 100644 spring-cloud-openfeign-core/pom.xml delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/AnnotatedParameterProcessor.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/CachingCapability.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/CircuitBreakerNameResolver.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/CollectionFormat.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/DefaultFeignLoggerFactory.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/DefaultTargeter.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/EnableFeignClients.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FallbackFactory.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignAutoConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignBuilderCustomizer.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCachingInvocationHandlerFactory.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreaker.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerDisabledConditions.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerInvocationHandler.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerTargeter.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClient.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientBuilder.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactory.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactoryBean.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientMicrometerEnabledCondition.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientProperties.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientSpecification.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignErrorDecoderFactory.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignFormatterRegistrar.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignLoggerFactory.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/OptionsFactoryBean.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/PropertyBasedTarget.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/RefreshableHardCodedTarget.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/RefreshableUrl.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/RefreshableUrlFactoryBean.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/SpringQueryMap.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/Targeter.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/CookieValueParameterProcessor.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/MatrixVariableParameterProcessor.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/PathVariableParameterProcessor.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/QueryMapParameterProcessor.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/RequestHeaderParameterProcessor.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/RequestParamParameterProcessor.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/RequestPartParameterProcessor.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/aot/FeignChildContextInitializer.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/aot/FeignClientBeanFactoryInitializationAotProcessor.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/clientconfig/FeignClientConfigurer.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/clientconfig/Http2ClientFeignConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/clientconfig/HttpClient5FeignConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/BaseRequestInterceptor.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignAcceptGzipEncodingAutoConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignAcceptGzipEncodingInterceptor.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignClientEncodingProperties.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignContentGzipEncodingAutoConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignContentGzipEncodingInterceptor.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/HttpEncoding.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/OkHttpFeignClientBeanMissingCondition.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/hateoas/FeignHalAutoConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/hateoas/WebConvertersCustomizer.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/DefaultFeignLoadBalancerConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/FeignBlockingLoadBalancerClient.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/FeignLoadBalancerAutoConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/Http2ClientFeignLoadBalancerConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/HttpClient5FeignLoadBalancerConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerFeignRequestTransformer.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerResponseStatusCodeException.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerUtils.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/OkHttpFeignLoadBalancerConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/OnRetryNotEnabledCondition.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClient.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/XForwardedHeadersTransformer.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/security/OAuth2AccessTokenInterceptor.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/AbstractFormWriter.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/EmptyObjectProvider.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignEncoderProperties.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignHttpClientProperties.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/HttpMessageConverterCustomizer.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/JsonFormWriter.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageJacksonModule.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageableSpringEncoder.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageableSpringQueryMapEncoder.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/ResponseEntityDecoder.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SortJacksonModule.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SortJsonComponent.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringDecoder.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringEncoder.java delete mode 100644 spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java delete mode 100644 spring-cloud-openfeign-core/src/main/resources/META-INF/additional-spring-configuration-metadata.json delete mode 100644 spring-cloud-openfeign-core/src/main/resources/META-INF/spring/aot.factories delete mode 100644 spring-cloud-openfeign-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/EagerInitFeignClientUsingConfigurerTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/EnableFeignClientsSpringDataTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/EnableFeignClientsTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignAutoConfigurationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignBuilderCustomizerTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientBuilderTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientCacheTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientConfigurationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledClientLevelFeaturesTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledFeaturesTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientErrorDecoderTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientFactoryTest.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientFactoryTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientMicrometerEnabledConditionTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientOverrideDefaultsTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientPropertiesTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingPropertiesTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientWithRefreshableOptionsTest.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsMicrometerAutoConfigurationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsRegistrarIntegrationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsRegistrarTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignCompressionTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignErrorDecoderFactoryTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttp2ClientConfigurationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClient5ConfigurationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlWithRetryableLoadBalancerTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignLoggerFactoryTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignOkHttpConfigurationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/GzipDecodingTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/LazyInitFeignClientUsingConfigurerTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/MicrometerPropertiesTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/NonRefreshableFeignClientUrlTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/OptionsTestClient.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/RefreshableFeignClientUrlTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/SpringDecoderTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/UrlTestClient.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/aot/FeignAotTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/aot/FeignClientBeanFactoryInitializationAotProcessorTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/BeansFeignClientTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/FeignClientMockBeanTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/TestClient.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/extra/TestClient.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/AsyncCircuitBreaker.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/AsyncCircuitBreakerTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerAutoConfigurationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerWithNoFallbackTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/FallbackSupportFactoryBeanTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/Hello.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/MyCircuitBreaker.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/FeignAcceptEncodingTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/FeignContentEncodingTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/FeignPageableEncodingTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/Invoices.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/client/InvoiceClient.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/domain/Invoice.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/resource/InvoiceResource.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufNotInClasspathTest.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufSpringEncoderTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufTest.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/Request.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/RequestOrBuilder.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/feignclientsregistrar/TopLevelClient.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/feignclientsregistrar/sub/SubLevelClient.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/FeignHalAutoConfigurationContextTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/FeignHalTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalApplication.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalClient.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalController.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/MarsRover.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/invalid/FeignClientValidationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/FeignBlockingLoadBalancerClientTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/FeignLoadBalancerAutoConfigurationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClientTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/XForwardedHeadersTransformerTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/protocol/FeignOkHttpProtocolsTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/security/OAuth2AccessTokenInterceptorTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/AbstractFormWriterTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/AbstractSpringMvcContractIntegrationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/FeignHttpClientPropertiesTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageJacksonModuleTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableEncoderTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableEncoderWithSpringDataWebTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableSpringQueryMapEncoderTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableSpringQueryMapEncoderWithSpringDataWebTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableSupportTest.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SortJacksonModuleTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringEncoderTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractIntegrationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractSlashEncodingIntegrationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/ApacheHttpClient5ConfigurationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/EqualsAndHashCodeAssert.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/Http2ClientConfigurationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/NoSecurityConfiguration.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/OkHttpClientConfigurationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/testclients/TestClient.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientNotPrimaryTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientValidationTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignHttp2ClientTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignHttpClientTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignOkHttpTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/IterableParameterTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/ValidFeignClientTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientEnvVarTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientScanningTests.java delete mode 100644 spring-cloud-openfeign-core/src/test/resources/application.yml delete mode 100644 spring-cloud-openfeign-core/src/test/resources/dummy.pdf delete mode 100644 spring-cloud-openfeign-core/src/test/resources/feign-properties.properties delete mode 100644 spring-cloud-openfeign-core/src/test/resources/feign-refreshable-properties.properties delete mode 100644 spring-cloud-openfeign-core/src/test/resources/logback-test.xml delete mode 100644 spring-cloud-openfeign-dependencies/pom.xml create mode 100644 spring-cloud-starter-openfeign/.flattened-pom.xml delete mode 100644 spring-cloud-starter-openfeign/pom.xml delete mode 100644 src/checkstyle/checkstyle-suppressions.xml create mode 100644 supplemental-ui/partials/nav-search.hbs create mode 100644 supplemental-ui/partials/search.hbs diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index e65ee4533..000000000 --- a/.editorconfig +++ /dev/null @@ -1,14 +0,0 @@ -# EditorConfig is awesome: https://EditorConfig.org - -# top-most EditorConfig file -root = true - -[*] -indent_style = tab -indent_size = 4 -end_of_line = lf -insert_final_newline = true - -[*.yml] -indent_style = space -indent_size = 2 diff --git a/.flattened-pom.xml b/.flattened-pom.xml new file mode 100644 index 000000000..85a754f61 --- /dev/null +++ b/.flattened-pom.xml @@ -0,0 +1,134 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-build + 4.1.0-SNAPSHOT + + + org.springframework.cloud + spring-cloud-openfeign + 4.1.0-SNAPSHOT + pom + Spring Cloud OpenFeign + Spring Cloud OpenFeign + https://spring.io/spring-cloud/spring-cloud-openfeign + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 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. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-openfeign.git + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-openfeign.git + https://github.com/spring-cloud/spring-cloud-openfeign + + + + spring + + + + false + + + true + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + + + false + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + false + + spring-releases + Spring Releases + https://repo.spring.io/release + + + + + diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md deleted file mode 100644 index b44059e78..000000000 --- a/.github/CONTRIBUTING.md +++ /dev/null @@ -1,45 +0,0 @@ - -# Contributing - -Spring Cloud is released under the non-restrictive Apache 2.0 license, -and follows a very standard Github development process, using Github -tracker for issues and merging pull requests into main. If you want -to contribute even something trivial please do not hesitate, but -follow the guidelines below. - -## Sign the Contributor License Agreement -Before we accept a non-trivial patch or pull request we will need you to sign the -[Contributor License Agreement](https://cla.pivotal.io/sign/spring). -Signing the contributor's agreement does not grant anyone commit rights to the main -repository, but it does mean that we can accept your contributions, and you will get an -author credit if we do. Active contributors might be asked to join the core team, and -given the ability to merge pull requests. - -## Code of Conduct -This project adheres to the Contributor Covenant [code of -conduct](https://github.com/spring-cloud/spring-cloud-build/blob/main/docs/src/main/asciidoc/code-of-conduct.adoc). By participating, you are expected to uphold this code. Please report -unacceptable behavior to spring-code-of-conduct@pivotal.io. - -## Code Conventions and Housekeeping -None of these is essential for a pull request, but they will all help. They can also be -added after the original pull request but before a merge. - -* Use the Spring Framework code format conventions. If you use Eclipse - you can import formatter settings using the - `eclipse-code-formatter.xml` file from the - [Spring Cloud Build](https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/spring-cloud-dependencies-parent/eclipse-code-formatter.xml) project. If using IntelliJ, you can use the - [Eclipse Code Formatter Plugin](https://plugins.jetbrains.com/plugin/6546) to import the same file. -* Make sure all new `.java` files to have a simple Javadoc class comment with at least an - `@author` tag identifying you, and preferably at least a paragraph on what the class is - for. -* Add the ASF license header comment to all new `.java` files (copy from existing files - in the project) -* Add yourself as an `@author` to the .java files that you modify substantially (more - than cosmetic changes). -* Add some Javadocs and, if you change the namespace, some XSD doc elements. -* A few unit tests would help a lot as well -- someone has to do it. -* If no-one else is using your branch, please rebase it against the current main (or - other target branch in the main project). -* When writing a commit message please follow [these conventions](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), - if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit - message (where XXXX is the issue number). diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 0bc5ef4fa..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index aeafef9d3..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -Please provide details of the problem, including the version of Spring Cloud that you -are using. - -**Sample** -If possible, please provide a test case or sample application that reproduces -the problem. This makes it much easier for us to diagnose the problem and to verify that -we have fixed it. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index bbcbbe7d6..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 000000000..2043bb9ee --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,53 @@ +name: Deploy Docs +run-name: ${{ format('{0} ({1})', github.workflow, github.event.inputs.build-refname || 'all') }} +on: + workflow_dispatch: + inputs: + build-refname: + description: Enter git refname to build (e.g., 5.7.x). + required: false + push: + branches: docs-build +env: + GRADLE_ENTERPRISE_SECRET_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} +permissions: + contents: write +jobs: + build: + if: github.repository_owner == 'spring-cloud' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 5 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Set up refname build + if: github.event.inputs.build-refname + run: | + git fetch --depth 1 https://github.com/$GITHUB_REPOSITORY ${{ github.event.inputs.build-refname }} + export BUILD_REFNAME=${{ github.event.inputs.build-refname }} + echo "BUILD_REFNAME=$BUILD_REFNAME" >> $GITHUB_ENV + export BUILD_VERSION=$(git cat-file --textconv FETCH_HEAD:pom.xml | python3 -c "import xml.etree.ElementTree as xml; from sys import stdin; print(xml.parse(stdin).getroot().find('{http://maven.apache.org/POM/4.0.0}version').text)") + echo BUILD_VERSION=$BUILD_VERSION >> $GITHUB_ENV + - name: Run Antora + run: | + ./mvnw --no-transfer-progress -B antora + - name: Publish Docs + uses: spring-io/spring-doc-actions/rsync-antora-reference@v0.0.11 + with: + docs-username: ${{ secrets.DOCS_USERNAME }} + docs-host: ${{ secrets.DOCS_HOST }} + docs-ssh-key: ${{ secrets.DOCS_SSH_KEY }} + docs-ssh-host-key: ${{ secrets.DOCS_SSH_HOST_KEY }} + site-path: target/antora/site + - name: Bust Cloudflare Cache + uses: spring-io/spring-doc-actions/bust-cloudflare-antora-cache@v0.0.11 + with: + context-root: spring-cloud-openfeign + cloudflare-zone-id: ${{ secrets.CLOUDFLARE_ZONE_ID }} + cloudflare-cache-token: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index 4cffe942d..000000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,33 +0,0 @@ -# This workflow will build a Java project with Maven -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven - -name: Build - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - - runs-on: ubuntu-latest - - strategy: - matrix: - java: ["17"] - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v2 - with: - distribution: 'zulu' - java-version: ${{ matrix.java }} - cache: 'maven' - - name: Build with Maven - run: ./mvnw clean install -B -U -P sonar - - uses: codecov/codecov-action@v1 - with: - fail_ci_if_error: true diff --git a/.gitignore b/.gitignore index 8a860b408..6be8a4a16 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,22 @@ -*~ -#* -*# -.#* -.classpath -.project +target/ .settings/ +.project +.classpath +*.orig .springBeans -target/ -bin/ -_site/ -.idea +.factorypath +.sts4-cache +.ant-targets-build.xml +src/ant/.ant-targets-upload-dist.xml +*.sonar4clipse* +.DS_Store *.iml *.ipr *.iws -.factorypath -*.log -.shelf -*.swp -*.swo -.vscode/ -.flattened-pom.xml - +/.idea/ +*.graphml +node +node_modules +build +package.json +package-lock.json diff --git a/.java-version b/.java-version deleted file mode 100644 index 98d9bcb75..000000000 --- a/.java-version +++ /dev/null @@ -1 +0,0 @@ -17 diff --git a/.mvn/maven.config b/.mvn/maven.config deleted file mode 100644 index 4b9372844..000000000 --- a/.mvn/maven.config +++ /dev/null @@ -1,2 +0,0 @@ --DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local --P spring diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 000000000..b901097f2 --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-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 + * + * http://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. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar index cb28b0e37c7d206feb564310fdeec0927af4123a..2cc7d4a55c0cd0092912bf49ae38b3a9e3fd0054 100644 GIT binary patch literal 50710 zcmbTd1CVCTmM+|7+wQV$+qP}n>auOywyU~q+qUhh+uxis_~*a##hm*_WW?9E7Pb7N%LRFiwbEGCJ0XP=%-6oeT$XZcYgtzC2~q zk(K08IQL8oTl}>>+hE5YRgXTB@fZ4TH9>7=79e`%%tw*SQUa9~$xKD5rS!;ZG@ocK zQdcH}JX?W|0_Afv?y`-NgLum62B&WSD$-w;O6G0Sm;SMX65z)l%m1e-g8Q$QTI;(Q z+x$xth4KFvH@Bs6(zn!iF#nenk^Y^ce;XIItAoCsow38eq?Y-Auh!1in#Rt-_D>H^ z=EjbclGGGa6VnaMGmMLj`x3NcwA43Jb(0gzl;RUIRAUDcR1~99l2SAPkVhoRMMtN} zXvC<tOmX83grD8GSo_Lo?%lNfhD#EBgPo z*nf@ppMC#B!T)Ae0RG$mlJWmGl7Cku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Ey1)Q~O}0qHRg4K_u>4e1arvJ7Q9!=t5AuzG`n=a-f0}{+lnCE#zu$`oVn44eS&T?N*wz~t~E&oQDBrB_MSg z_yVrQehWbD0xHX|v-hpselAu;O7s;P*!uAT`dr~}Lie=tknaGoiU?;*8Cwgala-65 zosOB4mATbdXJFujzgA4?UkCKE093A1KM?W&Pw>A?IACqg1z~IZYkdP70EeCfjii(n z3k%ax?4|rY(87N&_vhsyVK1zp@uils|B%`(V4e3%sj5f|i(eIhiSg-fHK1Pb0-mS^ zeh?WA7#{hhNci5e;?n*iVy|)iJiR>|8{TN3!=VBC2dN)~^ISSW_(g<^rHr$)nVrdA z39BMa5wl5q+5F@)4b%5-> zA^-P20l_e^S2PTa&HE2wf3jf)#)2ITVXzndeuMpPo8}kphQKhegB%QO+yBpDpgkcl z1nlPp14#+^bIA7__h16pMFECzKJ3p4`;Rf$gnr%{!5#oG42AH&X8hV8061%4W91ku z`OW_hyI+uBOqYXkVC&BqoKWmv;|{O|4d#Nay<)gkxBr^^N48(VDF7Sj#H1i3>9138 zkhxAU7;M)I18&d!Yw!V9zQA0tp(G4<8U5GX{YoYCQ?p56FxcD-2FwO5fqyx@__=$L zeK6Sg3>XQv)qz1?zW-k$_j`-)tf+yRU_%fXrenc>$^70d1Q-W?T#vy;6#Y-Q-<2)+ z5iTl6MA7j9m&oBhRXTKr*$3gec z3E;zX457RGZwUvD$l&8e42Qb^cbq>zYy@ive8`2N9vk=#6+AQlZZ7qk=?(ap1q0n0 z{B9Fte-{Gi-Tvax1)M+d1}Fyg@9X~sh1m|hsDcZuYOnxriBPN;z)q3<=-yBN2iM6V A?*IS* diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index ac184013f..642d572ce 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,18 +1,2 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 -# -# http://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. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/.sdkmanrc b/.sdkmanrc deleted file mode 100644 index 415f90832..000000000 --- a/.sdkmanrc +++ /dev/null @@ -1,3 +0,0 @@ -# Enable auto-env through the sdkman_auto_env config -# Add key=value pairs of SDKs to use below -java=17.0.1-tem diff --git a/.settings.xml b/.settings.xml deleted file mode 100644 index 03645e8ce..000000000 --- a/.settings.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - repo.spring.io - ${env.CI_DEPLOY_USERNAME} - ${env.CI_DEPLOY_PASSWORD} - - - - - - spring - - true - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - diff --git a/.springformat b/.springformat deleted file mode 100644 index e69de29bb..000000000 diff --git a/Guardfile b/Guardfile deleted file mode 100644 index d419ab250..000000000 --- a/Guardfile +++ /dev/null @@ -1,11 +0,0 @@ -require 'asciidoctor' -require 'erb' - -options = {:mkdirs => true, :safe => :unsafe, :attributes => ['linkcss', 'allow-uri-read']} - -guard 'shell' do - watch(/^docs\/[A-Z-a-z][^#]*\.adoc$/) {|m| - Asciidoctor.load_file('docs/src/main/asciidoc/README.adoc', :to_file => './README.adoc', safe: :safe, parse: false, attributes: 'allow-uri-read') - Asciidoctor.render_file('docs/src/main/asciidoc/spring-cloud-netflix.adoc', options.merge(:to_dir => 'target/generated-docs')) - } -end diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 62589edd1..000000000 --- a/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/README.adoc b/README.adoc index cb097fff2..77ed7a15f 100644 --- a/README.adoc +++ b/README.adoc @@ -1,360 +1,23 @@ -//// -DO NOT EDIT THIS FILE. IT WAS GENERATED. -Manual changes to this file will be lost when it is generated again. -Edit the files in the src/main/asciidoc/ directory instead. -//// += Spring Cloud Openfeign Docs Build +You're currently viewing the Antora playbook branch. +The playbook branch hosts the docs build that is used to build and publish the production docs site. -image::https://github.com/spring-cloud/spring-cloud-openfeign/workflows/Build/badge.svg?branch=main&style=svg["Build",link="https://github.com/spring-cloud/spring-cloud-openfeign/actions"] +The Spring Cloud Openfeign reference docs are built using https://antora.org[Antora]. +This README covers how to build the docs in a software branch as well as how to build the production docs site locally. -image:https://codecov.io/gh/spring-cloud/spring-cloud-openfeign/branch/main/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-openfeign"] +== Building the Site -image:https://api.codacy.com/project/badge/Grade/97b04c4e609c4b4f86b415e4437a6484["Codacy code quality", link="https://www.codacy.com/app/Spring-Cloud/spring-cloud-openfeign?utm_source=github.com&utm_medium=referral&utm_content=spring-cloud/spring-cloud-openfeign&utm_campaign=Badge_Grade"] +You can build the entire site by invoking the following on the docs-build branch and then viewing the site at `target/site/index.html` -:doctype: book -:idprefix: -:idseparator: - -:toc: left -:toclevels: 4 -:tabsize: 4 -:numbered: -:sectanchors: -:sectnums: -:icons: font -:hide-uri-scheme: -:docinfo: shared,private - -:sc-ext: java -:project-full-name: Spring Cloud OpenFeign -:all: {asterisk}{asterisk} - -:core_path: {project-root}/spring-cloud-openfeign-core - -This project provides OpenFeign integrations for Spring Boot apps through autoconfiguration -and binding to the Spring Environment and other Spring programming model idioms. - - -== Features - -* Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations - -== Building - - -:jdkversion: 17 - -=== Basic Compile and Test - -To build the source you will need to install JDK {jdkversion}. - -Spring Cloud uses Maven for most build-related activities, and you -should be able to get off the ground quite quickly by cloning the -project you are interested in and typing - ----- -$ ./mvnw install ----- - -NOTE: You can also install Maven (>=3.3.3) yourself and run the `mvn` command -in place of `./mvnw` in the examples below. If you do that you also -might need to add `-P spring` if your local Maven settings do not -contain repository declarations for spring pre-release artifacts. - -NOTE: Be aware that you might need to increase the amount of memory -available to Maven by setting a `MAVEN_OPTS` environment variable with -a value like `-Xmx512m -XX:MaxPermSize=128m`. We try to cover this in -the `.mvn` configuration, so if you find you have to do it to make a -build succeed, please raise a ticket to get the settings added to -source control. - -The projects that require middleware (i.e. Redis) for testing generally -require that a local instance of [Docker](https://www.docker.com/get-started) is installed and running. - - -=== Documentation - -The spring-cloud-build module has a "docs" profile, and if you switch -that on it will try to build asciidoc sources from -`src/main/asciidoc`. As part of that process it will look for a -`README.adoc` and process it by loading all the includes, but not -parsing or rendering it, just copying it to `${main.basedir}` -(defaults to `${basedir}`, i.e. the root of the project). If there are -any changes in the README it will then show up after a Maven build as -a modified file in the correct place. Just commit it and push the change. - -=== Working with the code -If you don't have an IDE preference we would recommend that you use -https://www.springsource.com/developer/sts[Spring Tools Suite] or -https://eclipse.org[Eclipse] when working with the code. We use the -https://eclipse.org/m2e/[m2eclipse] eclipse plugin for maven support. Other IDEs and tools -should also work without issue as long as they use Maven 3.3.3 or better. - -==== Activate the Spring Maven profile -Spring Cloud projects require the 'spring' Maven profile to be activated to resolve -the spring milestone and snapshot repositories. Use your preferred IDE to set this -profile to be active, or you may experience build errors. - -==== Importing into eclipse with m2eclipse -We recommend the https://eclipse.org/m2e/[m2eclipse] eclipse plugin when working with -eclipse. If you don't already have m2eclipse installed it is available from the "eclipse -marketplace". - -NOTE: Older versions of m2e do not support Maven 3.3, so once the -projects are imported into Eclipse you will also need to tell -m2eclipse to use the right profile for the projects. If you -see many different errors related to the POMs in the projects, check -that you have an up to date installation. If you can't upgrade m2e, -add the "spring" profile to your `settings.xml`. Alternatively you can -copy the repository settings from the "spring" profile of the parent -pom into your `settings.xml`. - -==== Importing into eclipse without m2eclipse -If you prefer not to use m2eclipse you can generate eclipse project metadata using the -following command: - -[indent=0] +[source,bash] ---- - $ ./mvnw eclipse:eclipse +./mvnw antora ---- -The generated eclipse projects can be imported by selecting `import existing projects` -from the `file` menu. - - - -== Contributing - -:spring-cloud-build-branch: master - -Spring Cloud is released under the non-restrictive Apache 2.0 license, -and follows a very standard Github development process, using Github -tracker for issues and merging pull requests into master. If you want -to contribute even something trivial please do not hesitate, but -follow the guidelines below. - -=== Sign the Contributor License Agreement -Before we accept a non-trivial patch or pull request we will need you to sign the -https://cla.pivotal.io/sign/spring[Contributor License Agreement]. -Signing the contributor's agreement does not grant anyone commit rights to the main -repository, but it does mean that we can accept your contributions, and you will get an -author credit if we do. Active contributors might be asked to join the core team, and -given the ability to merge pull requests. +== Building a Specific Branch -=== Code of Conduct -This project adheres to the Contributor Covenant https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc[code of -conduct]. By participating, you are expected to uphold this code. Please report -unacceptable behavior to spring-code-of-conduct@pivotal.io. - -=== Code Conventions and Housekeeping -None of these is essential for a pull request, but they will all help. They can also be -added after the original pull request but before a merge. - -* Use the Spring Framework code format conventions. If you use Eclipse - you can import formatter settings using the - `eclipse-code-formatter.xml` file from the - https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml[Spring - Cloud Build] project. If using IntelliJ, you can use the - https://plugins.jetbrains.com/plugin/6546[Eclipse Code Formatter - Plugin] to import the same file. -* Make sure all new `.java` files to have a simple Javadoc class comment with at least an - `@author` tag identifying you, and preferably at least a paragraph on what the class is - for. -* Add the ASF license header comment to all new `.java` files (copy from existing files - in the project) -* Add yourself as an `@author` to the .java files that you modify substantially (more - than cosmetic changes). -* Add some Javadocs and, if you change the namespace, some XSD doc elements. -* A few unit tests would help a lot as well -- someone has to do it. -* If no-one else is using your branch, please rebase it against the current master (or - other target branch in the main project). -* When writing a commit message please follow https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[these conventions], - if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit - message (where XXXX is the issue number). - -=== Checkstyle - -Spring Cloud Build comes with a set of checkstyle rules. You can find them in the `spring-cloud-build-tools` module. The most notable files under the module are: - -.spring-cloud-build-tools/ +[source,bash] ---- -└── src -    ├── checkstyle -    │   └── checkstyle-suppressions.xml <3> -    └── main -    └── resources -    ├── checkstyle-header.txt <2> -    └── checkstyle.xml <1> +./mvnw antora ---- -<1> Default Checkstyle rules -<2> File header setup -<3> Default suppression rules - -==== Checkstyle configuration - -Checkstyle rules are *disabled by default*. To add checkstyle to your project just define the following properties and plugins. - -.pom.xml ----- - -true <1> - true - <2> - true - <3> - - - - - <4> - io.spring.javaformat - spring-javaformat-maven-plugin - - <5> - org.apache.maven.plugins - maven-checkstyle-plugin - - - - - - <5> - org.apache.maven.plugins - maven-checkstyle-plugin - - - - ----- -<1> Fails the build upon Checkstyle errors -<2> Fails the build upon Checkstyle violations -<3> Checkstyle analyzes also the test sources -<4> Add the Spring Java Format plugin that will reformat your code to pass most of the Checkstyle formatting rules -<5> Add checkstyle plugin to your build and reporting phases - -If you need to suppress some rules (e.g. line length needs to be longer), then it's enough for you to define a file under `${project.root}/src/checkstyle/checkstyle-suppressions.xml` with your suppressions. Example: - -.projectRoot/src/checkstyle/checkstyle-suppresions.xml ----- - - - - - - ----- - -It's advisable to copy the `${spring-cloud-build.rootFolder}/.editorconfig` and `${spring-cloud-build.rootFolder}/.springformat` to your project. That way, some default formatting rules will be applied. You can do so by running this script: - -```bash -$ curl https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/.editorconfig -o .editorconfig -$ touch .springformat -``` - -=== IDE setup - -==== Intellij IDEA - -In order to setup Intellij you should import our coding conventions, inspection profiles and set up the checkstyle plugin. -The following files can be found in the https://github.com/spring-cloud/spring-cloud-build/tree/master/spring-cloud-build-tools[Spring Cloud Build] project. - -.spring-cloud-build-tools/ ----- -└── src -    ├── checkstyle -    │   └── checkstyle-suppressions.xml <3> -    └── main -    └── resources -    ├── checkstyle-header.txt <2> -    ├── checkstyle.xml <1> -    └── intellij -       ├── Intellij_Project_Defaults.xml <4> -       └── Intellij_Spring_Boot_Java_Conventions.xml <5> ----- -<1> Default Checkstyle rules -<2> File header setup -<3> Default suppression rules -<4> Project defaults for Intellij that apply most of Checkstyle rules -<5> Project style conventions for Intellij that apply most of Checkstyle rules - -.Code style - -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-code-style.png[Code style] - -Go to `File` -> `Settings` -> `Editor` -> `Code style`. There click on the icon next to the `Scheme` section. There, click on the `Import Scheme` value and pick the `Intellij IDEA code style XML` option. Import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Spring_Boot_Java_Conventions.xml` file. - -.Inspection profiles - -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-inspections.png[Code style] - -Go to `File` -> `Settings` -> `Editor` -> `Inspections`. There click on the icon next to the `Profile` section. There, click on the `Import Profile` and import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Project_Defaults.xml` file. - -.Checkstyle - -To have Intellij work with Checkstyle, you have to install the `Checkstyle` plugin. It's advisable to also install the `Assertions2Assertj` to automatically convert the JUnit assertions - -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-checkstyle.png[Checkstyle] - -Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on the `+` icon in the `Configuration file` section. There, you'll have to define where the checkstyle rules should be picked from. In the image above, we've picked the rules from the cloned Spring Cloud Build repository. However, you can point to the Spring Cloud Build's GitHub repository (e.g. for the `checkstyle.xml` : `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle.xml`). We need to provide the following variables: - -- `checkstyle.header.file` - please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` URL. -- `checkstyle.suppressions.file` - default suppressions. Please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL. -- `checkstyle.additional.suppressions.file` - this variable corresponds to suppressions in your local project. E.g. you're working on `spring-cloud-contract`. Then point to the `project-root/src/checkstyle/checkstyle-suppressions.xml` folder. Example for `spring-cloud-contract` would be: `/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml`. - -IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources. - -=== Duplicate Finder - -Spring Cloud Build brings along the `basepom:duplicate-finder-maven-plugin`, that enables flagging duplicate and conflicting classes and resources on the java classpath. - -==== Duplicate Finder configuration - -Duplicate finder is *enabled by default* and will run in the `verify` phase of your Maven build, but it will only take effect in your project if you add the `duplicate-finder-maven-plugin` to the `build` section of the projecst's `pom.xml`. - -.pom.xml -[source,xml] ----- - - - - org.basepom.maven - duplicate-finder-maven-plugin - - - ----- - -For other properties, we have set defaults as listed in the https://github.com/basepom/duplicate-finder-maven-plugin/wiki[plugin documentation]. - -You can easily override them but setting the value of the selected property prefixed with `duplicate-finder-maven-plugin`. For example, set `duplicate-finder-maven-plugin.skip` to `true` in order to skip duplicates check in your build. - -If you need to add `ignoredClassPatterns` or `ignoredResourcePatterns` to your setup, make sure to add them in the plugin configuration section of your project: - -[source,xml] ----- - - - - org.basepom.maven - duplicate-finder-maven-plugin - - - org.joda.time.base.BaseDateTime - .*module-info - - - changelog.txt - - - - - - - ----- - - -== License - -The project license file is available https://raw.githubusercontent.com/spring-cloud/spring-cloud-openfeign/main/LICENSE.txt[here]. diff --git a/docs/antora-playbook.yml b/antora-playbook.yml similarity index 61% rename from docs/antora-playbook.yml rename to antora-playbook.yml index 9a70e676c..8b69c6df1 100644 --- a/docs/antora-playbook.yml +++ b/antora-playbook.yml @@ -6,38 +6,39 @@ antora: - '@antora/collector-extension' - '@antora/atlas-extension' - require: '@springio/antora-extensions/root-component-extension' - root_component_name: 'PROJECT_WITHOUT_SPRING' - # FIXME: Run antora once using this extension to migrate to the Asciidoc Tabs syntax - # and then remove this extension - - require: '@springio/antora-extensions/tabs-migration-extension' - unwrap_example_block: always - save_result: true + root_component_name: 'cloud-openfeign' site: - title: PROJECT_FULL_NAME - url: https://docs.spring.io/PROJECT_NAME/reference/ + title: Spring Cloud Openfeign + url: https://docs.spring.io/spring-cloud-openfeign/reference + robots: allow +git: + ensure_git_suffix: false content: sources: - - url: ./.. - branches: HEAD + - url: https://github.com/spring-cloud/spring-cloud-openfeign + # Refname matching: + # https://docs.antora.org/antora/latest/playbook/content-refname-matching/ + branches: [ main ] + tags: [ '({4..9}).+({1..9}).+({0..9})?(-{RC,M}+({0..9}))', '!4.1.0-M1' ] start_path: docs - worktrees: true asciidoc: attributes: page-stackoverflow-url: https://stackoverflow.com/tags/spring-cloud page-pagination: '' hide-uri-scheme: '@' tabs-sync-option: '@' - chomp: 'all' extensions: - '@asciidoctor/tabs' - '@springio/asciidoctor-extensions' - sourcemap: true urls: + latest_version_segment_strategy: redirect:to latest_version_segment: '' + redirect_facility: httpd +ui: + bundle: + url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.3.5/ui-bundle.zip + snapshot: true runtime: log: failure_level: warn format: pretty -ui: - bundle: - url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.3.5/ui-bundle.zip diff --git a/asciidoctor.css b/asciidoctor.css deleted file mode 100644 index f592f50af..000000000 --- a/asciidoctor.css +++ /dev/null @@ -1,2011 +0,0 @@ -/* Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */ -/* Remove the comments around the @import statement below when using this as a custom stylesheet */ -/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic|Noto+Serif:400,400italic,700,700italic|Droid+Sans+Mono:400";*/ -article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary { - display: block -} - -audio, canvas, video { - display: inline-block -} - -audio:not([controls]) { - display: none; - height: 0 -} - -[hidden], template { - display: none -} - -script { - display: none !important -} - -html { - font-family: sans-serif; - -ms-text-size-adjust: 100%; - -webkit-text-size-adjust: 100% -} - -body { - margin: 0 -} - -a { - background: transparent -} - -a:focus { - outline: thin dotted -} - -a:active, a:hover { - outline: 0 -} - -h1 { - font-size: 2em; - margin: .67em 0 -} - -abbr[title] { - border-bottom: 1px dotted -} - -b, strong { - font-weight: bold -} - -dfn { - font-style: italic -} - -hr { - -moz-box-sizing: content-box; - box-sizing: content-box; - height: 0 -} - -mark { - background: #ff0; - color: #000 -} - -code, kbd, pre, samp { - font-family: monospace; - font-size: 1em -} - -pre { - white-space: pre-wrap -} - -q { - quotes: "\201C" "\201D" "\2018" "\2019" -} - -small { - font-size: 80% -} - -sub, sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline -} - -sup { - top: -.5em -} - -sub { - bottom: -.25em -} - -img { - border: 0 -} - -svg:not(:root) { - overflow: hidden -} - -figure { - margin: 0 -} - -fieldset { - border: 1px solid silver; - margin: 0 2px; - padding: .35em .625em .75em -} - -legend { - border: 0; - padding: 0 -} - -button, input, select, textarea { - font-family: inherit; - font-size: 100%; - margin: 0 -} - -button, input { - line-height: normal -} - -button, select { - text-transform: none -} - -button, html input[type="button"], input[type="reset"], input[type="submit"] { - -webkit-appearance: button; - cursor: pointer -} - -button[disabled], html input[disabled] { - cursor: default -} - -input[type="checkbox"], input[type="radio"] { - box-sizing: border-box; - padding: 0 -} - -input[type="search"] { - -webkit-appearance: textfield; - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; - box-sizing: content-box -} - -input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none -} - -button::-moz-focus-inner, input::-moz-focus-inner { - border: 0; - padding: 0 -} - -textarea { - overflow: auto; - vertical-align: top -} - -table { - border-collapse: collapse; - border-spacing: 0 -} - -*, *:before, *:after { - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - box-sizing: border-box -} - -html, body { - font-size: 100% -} - -body { - background: #fff; - color: rgba(0, 0, 0, .8); - padding: 0; - margin: 0; - font-family: "Noto Serif", "DejaVu Serif", serif; - font-weight: 400; - font-style: normal; - line-height: 1; - position: relative; - cursor: auto -} - -a:hover { - cursor: pointer -} - -img, object, embed { - max-width: 100%; - height: auto -} - -object, embed { - height: 100% -} - -img { - -ms-interpolation-mode: bicubic -} - -#map_canvas img, #map_canvas embed, #map_canvas object, .map_canvas img, .map_canvas embed, .map_canvas object { - max-width: none !important -} - -.left { - float: left !important -} - -.right { - float: right !important -} - -.text-left { - text-align: left !important -} - -.text-right { - text-align: right !important -} - -.text-center { - text-align: center !important -} - -.text-justify { - text-align: justify !important -} - -.hide { - display: none -} - -.antialiased, body { - -webkit-font-smoothing: antialiased -} - -img { - display: inline-block; - vertical-align: middle -} - -textarea { - height: auto; - min-height: 50px -} - -select { - width: 100% -} - -p.lead, .paragraph.lead > p, #preamble > .sectionbody > .paragraph:first-of-type p { - font-size: 1.21875em; - line-height: 1.6 -} - -.subheader, .admonitionblock td.content > .title, .audioblock > .title, .exampleblock > .title, .imageblock > .title, .listingblock > .title, .literalblock > .title, .stemblock > .title, .openblock > .title, .paragraph > .title, .quoteblock > .title, table.tableblock > .title, .verseblock > .title, .videoblock > .title, .dlist > .title, .olist > .title, .ulist > .title, .qlist > .title, .hdlist > .title { - line-height: 1.45; - color: #7a2518; - font-weight: 400; - margin-top: 0; - margin-bottom: .25em -} - -div, dl, dt, dd, ul, ol, li, h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6, pre, form, p, blockquote, th, td { - margin: 0; - padding: 0; - direction: ltr -} - -a { - color: #2156a5; - text-decoration: underline; - line-height: inherit -} - -a:hover, a:focus { - color: #1d4b8f -} - -a img { - border: none -} - -p { - font-family: inherit; - font-weight: 400; - font-size: 1em; - line-height: 1.6; - margin-bottom: 1.25em; - text-rendering: optimizeLegibility -} - -p aside { - font-size: .875em; - line-height: 1.35; - font-style: italic -} - -h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { - font-family: "Open Sans", "DejaVu Sans", sans-serif; - font-weight: 300; - font-style: normal; - color: #ba3925; - text-rendering: optimizeLegibility; - margin-top: 1em; - margin-bottom: .5em; - line-height: 1.0125em -} - -h1 small, h2 small, h3 small, #toctitle small, .sidebarblock > .content > .title small, h4 small, h5 small, h6 small { - font-size: 60%; - color: #e99b8f; - line-height: 0 -} - -h1 { - font-size: 2.125em -} - -h2 { - font-size: 1.6875em -} - -h3, #toctitle, .sidebarblock > .content > .title { - font-size: 1.375em -} - -h4, h5 { - font-size: 1.125em -} - -h6 { - font-size: 1em -} - -hr { - border: solid #ddddd8; - border-width: 1px 0 0; - clear: both; - margin: 1.25em 0 1.1875em; - height: 0 -} - -em, i { - font-style: italic; - line-height: inherit -} - -strong, b { - font-weight: bold; - line-height: inherit -} - -small { - font-size: 60%; - line-height: inherit -} - -code { - font-family: "Droid Sans Mono", "DejaVu Sans Mono", monospace; - font-weight: 400; - color: rgba(0, 0, 0, .9) -} - -ul, ol, dl { - font-size: 1em; - line-height: 1.6; - margin-bottom: 1.25em; - list-style-position: outside; - font-family: inherit -} - -ul, ol, ul.no-bullet, ol.no-bullet { - margin-left: 1.5em -} - -ul li ul, ul li ol { - margin-left: 1.25em; - margin-bottom: 0; - font-size: 1em -} - -ul.square li ul, ul.circle li ul, ul.disc li ul { - list-style: inherit -} - -ul.square { - list-style-type: square -} - -ul.circle { - list-style-type: circle -} - -ul.disc { - list-style-type: disc -} - -ul.no-bullet { - list-style: none -} - -ol li ul, ol li ol { - margin-left: 1.25em; - margin-bottom: 0 -} - -dl dt { - margin-bottom: .3125em; - font-weight: bold -} - -dl dd { - margin-bottom: 1.25em -} - -abbr, acronym { - text-transform: uppercase; - font-size: 90%; - color: rgba(0, 0, 0, .8); - border-bottom: 1px dotted #ddd; - cursor: help -} - -abbr { - text-transform: none -} - -blockquote { - margin: 0 0 1.25em; - padding: .5625em 1.25em 0 1.1875em; - border-left: 1px solid #ddd -} - -blockquote cite { - display: block; - font-size: .9375em; - color: rgba(0, 0, 0, .6) -} - -blockquote cite:before { - content: "\2014 \0020" -} - -blockquote cite a, blockquote cite a:visited { - color: rgba(0, 0, 0, .6) -} - -blockquote, blockquote p { - line-height: 1.6; - color: rgba(0, 0, 0, .85) -} - -@media only screen and (min-width: 768px) { - h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { - line-height: 1.2 - } - - h1 { - font-size: 2.75em - } - - h2 { - font-size: 2.3125em - } - - h3, #toctitle, .sidebarblock > .content > .title { - font-size: 1.6875em - } - - h4 { - font-size: 1.4375em - } -} - -table { - background: #fff; - margin-bottom: 1.25em; - border: solid 1px #dedede -} - -table thead, table tfoot { - background: #f7f8f7; - font-weight: bold -} - -table thead tr th, table thead tr td, table tfoot tr th, table tfoot tr td { - padding: .5em .625em .625em; - font-size: inherit; - color: rgba(0, 0, 0, .8); - text-align: left -} - -table tr th, table tr td { - padding: .5625em .625em; - font-size: inherit; - color: rgba(0, 0, 0, .8) -} - -table tr.even, table tr.alt, table tr:nth-of-type(even) { - background: #f8f8f7 -} - -table thead tr th, table tfoot tr th, table tbody tr td, table tr td, table tfoot tr td { - display: table-cell; - line-height: 1.6 -} - -h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { - line-height: 1.2; - word-spacing: -.05em -} - -h1 strong, h2 strong, h3 strong, #toctitle strong, .sidebarblock > .content > .title strong, h4 strong, h5 strong, h6 strong { - font-weight: 400 -} - -.clearfix:before, .clearfix:after, .float-group:before, .float-group:after { - content: " "; - display: table -} - -.clearfix:after, .float-group:after { - clear: both -} - -*:not(pre) > code { - font-size: .9375em; - font-style: normal !important; - letter-spacing: 0; - padding: .1em .5ex; - word-spacing: -.15em; - background-color: #f7f7f8; - -webkit-border-radius: 4px; - border-radius: 4px; - line-height: 1.45; - text-rendering: optimizeSpeed -} - -pre, pre > code { - line-height: 1.45; - color: rgba(0, 0, 0, .9); - font-family: "Droid Sans Mono", "DejaVu Sans Mono", monospace; - font-weight: 400; - text-rendering: optimizeSpeed -} - -.keyseq { - color: rgba(51, 51, 51, .8) -} - -kbd { - display: inline-block; - color: rgba(0, 0, 0, .8); - font-size: .75em; - line-height: 1.4; - background-color: #f7f7f7; - border: 1px solid #ccc; - -webkit-border-radius: 3px; - border-radius: 3px; - -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 0 0 .1em white inset; - box-shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 0 0 .1em #fff inset; - margin: -.15em .15em 0 .15em; - padding: .2em .6em .2em .5em; - vertical-align: middle; - white-space: nowrap -} - -.keyseq kbd:first-child { - margin-left: 0 -} - -.keyseq kbd:last-child { - margin-right: 0 -} - -.menuseq, .menu { - color: rgba(0, 0, 0, .8) -} - -b.button:before, b.button:after { - position: relative; - top: -1px; - font-weight: 400 -} - -b.button:before { - content: "["; - padding: 0 3px 0 2px -} - -b.button:after { - content: "]"; - padding: 0 2px 0 3px -} - -p a > code:hover { - color: rgba(0, 0, 0, .9) -} - -#header, #content, #footnotes, #footer { - width: 100%; - margin-left: auto; - margin-right: auto; - margin-top: 0; - margin-bottom: 0; - max-width: 62.5em; - *zoom: 1; - position: relative; - padding-left: .9375em; - padding-right: .9375em -} - -#header:before, #header:after, #content:before, #content:after, #footnotes:before, #footnotes:after, #footer:before, #footer:after { - content: " "; - display: table -} - -#header:after, #content:after, #footnotes:after, #footer:after { - clear: both -} - -#content { - margin-top: 1.25em -} - -#content:before { - content: none -} - -#header > h1:first-child { - color: rgba(0, 0, 0, .85); - margin-top: 2.25rem; - margin-bottom: 0 -} - -#header > h1:first-child + #toc { - margin-top: 8px; - border-top: 1px solid #ddddd8 -} - -#header > h1:only-child, body.toc2 #header > h1:nth-last-child(2) { - border-bottom: 1px solid #ddddd8; - padding-bottom: 8px -} - -#header .details { - border-bottom: 1px solid #ddddd8; - line-height: 1.45; - padding-top: .25em; - padding-bottom: .25em; - padding-left: .25em; - color: rgba(0, 0, 0, .6); - display: -ms-flexbox; - display: -webkit-flex; - display: flex; - -ms-flex-flow: row wrap; - -webkit-flex-flow: row wrap; - flex-flow: row wrap -} - -#header .details span:first-child { - margin-left: -.125em -} - -#header .details span.email a { - color: rgba(0, 0, 0, .85) -} - -#header .details br { - display: none -} - -#header .details br + span:before { - content: "\00a0\2013\00a0" -} - -#header .details br + span.author:before { - content: "\00a0\22c5\00a0"; - color: rgba(0, 0, 0, .85) -} - -#header .details br + span#revremark:before { - content: "\00a0|\00a0" -} - -#header #revnumber { - text-transform: capitalize -} - -#header #revnumber:after { - content: "\00a0" -} - -#content > h1:first-child:not([class]) { - color: rgba(0, 0, 0, .85); - border-bottom: 1px solid #ddddd8; - padding-bottom: 8px; - margin-top: 0; - padding-top: 1rem; - margin-bottom: 1.25rem -} - -#toc { - border-bottom: 1px solid #efefed; - padding-bottom: .5em -} - -#toc > ul { - margin-left: .125em -} - -#toc ul.sectlevel0 > li > a { - font-style: italic -} - -#toc ul.sectlevel0 ul.sectlevel1 { - margin: .5em 0 -} - -#toc ul { - font-family: "Open Sans", "DejaVu Sans", sans-serif; - list-style-type: none -} - -#toc a { - text-decoration: none -} - -#toc a:active { - text-decoration: underline -} - -#toctitle { - color: #7a2518; - font-size: 1.2em -} - -@media only screen and (min-width: 768px) { - #toctitle { - font-size: 1.375em - } - - body.toc2 { - padding-left: 15em; - padding-right: 0 - } - - #toc.toc2 { - margin-top: 0 !important; - background-color: #f8f8f7; - position: fixed; - width: 15em; - left: 0; - top: 0; - border-right: 1px solid #efefed; - border-top-width: 0 !important; - border-bottom-width: 0 !important; - z-index: 1000; - padding: 1.25em 1em; - height: 100%; - overflow: auto - } - - #toc.toc2 #toctitle { - margin-top: 0; - font-size: 1.2em - } - - #toc.toc2 > ul { - font-size: .9em; - margin-bottom: 0 - } - - #toc.toc2 ul ul { - margin-left: 0; - padding-left: 1em - } - - #toc.toc2 ul.sectlevel0 ul.sectlevel1 { - padding-left: 0; - margin-top: .5em; - margin-bottom: .5em - } - - body.toc2.toc-right { - padding-left: 0; - padding-right: 15em - } - - body.toc2.toc-right #toc.toc2 { - border-right-width: 0; - border-left: 1px solid #efefed; - left: auto; - right: 0 - } -} - -@media only screen and (min-width: 1280px) { - body.toc2 { - padding-left: 20em; - padding-right: 0 - } - - #toc.toc2 { - width: 20em - } - - #toc.toc2 #toctitle { - font-size: 1.375em - } - - #toc.toc2 > ul { - font-size: .95em - } - - #toc.toc2 ul ul { - padding-left: 1.25em - } - - body.toc2.toc-right { - padding-left: 0; - padding-right: 20em - } -} - -#content #toc { - border-style: solid; - border-width: 1px; - border-color: #e0e0dc; - margin-bottom: 1.25em; - padding: 1.25em; - background: #f8f8f7; - -webkit-border-radius: 4px; - border-radius: 4px -} - -#content #toc > :first-child { - margin-top: 0 -} - -#content #toc > :last-child { - margin-bottom: 0 -} - -#footer { - max-width: 100%; - background-color: rgba(0, 0, 0, .8); - padding: 1.25em -} - -#footer-text { - color: rgba(255, 255, 255, .8); - line-height: 1.44 -} - -.sect1 { - padding-bottom: .625em -} - -@media only screen and (min-width: 768px) { - .sect1 { - padding-bottom: 1.25em - } -} - -.sect1 + .sect1 { - border-top: 1px solid #efefed -} - -#content h1 > a.anchor, h2 > a.anchor, h3 > a.anchor, #toctitle > a.anchor, .sidebarblock > .content > .title > a.anchor, h4 > a.anchor, h5 > a.anchor, h6 > a.anchor { - position: absolute; - z-index: 1001; - width: 1.5ex; - margin-left: -1.5ex; - display: block; - text-decoration: none !important; - visibility: hidden; - text-align: center; - font-weight: 400 -} - -#content h1 > a.anchor:before, h2 > a.anchor:before, h3 > a.anchor:before, #toctitle > a.anchor:before, .sidebarblock > .content > .title > a.anchor:before, h4 > a.anchor:before, h5 > a.anchor:before, h6 > a.anchor:before { - content: "\00A7"; - font-size: .85em; - display: block; - padding-top: .1em -} - -#content h1:hover > a.anchor, #content h1 > a.anchor:hover, h2:hover > a.anchor, h2 > a.anchor:hover, h3:hover > a.anchor, #toctitle:hover > a.anchor, .sidebarblock > .content > .title:hover > a.anchor, h3 > a.anchor:hover, #toctitle > a.anchor:hover, .sidebarblock > .content > .title > a.anchor:hover, h4:hover > a.anchor, h4 > a.anchor:hover, h5:hover > a.anchor, h5 > a.anchor:hover, h6:hover > a.anchor, h6 > a.anchor:hover { - visibility: visible -} - -#content h1 > a.link, h2 > a.link, h3 > a.link, #toctitle > a.link, .sidebarblock > .content > .title > a.link, h4 > a.link, h5 > a.link, h6 > a.link { - color: #ba3925; - text-decoration: none -} - -#content h1 > a.link:hover, h2 > a.link:hover, h3 > a.link:hover, #toctitle > a.link:hover, .sidebarblock > .content > .title > a.link:hover, h4 > a.link:hover, h5 > a.link:hover, h6 > a.link:hover { - color: #a53221 -} - -.audioblock, .imageblock, .literalblock, .listingblock, .stemblock, .videoblock { - margin-bottom: 1.25em -} - -.admonitionblock td.content > .title, .audioblock > .title, .exampleblock > .title, .imageblock > .title, .listingblock > .title, .literalblock > .title, .stemblock > .title, .openblock > .title, .paragraph > .title, .quoteblock > .title, table.tableblock > .title, .verseblock > .title, .videoblock > .title, .dlist > .title, .olist > .title, .ulist > .title, .qlist > .title, .hdlist > .title { - text-rendering: optimizeLegibility; - text-align: left; - font-family: "Noto Serif", "DejaVu Serif", serif; - font-size: 1rem; - font-style: italic -} - -table.tableblock > caption.title { - white-space: nowrap; - overflow: visible; - max-width: 0 -} - -.paragraph.lead > p, #preamble > .sectionbody > .paragraph:first-of-type p { - color: rgba(0, 0, 0, .85) -} - -table.tableblock #preamble > .sectionbody > .paragraph:first-of-type p { - font-size: inherit -} - -.admonitionblock > table { - border-collapse: separate; - border: 0; - background: none; - width: 100% -} - -.admonitionblock > table td.icon { - text-align: center; - width: 80px -} - -.admonitionblock > table td.icon img { - max-width: none -} - -.admonitionblock > table td.icon .title { - font-weight: bold; - font-family: "Open Sans", "DejaVu Sans", sans-serif; - text-transform: uppercase -} - -.admonitionblock > table td.content { - padding-left: 1.125em; - padding-right: 1.25em; - border-left: 1px solid #ddddd8; - color: rgba(0, 0, 0, .6) -} - -.admonitionblock > table td.content > :last-child > :last-child { - margin-bottom: 0 -} - -.exampleblock > .content { - border-style: solid; - border-width: 1px; - border-color: #e6e6e6; - margin-bottom: 1.25em; - padding: 1.25em; - background: #fff; - -webkit-border-radius: 4px; - border-radius: 4px -} - -.exampleblock > .content > :first-child { - margin-top: 0 -} - -.exampleblock > .content > :last-child { - margin-bottom: 0 -} - -.sidebarblock { - border-style: solid; - border-width: 1px; - border-color: #e0e0dc; - margin-bottom: 1.25em; - padding: 1.25em; - background: #f8f8f7; - -webkit-border-radius: 4px; - border-radius: 4px -} - -.sidebarblock > :first-child { - margin-top: 0 -} - -.sidebarblock > :last-child { - margin-bottom: 0 -} - -.sidebarblock > .content > .title { - color: #7a2518; - margin-top: 0; - text-align: center -} - -.exampleblock > .content > :last-child > :last-child, .exampleblock > .content .olist > ol > li:last-child > :last-child, .exampleblock > .content .ulist > ul > li:last-child > :last-child, .exampleblock > .content .qlist > ol > li:last-child > :last-child, .sidebarblock > .content > :last-child > :last-child, .sidebarblock > .content .olist > ol > li:last-child > :last-child, .sidebarblock > .content .ulist > ul > li:last-child > :last-child, .sidebarblock > .content .qlist > ol > li:last-child > :last-child { - margin-bottom: 0 -} - -.literalblock pre, .listingblock pre:not(.highlight), .listingblock pre[class="highlight"], .listingblock pre[class^="highlight "], .listingblock pre.CodeRay, .listingblock pre.prettyprint { - background: #f7f7f8 -} - -.sidebarblock .literalblock pre, .sidebarblock .listingblock pre:not(.highlight), .sidebarblock .listingblock pre[class="highlight"], .sidebarblock .listingblock pre[class^="highlight "], .sidebarblock .listingblock pre.CodeRay, .sidebarblock .listingblock pre.prettyprint { - background: #f2f1f1 -} - -.literalblock pre, .literalblock pre[class], .listingblock pre, .listingblock pre[class] { - -webkit-border-radius: 4px; - border-radius: 4px; - word-wrap: break-word; - padding: 1em; - font-size: .8125em -} - -.literalblock pre.nowrap, .literalblock pre[class].nowrap, .listingblock pre.nowrap, .listingblock pre[class].nowrap { - overflow-x: auto; - white-space: pre; - word-wrap: normal -} - -@media only screen and (min-width: 768px) { - .literalblock pre, .literalblock pre[class], .listingblock pre, .listingblock pre[class] { - font-size: .90625em - } -} - -@media only screen and (min-width: 1280px) { - .literalblock pre, .literalblock pre[class], .listingblock pre, .listingblock pre[class] { - font-size: 1em - } -} - -.literalblock.output pre { - color: #f7f7f8; - background-color: rgba(0, 0, 0, .9) -} - -.listingblock pre.highlightjs { - padding: 0 -} - -.listingblock pre.highlightjs > code { - padding: 1em; - -webkit-border-radius: 4px; - border-radius: 4px -} - -.listingblock pre.prettyprint { - border-width: 0 -} - -.listingblock > .content { - position: relative -} - -.listingblock code[data-lang]:before { - display: none; - content: attr(data-lang); - position: absolute; - font-size: .75em; - top: .425rem; - right: .5rem; - line-height: 1; - text-transform: uppercase; - color: #999 -} - -.listingblock:hover code[data-lang]:before { - display: block -} - -.listingblock.terminal pre .command:before { - content: attr(data-prompt); - padding-right: .5em; - color: #999 -} - -.listingblock.terminal pre .command:not([data-prompt]):before { - content: "$" -} - -table.pyhltable { - border-collapse: separate; - border: 0; - margin-bottom: 0; - background: none -} - -table.pyhltable td { - vertical-align: top; - padding-top: 0; - padding-bottom: 0 -} - -table.pyhltable td.code { - padding-left: .75em; - padding-right: 0 -} - -pre.pygments .lineno, table.pyhltable td:not(.code) { - color: #999; - padding-left: 0; - padding-right: .5em; - border-right: 1px solid #ddddd8 -} - -pre.pygments .lineno { - display: inline-block; - margin-right: .25em -} - -table.pyhltable .linenodiv { - background: none !important; - padding-right: 0 !important -} - -.quoteblock { - margin: 0 1em 1.25em 1.5em; - display: table -} - -.quoteblock > .title { - margin-left: -1.5em; - margin-bottom: .75em -} - -.quoteblock blockquote, .quoteblock blockquote p { - color: rgba(0, 0, 0, .85); - font-size: 1.15rem; - line-height: 1.75; - word-spacing: .1em; - letter-spacing: 0; - font-style: italic; - text-align: justify -} - -.quoteblock blockquote { - margin: 0; - padding: 0; - border: 0 -} - -.quoteblock blockquote:before { - content: "\201c"; - float: left; - font-size: 2.75em; - font-weight: bold; - line-height: .6em; - margin-left: -.6em; - color: #7a2518; - text-shadow: 0 1px 2px rgba(0, 0, 0, .1) -} - -.quoteblock blockquote > .paragraph:last-child p { - margin-bottom: 0 -} - -.quoteblock .attribution { - margin-top: .5em; - margin-right: .5ex; - text-align: right -} - -.quoteblock .quoteblock { - margin-left: 0; - margin-right: 0; - padding: .5em 0; - border-left: 3px solid rgba(0, 0, 0, .6) -} - -.quoteblock .quoteblock blockquote { - padding: 0 0 0 .75em -} - -.quoteblock .quoteblock blockquote:before { - display: none -} - -.verseblock { - margin: 0 1em 1.25em 1em -} - -.verseblock pre { - font-family: "Open Sans", "DejaVu Sans", sans; - font-size: 1.15rem; - color: rgba(0, 0, 0, .85); - font-weight: 300; - text-rendering: optimizeLegibility -} - -.verseblock pre strong { - font-weight: 400 -} - -.verseblock .attribution { - margin-top: 1.25rem; - margin-left: .5ex -} - -.quoteblock .attribution, .verseblock .attribution { - font-size: .9375em; - line-height: 1.45; - font-style: italic -} - -.quoteblock .attribution br, .verseblock .attribution br { - display: none -} - -.quoteblock .attribution cite, .verseblock .attribution cite { - display: block; - letter-spacing: -.05em; - color: rgba(0, 0, 0, .6) -} - -.quoteblock.abstract { - margin: 0 0 1.25em 0; - display: block -} - -.quoteblock.abstract blockquote, .quoteblock.abstract blockquote p { - text-align: left; - word-spacing: 0 -} - -.quoteblock.abstract blockquote:before, .quoteblock.abstract blockquote p:first-of-type:before { - display: none -} - -table.tableblock { - max-width: 100%; - border-collapse: separate -} - -table.tableblock td > .paragraph:last-child p > p:last-child, table.tableblock th > p:last-child, table.tableblock td > p:last-child { - margin-bottom: 0 -} - -table.spread { - width: 100% -} - -table.tableblock, th.tableblock, td.tableblock { - border: 0 solid #dedede -} - -table.grid-all th.tableblock, table.grid-all td.tableblock { - border-width: 0 1px 1px 0 -} - -table.grid-all tfoot > tr > th.tableblock, table.grid-all tfoot > tr > td.tableblock { - border-width: 1px 1px 0 0 -} - -table.grid-cols th.tableblock, table.grid-cols td.tableblock { - border-width: 0 1px 0 0 -} - -table.grid-all * > tr > .tableblock:last-child, table.grid-cols * > tr > .tableblock:last-child { - border-right-width: 0 -} - -table.grid-rows th.tableblock, table.grid-rows td.tableblock { - border-width: 0 0 1px 0 -} - -table.grid-all tbody > tr:last-child > th.tableblock, table.grid-all tbody > tr:last-child > td.tableblock, table.grid-all thead:last-child > tr > th.tableblock, table.grid-rows tbody > tr:last-child > th.tableblock, table.grid-rows tbody > tr:last-child > td.tableblock, table.grid-rows thead:last-child > tr > th.tableblock { - border-bottom-width: 0 -} - -table.grid-rows tfoot > tr > th.tableblock, table.grid-rows tfoot > tr > td.tableblock { - border-width: 1px 0 0 0 -} - -table.frame-all { - border-width: 1px -} - -table.frame-sides { - border-width: 0 1px -} - -table.frame-topbot { - border-width: 1px 0 -} - -th.halign-left, td.halign-left { - text-align: left -} - -th.halign-right, td.halign-right { - text-align: right -} - -th.halign-center, td.halign-center { - text-align: center -} - -th.valign-top, td.valign-top { - vertical-align: top -} - -th.valign-bottom, td.valign-bottom { - vertical-align: bottom -} - -th.valign-middle, td.valign-middle { - vertical-align: middle -} - -table thead th, table tfoot th { - font-weight: bold -} - -tbody tr th { - display: table-cell; - line-height: 1.6; - background: #f7f8f7 -} - -tbody tr th, tbody tr th p, tfoot tr th, tfoot tr th p { - color: rgba(0, 0, 0, .8); - font-weight: bold -} - -p.tableblock > code:only-child { - background: none; - padding: 0 -} - -p.tableblock { - font-size: 1em -} - -td > div.verse { - white-space: pre -} - -ol { - margin-left: 1.75em -} - -ul li ol { - margin-left: 1.5em -} - -dl dd { - margin-left: 1.125em -} - -dl dd:last-child, dl dd:last-child > :last-child { - margin-bottom: 0 -} - -ol > li p, ul > li p, ul dd, ol dd, .olist .olist, .ulist .ulist, .ulist .olist, .olist .ulist { - margin-bottom: .625em -} - -ul.unstyled, ol.unnumbered, ul.checklist, ul.none { - list-style-type: none -} - -ul.unstyled, ol.unnumbered, ul.checklist { - margin-left: .625em -} - -ul.checklist li > p:first-child > .fa-check-square-o:first-child, ul.checklist li > p:first-child > input[type="checkbox"]:first-child { - margin-right: .25em -} - -ul.checklist li > p:first-child > input[type="checkbox"]:first-child { - position: relative; - top: 1px -} - -ul.inline { - margin: 0 auto .625em auto; - margin-left: -1.375em; - margin-right: 0; - padding: 0; - list-style: none; - overflow: hidden -} - -ul.inline > li { - list-style: none; - float: left; - margin-left: 1.375em; - display: block -} - -ul.inline > li > * { - display: block -} - -.unstyled dl dt { - font-weight: 400; - font-style: normal -} - -ol.arabic { - list-style-type: decimal -} - -ol.decimal { - list-style-type: decimal-leading-zero -} - -ol.loweralpha { - list-style-type: lower-alpha -} - -ol.upperalpha { - list-style-type: upper-alpha -} - -ol.lowerroman { - list-style-type: lower-roman -} - -ol.upperroman { - list-style-type: upper-roman -} - -ol.lowergreek { - list-style-type: lower-greek -} - -.hdlist > table, .colist > table { - border: 0; - background: none -} - -.hdlist > table > tbody > tr, .colist > table > tbody > tr { - background: none -} - -td.hdlist1 { - padding-right: .75em; - font-weight: bold -} - -td.hdlist1, td.hdlist2 { - vertical-align: top -} - -.literalblock + .colist, .listingblock + .colist { - margin-top: -.5em -} - -.colist > table tr > td:first-of-type { - padding: 0 .75em; - line-height: 1 -} - -.colist > table tr > td:last-of-type { - padding: .25em 0 -} - -.thumb, .th { - line-height: 0; - display: inline-block; - border: solid 4px #fff; - -webkit-box-shadow: 0 0 0 1px #ddd; - box-shadow: 0 0 0 1px #ddd -} - -.imageblock.left, .imageblock[style*="float: left"] { - margin: .25em .625em 1.25em 0 -} - -.imageblock.right, .imageblock[style*="float: right"] { - margin: .25em 0 1.25em .625em -} - -.imageblock > .title { - margin-bottom: 0 -} - -.imageblock.thumb, .imageblock.th { - border-width: 6px -} - -.imageblock.thumb > .title, .imageblock.th > .title { - padding: 0 .125em -} - -.image.left, .image.right { - margin-top: .25em; - margin-bottom: .25em; - display: inline-block; - line-height: 0 -} - -.image.left { - margin-right: .625em -} - -.image.right { - margin-left: .625em -} - -a.image { - text-decoration: none -} - -span.footnote, span.footnoteref { - vertical-align: super; - font-size: .875em -} - -span.footnote a, span.footnoteref a { - text-decoration: none -} - -span.footnote a:active, span.footnoteref a:active { - text-decoration: underline -} - -#footnotes { - padding-top: .75em; - padding-bottom: .75em; - margin-bottom: .625em -} - -#footnotes hr { - width: 20%; - min-width: 6.25em; - margin: -.25em 0 .75em 0; - border-width: 1px 0 0 0 -} - -#footnotes .footnote { - padding: 0 .375em; - line-height: 1.3; - font-size: .875em; - margin-left: 1.2em; - text-indent: -1.2em; - margin-bottom: .2em -} - -#footnotes .footnote a:first-of-type { - font-weight: bold; - text-decoration: none -} - -#footnotes .footnote:last-of-type { - margin-bottom: 0 -} - -#content #footnotes { - margin-top: -.625em; - margin-bottom: 0; - padding: .75em 0 -} - -.gist .file-data > table { - border: 0; - background: #fff; - width: 100%; - margin-bottom: 0 -} - -.gist .file-data > table td.line-data { - width: 99% -} - -div.unbreakable { - page-break-inside: avoid -} - -.big { - font-size: larger -} - -.small { - font-size: smaller -} - -.underline { - text-decoration: underline -} - -.overline { - text-decoration: overline -} - -.line-through { - text-decoration: line-through -} - -.aqua { - color: #00bfbf -} - -.aqua-background { - background-color: #00fafa -} - -.black { - color: #000 -} - -.black-background { - background-color: #000 -} - -.blue { - color: #0000bf -} - -.blue-background { - background-color: #0000fa -} - -.fuchsia { - color: #bf00bf -} - -.fuchsia-background { - background-color: #fa00fa -} - -.gray { - color: #606060 -} - -.gray-background { - background-color: #7d7d7d -} - -.green { - color: #006000 -} - -.green-background { - background-color: #007d00 -} - -.lime { - color: #00bf00 -} - -.lime-background { - background-color: #00fa00 -} - -.maroon { - color: #600000 -} - -.maroon-background { - background-color: #7d0000 -} - -.navy { - color: #000060 -} - -.navy-background { - background-color: #00007d -} - -.olive { - color: #606000 -} - -.olive-background { - background-color: #7d7d00 -} - -.purple { - color: #600060 -} - -.purple-background { - background-color: #7d007d -} - -.red { - color: #bf0000 -} - -.red-background { - background-color: #fa0000 -} - -.silver { - color: #909090 -} - -.silver-background { - background-color: #bcbcbc -} - -.teal { - color: #006060 -} - -.teal-background { - background-color: #007d7d -} - -.white { - color: #bfbfbf -} - -.white-background { - background-color: #fafafa -} - -.yellow { - color: #bfbf00 -} - -.yellow-background { - background-color: #fafa00 -} - -span.icon > .fa { - cursor: default -} - -.admonitionblock td.icon [class^="fa icon-"] { - font-size: 2.5em; - text-shadow: 1px 1px 2px rgba(0, 0, 0, .5); - cursor: default -} - -.admonitionblock td.icon .icon-note:before { - content: "\f05a"; - color: #19407c -} - -.admonitionblock td.icon .icon-tip:before { - content: "\f0eb"; - text-shadow: 1px 1px 2px rgba(155, 155, 0, .8); - color: #111 -} - -.admonitionblock td.icon .icon-warning:before { - content: "\f071"; - color: #bf6900 -} - -.admonitionblock td.icon .icon-caution:before { - content: "\f06d"; - color: #bf3400 -} - -.admonitionblock td.icon .icon-important:before { - content: "\f06a"; - color: #bf0000 -} - -.conum[data-value] { - display: inline-block; - color: #fff !important; - background-color: rgba(0, 0, 0, .8); - -webkit-border-radius: 100px; - border-radius: 100px; - text-align: center; - font-size: .75em; - width: 1.67em; - height: 1.67em; - line-height: 1.67em; - font-family: "Open Sans", "DejaVu Sans", sans-serif; - font-style: normal; - font-weight: bold -} - -.conum[data-value] * { - color: #fff !important -} - -.conum[data-value] + b { - display: none -} - -.conum[data-value]:after { - content: attr(data-value) -} - -pre .conum[data-value] { - position: relative; - top: -.125em -} - -b.conum * { - color: inherit !important -} - -.conum:not([data-value]):empty { - display: none -} - -h1, h2 { - letter-spacing: -.01em -} - -dt, th.tableblock, td.content { - text-rendering: optimizeLegibility -} - -p, td.content { - letter-spacing: -.01em -} - -p strong, td.content strong { - letter-spacing: -.005em -} - -p, blockquote, dt, td.content { - font-size: 1.0625rem -} - -p { - margin-bottom: 1.25rem -} - -.sidebarblock p, .sidebarblock dt, .sidebarblock td.content, p.tableblock { - font-size: 1em -} - -.exampleblock > .content { - background-color: #fffef7; - border-color: #e0e0dc; - -webkit-box-shadow: 0 1px 4px #e0e0dc; - box-shadow: 0 1px 4px #e0e0dc -} - -.print-only { - display: none !important -} - -@media print { - @page { - margin: 1.25cm .75cm - } - - * { - -webkit-box-shadow: none !important; - box-shadow: none !important; - text-shadow: none !important - } - - a { - color: inherit !important; - text-decoration: underline !important - } - - a.bare, a[href^="#"], a[href^="mailto:"] { - text-decoration: none !important - } - - a[href^="http:"]:not(.bare):after, a[href^="https:"]:not(.bare):after { - content: "(" attr(href) ")"; - display: inline-block; - font-size: .875em; - padding-left: .25em - } - - abbr[title]:after { - content: " (" attr(title) ")" - } - - pre, blockquote, tr, img { - page-break-inside: avoid - } - - thead { - display: table-header-group - } - - img { - max-width: 100% !important - } - - p, blockquote, dt, td.content { - font-size: 1em; - orphans: 3; - widows: 3 - } - - h2, h3, #toctitle, .sidebarblock > .content > .title { - page-break-after: avoid - } - - #toc, .sidebarblock, .exampleblock > .content { - background: none !important - } - - #toc { - border-bottom: 1px solid #ddddd8 !important; - padding-bottom: 0 !important - } - - .sect1 { - padding-bottom: 0 !important - } - - .sect1 + .sect1 { - border: 0 !important - } - - #header > h1:first-child { - margin-top: 1.25rem - } - - body.book #header { - text-align: center - } - - body.book #header > h1:first-child { - border: 0 !important; - margin: 2.5em 0 1em 0 - } - - body.book #header .details { - border: 0 !important; - display: block; - padding: 0 !important - } - - body.book #header .details span:first-child { - margin-left: 0 !important - } - - body.book #header .details br { - display: block - } - - body.book #header .details br + span:before { - content: none !important - } - - body.book #toc { - border: 0 !important; - text-align: left !important; - padding: 0 !important; - margin: 0 !important - } - - body.book #toc, body.book #preamble, body.book h1.sect0, body.book .sect1 > h2 { - page-break-before: always - } - - .listingblock code[data-lang]:before { - display: block - } - - #footer { - background: none !important; - padding: 0 .9375em - } - - #footer-text { - color: rgba(0, 0, 0, .6) !important; - font-size: .9em - } - - .hide-on-print { - display: none !important - } - - .print-only { - display: block !important - } - - .hide-for-print { - display: none !important - } - - .show-for-print { - display: inherit !important - } -} diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index 765e05d29..000000000 --- a/codecov.yml +++ /dev/null @@ -1,7 +0,0 @@ -comment: - layout: "reach, diff, flags, files" - behavior: default - require_changes: false # if true: only post the comment if coverage changes - require_base: no # [yes :: must have a base report to post] - require_head: yes # [yes :: must have a head report to post] - branches: null diff --git a/docs/.flattened-pom.xml b/docs/.flattened-pom.xml new file mode 100644 index 000000000..1f264c617 --- /dev/null +++ b/docs/.flattened-pom.xml @@ -0,0 +1,106 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-openfeign + 4.1.0-SNAPSHOT + + org.springframework.cloud + spring-cloud-openfeign-docs + 4.1.0-SNAPSHOT + Spring Cloud OpenFeign Docs + Spring Cloud Docs + https://spring.io/spring-cloud/spring-cloud-openfeign/spring-cloud-openfeign-docs + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 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. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-openfeign.git/spring-cloud-openfeign-docs + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-openfeign.git/spring-cloud-openfeign-docs + https://github.com/spring-cloud/spring-cloud-openfeign + + + + org.springframework.cloud + spring-cloud-starter-openfeign + 4.1.0-SNAPSHOT + compile + + + diff --git a/docs/.github/workflows/deploy-docs.yml b/docs/.github/workflows/deploy-docs.yml deleted file mode 100644 index be4b92dfc..000000000 --- a/docs/.github/workflows/deploy-docs.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Deploy Docs -on: - push: - branches-ignore: [ gh-pages ] - tags: '**' - repository_dispatch: - types: request-build-reference # legacy - #schedule: - #- cron: '0 10 * * *' # Once per day at 10am UTC - workflow_dispatch: -permissions: - actions: write -jobs: - build: - runs-on: ubuntu-latest - # if: github.repository_owner == 'spring-cloud' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: docs-build - fetch-depth: 1 - - name: Dispatch (partial build) - if: github.ref_type == 'branch' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }} - - name: Dispatch (full build) - if: github.ref_type == 'tag' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) diff --git a/docs/antora.yml b/docs/antora.yml deleted file mode 100644 index 15b346da0..000000000 --- a/docs/antora.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: PROJECT_WITHOUT_SPRING -version: true -title: PROJECT_NAME -nav: - - modules/ROOT/nav.adoc -ext: - collector: - run: - command: ./mvnw --no-transfer-progress -B process-resources -Pdocs -pl docs -Dantora-maven-plugin.phase=none -Dgenerate-docs.phase=none -Dgenerate-readme.phase=none -Dgenerate-cloud-resources.phase=none -Dmaven-dependency-plugin-for-docs.phase=none -Dmaven-dependency-plugin-for-docs-classes.phase=none -DskipTests - local: true - scan: - dir: ./target/classes/antora-resources/ diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc deleted file mode 100644 index 5d5a53a8b..000000000 --- a/docs/modules/ROOT/nav.adoc +++ /dev/null @@ -1,9 +0,0 @@ -* xref:index.adoc[] -* xref:spring-cloud-openfeign.adoc[] -* xref:_attributes.adoc[] -* xref:intro.adoc[] -* xref:README.adoc[] -* xref:_configprops.adoc[] -* xref:appendix.adoc[] -* xref:sagan-boot.adoc[] -* xref:sagan-index.adoc[] diff --git a/docs/modules/ROOT/pages/README.adoc b/docs/modules/ROOT/pages/README.adoc deleted file mode 100644 index ccfa990a1..000000000 --- a/docs/modules/ROOT/pages/README.adoc +++ /dev/null @@ -1,27 +0,0 @@ -image::https://github.com/spring-cloud/spring-cloud-openfeign/workflows/Build/badge.svg?branch=main&style=svg["Build",link="https://github.com/spring-cloud/spring-cloud-openfeign/actions"] - -image:https://codecov.io/gh/spring-cloud/spring-cloud-openfeign/branch/main/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-openfeign"] - -image:https://api.codacy.com/project/badge/Grade/97b04c4e609c4b4f86b415e4437a6484["Codacy code quality", link="https://www.codacy.com/app/Spring-Cloud/spring-cloud-openfeign?utm_source=github.com&utm_medium=referral&utm_content=spring-cloud/spring-cloud-openfeign&utm_campaign=Badge_Grade"] - - - -[[features]] -= Features - -* Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations - -[[building]] -= Building - -include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/building-jdk8.adoc[] - -[[contributing]] -= Contributing - -include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/contributing.adoc[] - -[[license]] -= License - -The project license file is available https://raw.githubusercontent.com/spring-cloud/spring-cloud-openfeign/main/LICENSE.txt[here]. diff --git a/docs/modules/ROOT/pages/_attributes.adoc b/docs/modules/ROOT/pages/_attributes.adoc deleted file mode 100644 index a42e7dea7..000000000 --- a/docs/modules/ROOT/pages/_attributes.adoc +++ /dev/null @@ -1,16 +0,0 @@ -:doctype: book -:idprefix: -:idseparator: - -:tabsize: 4 -:numbered: -:sectanchors: -:sectnums: -:icons: font -:hide-uri-scheme: -:docinfo: shared,private - -:sc-ext: java -:project-full-name: Spring Cloud OpenFeign -:all: {asterisk}{asterisk} - -:core_path: {project-root}/spring-cloud-openfeign-core diff --git a/docs/modules/ROOT/pages/_configprops.adoc b/docs/modules/ROOT/pages/_configprops.adoc deleted file mode 100644 index 6d8de12a4..000000000 --- a/docs/modules/ROOT/pages/_configprops.adoc +++ /dev/null @@ -1,37 +0,0 @@ -|=== -|Name | Default | Description - -|spring.cloud.openfeign.autoconfiguration.jackson.enabled | `false` | If true, PageJacksonModule and SortJacksonModule bean will be provided for Jackson page decoding. -|spring.cloud.openfeign.circuitbreaker.enabled | `false` | If true, an OpenFeign client will be wrapped with a Spring Cloud CircuitBreaker circuit breaker. -|spring.cloud.openfeign.circuitbreaker.group.enabled | `false` | If true, an OpenFeign client will be wrapped with a Spring Cloud CircuitBreaker circuit breaker with with group. -|spring.cloud.openfeign.client.config | | -|spring.cloud.openfeign.client.decode-slash | `true` | Feign clients do not encode slash `/` characters by default. To change this behavior, set the `decodeSlash` to `false`. -|spring.cloud.openfeign.client.default-config | `default` | -|spring.cloud.openfeign.client.default-to-properties | `true` | -|spring.cloud.openfeign.client.refresh-enabled | `false` | Enables options value refresh capability for Feign. -|spring.cloud.openfeign.compression.request.enabled | `false` | Enables the request sent by Feign to be compressed. -|spring.cloud.openfeign.compression.request.mime-types | `[text/xml, application/xml, application/json]` | The list of supported mime types. -|spring.cloud.openfeign.compression.request.min-request-size | `2048` | The minimum threshold content size. -|spring.cloud.openfeign.compression.response.enabled | `false` | Enables the response from Feign to be compressed. -|spring.cloud.openfeign.encoder.charset-from-content-type | `false` | Indicates whether the charset should be derived from the {@code Content-Type} header. -|spring.cloud.openfeign.httpclient.connection-timeout | `2000` | -|spring.cloud.openfeign.httpclient.connection-timer-repeat | `3000` | -|spring.cloud.openfeign.httpclient.disable-ssl-validation | `false` | -|spring.cloud.openfeign.httpclient.enabled | `true` | Enables the use of the Apache HTTP Client by Feign. -|spring.cloud.openfeign.httpclient.follow-redirects | `true` | -|spring.cloud.openfeign.httpclient.hc5.enabled | `false` | Enables the use of the Apache HTTP Client 5 by Feign. -|spring.cloud.openfeign.httpclient.hc5.pool-concurrency-policy | | Pool concurrency policies. -|spring.cloud.openfeign.httpclient.hc5.pool-reuse-policy | | Pool connection re-use policies. -|spring.cloud.openfeign.httpclient.hc5.socket-timeout | `5` | Default value for socket timeout. -|spring.cloud.openfeign.httpclient.hc5.socket-timeout-unit | | Default value for socket timeout unit. -|spring.cloud.openfeign.httpclient.max-connections | `200` | -|spring.cloud.openfeign.httpclient.max-connections-per-route | `50` | -|spring.cloud.openfeign.httpclient.ok-http.read-timeout | `60s` | {@link OkHttpClient} read timeout; defaults to 60 seconds. -|spring.cloud.openfeign.httpclient.time-to-live | `900` | -|spring.cloud.openfeign.httpclient.time-to-live-unit | | -|spring.cloud.openfeign.micrometer.enabled | `true` | Enables Micrometer capabilities for Feign. -|spring.cloud.openfeign.oauth2.enabled | `false` | Enables feign interceptor for managing oauth2 access token. -|spring.cloud.openfeign.oauth2.load-balanced | `false` | Enables load balancing for oauth2 access token provider. -|spring.cloud.openfeign.okhttp.enabled | `false` | Enables the use of the OK HTTP Client by Feign. - -|=== diff --git a/docs/modules/ROOT/pages/appendix.adoc b/docs/modules/ROOT/pages/appendix.adoc deleted file mode 100644 index eef1c9056..000000000 --- a/docs/modules/ROOT/pages/appendix.adoc +++ /dev/null @@ -1,13 +0,0 @@ -:numbered!: -[appendix] -[[common-application-properties]] -= Common application properties -:page-section-summary-toc: 1 - - -Various properties can be specified inside your `application.properties` file, inside your `application.yml` file, or as command line switches. -This appendix provides a list of common {project-full-name} properties and references to the underlying classes that consume them. - -NOTE: Property contributions can come from additional jar files on your classpath, so you should not consider this an exhaustive list. -Also, you can define your own properties. - diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc deleted file mode 100644 index e69de29bb..000000000 diff --git a/docs/modules/ROOT/pages/intro.adoc b/docs/modules/ROOT/pages/intro.adoc deleted file mode 100644 index a69a78c55..000000000 --- a/docs/modules/ROOT/pages/intro.adoc +++ /dev/null @@ -1,3 +0,0 @@ -This project provides OpenFeign integrations for Spring Boot apps through autoconfiguration -and binding to the Spring Environment and other Spring programming model idioms. - diff --git a/docs/modules/ROOT/pages/sagan-boot.adoc b/docs/modules/ROOT/pages/sagan-boot.adoc deleted file mode 100644 index e69de29bb..000000000 diff --git a/docs/modules/ROOT/pages/sagan-index.adoc b/docs/modules/ROOT/pages/sagan-index.adoc deleted file mode 100644 index 134860fdf..000000000 --- a/docs/modules/ROOT/pages/sagan-index.adoc +++ /dev/null @@ -1,41 +0,0 @@ -This project provides https://github.com/OpenFeign/feign[OpenFeign] integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms. - -## Features - -* Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations - -## Getting Started - - -```java -@SpringBootApplication -@EnableFeignClients -public class WebApplication { - - public static void main(String[] args) { - SpringApplication.run(WebApplication.class, args); - } - - @FeignClient("name") - static interface NameService { - @RequestMapping("/") - public String getName(); - } -} - -``` - -## Contributing - -We welcome contributions. You can read more on how to contribute to the project https://github.com/spring-cloud/spring-cloud-openfeign/blob/main/README.adoc#3-contributing[here]. - -## Community Support - -* You can report issues through https://github.com/spring-cloud/spring-cloud-openfeign/issues[Github]. -* We monitor https://stackoverflow.com/[StackOverflow] for questions with the `spring-cloud-feign` tag. -* You can contact our team at https://gitter.im/spring-cloud/spring-cloud[Gitter]. - -## Commercial Support - -Commercial Support is provided as part of the https://spring.io/support[VMware Spring Runtime] offering. - diff --git a/docs/modules/ROOT/pages/spring-cloud-openfeign.adoc b/docs/modules/ROOT/pages/spring-cloud-openfeign.adoc deleted file mode 100644 index 28ffc708f..000000000 --- a/docs/modules/ROOT/pages/spring-cloud-openfeign.adoc +++ /dev/null @@ -1,957 +0,0 @@ -[[spring-cloud-openfeign]] -= Spring Cloud OpenFeign - -*{spring-cloud-version}* - - - -[[spring-cloud-feign]] -== Declarative REST Client: Feign - -https://github.com/OpenFeign/feign[Feign] is a declarative web service client. -It makes writing web service clients easier. -To use Feign create an interface and annotate it. -It has pluggable annotation support including Feign annotations and JAX-RS annotations. -Feign also supports pluggable encoders and decoders. -Spring Cloud adds support for Spring MVC annotations and for using the same `HttpMessageConverters` used by default in Spring Web. -Spring Cloud integrates Eureka, Spring Cloud CircuitBreaker, as well as Spring Cloud LoadBalancer to provide a load-balanced http client when using Feign. - -[[netflix-feign-starter]] -=== How to Include Feign - -To include Feign in your project use the starter with group `org.springframework.cloud` -and artifact id `spring-cloud-starter-openfeign`. See the https://projects.spring.io/spring-cloud/[Spring Cloud Project page] -for details on setting up your build system with the current Spring Cloud Release Train. - -Example spring boot app - -[source,java,indent=0] ----- -@SpringBootApplication -@EnableFeignClients -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} ----- - -.StoreClient.java -[source,java,indent=0] ----- -@FeignClient("stores") -public interface StoreClient { - @RequestMapping(method = RequestMethod.GET, value = "/stores") - List getStores(); - - @RequestMapping(method = RequestMethod.GET, value = "/stores") - Page getStores(Pageable pageable); - - @RequestMapping(method = RequestMethod.POST, value = "/stores/{storeId}", consumes = "application/json") - Store update(@PathVariable("storeId") Long storeId, Store store); - - @RequestMapping(method = RequestMethod.DELETE, value = "/stores/{storeId:\\d+}") - void delete(@PathVariable Long storeId); -} ----- - -In the `@FeignClient` annotation the String value ("stores" above) is an arbitrary client name, which is used to create a https://github.com/spring-cloud/spring-cloud-commons/blob/main/spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/blocking/client/BlockingLoadBalancerClient.java[Spring Cloud LoadBalancer client]. -You can also specify a URL using the `url` attribute -(absolute value or just a hostname). The name of the bean in the -application context is the fully qualified name of the interface. -To specify your own alias value you can use the `qualifiers` value -of the `@FeignClient` annotation. - -The load-balancer client above will want to discover the physical addresses -for the "stores" service. If your application is a Eureka client then -it will resolve the service in the Eureka service registry. If you -don't want to use Eureka, you can configure a list of servers -in your external configuration using https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#simplediscoveryclient[`SimpleDiscoveryClient`]. - -Spring Cloud OpenFeign supports all the features available for the blocking mode of Spring Cloud LoadBalancer. You can read more about them in the https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#spring-cloud-loadbalancer[project documentation]. - -TIP: To use `@EnableFeignClients` annotation on `@Configuration`-annotated-classes, make sure to specify where the clients are located, for example: -`@EnableFeignClients(basePackages = "com.example.clients")` -or list them explicitly: -`@EnableFeignClients(clients = InventoryServiceFeignClient.class)` - -[[attribute-resolution-mode]] -==== Attribute resolution mode - -While creating `Feign` client beans, we resolve the values passed via the `@FeignClient` annotation. As of `4.x`, the values are being resolved eagerly. This is a good solution for most use-cases, and it also allows for AOT support. - -If you need the attributes to be resolved lazily, set the `spring.cloud.openfeign.lazy-attributes-resolution` property value to `true`. - -TIP: For Spring Cloud Contract test integration, lazy attribute resolution should be used. - -[[spring-cloud-feign-overriding-defaults]] -=== Overriding Feign Defaults - -A central concept in Spring Cloud's Feign support is that of the named client. Each feign client is part of an ensemble of components that work together to contact a remote server on demand, and the ensemble has a name that you give it as an application developer using the `@FeignClient` annotation. Spring Cloud creates a new ensemble as an -`ApplicationContext` on demand for each named client using `FeignClientsConfiguration`. This contains (amongst other things) an `feign.Decoder`, a `feign.Encoder`, and a `feign.Contract`. -It is possible to override the name of that ensemble by using the `contextId` -attribute of the `@FeignClient` annotation. - -Spring Cloud lets you take full control of the feign client by declaring additional configuration (on top of the `FeignClientsConfiguration`) using `@FeignClient`. Example: - -[source,java,indent=0] ----- -@FeignClient(name = "stores", configuration = FooConfiguration.class) -public interface StoreClient { - //.. -} ----- - -In this case the client is composed from the components already in `FeignClientsConfiguration` together with any in `FooConfiguration` (where the latter will override the former). - -NOTE: `FooConfiguration` does not need to be annotated with `@Configuration`. However, if it is, then take care to exclude it from any `@ComponentScan` that would otherwise include this configuration as it will become the default source for `feign.Decoder`, `feign.Encoder`, `feign.Contract`, etc., when specified. This can be avoided by putting it in a separate, non-overlapping package from any `@ComponentScan` or `@SpringBootApplication`, or it can be explicitly excluded in `@ComponentScan`. - -NOTE: Using `contextId` attribute of the `@FeignClient` annotation in addition to changing the name of -the `ApplicationContext` ensemble, it will override the alias of the client name -and it will be used as part of the name of the configuration bean created for that client. - -WARNING: Previously, using the `url` attribute, did not require the `name` attribute. Using `name` is now required. - -Placeholders are supported in the `name` and `url` attributes. - -[source,java,indent=0] ----- -@FeignClient(name = "${feign.name}", url = "${feign.url}") -public interface StoreClient { - //.. -} ----- - -Spring Cloud OpenFeign provides the following beans by default for feign (`BeanType` beanName: `ClassName`): - -* `Decoder` feignDecoder: `ResponseEntityDecoder` (which wraps a `SpringDecoder`) -* `Encoder` feignEncoder: `SpringEncoder` -* `Logger` feignLogger: `Slf4jLogger` -* `MicrometerObservationCapability` micrometerObservationCapability: If `feign-micrometer` is on the classpath and `ObservationRegistry` is available -* `MicrometerCapability` micrometerCapability: If `feign-micrometer` is on the classpath, `MeterRegistry` is available and `ObservationRegistry` is not available -* `CachingCapability` cachingCapability: If `@EnableCaching` annotation is used. Can be disabled via `spring.cloud.openfeign.cache.enabled`. -* `Contract` feignContract: `SpringMvcContract` -* `Feign.Builder` feignBuilder: `FeignCircuitBreaker.Builder` -* `Client` feignClient: If Spring Cloud LoadBalancer is on the classpath, `FeignBlockingLoadBalancerClient` is used. -If none of them is on the classpath, the default feign client is used. - -NOTE: `spring-cloud-starter-openfeign` supports `spring-cloud-starter-loadbalancer`. However, as is an optional dependency, you need to make sure it has been added to your project if you want to use it. - -The OkHttpClient, Apache HttpClient 5 and Http2Client Feign clients can be used by setting `spring.cloud.openfeign.okhttp.enabled` or `spring.cloud.openfeign.httpclient.hc5.enabled` or `spring.cloud.openfeign.http2client.enabled` to `true`, respectively, and having them on the classpath. -You can customize the HTTP client used by providing a bean of either `org.apache.hc.client5.http.impl.classic.CloseableHttpClient` when using Apache HC5. - -You can further customise http clients by setting values in the `spring.cloud.openfeign.httpclient.xxx` properties. The ones prefixed just with `httpclient` will work for all the clients, the ones prefixed with `httpclient.hc5` to Apache HttpClient 5, the ones prefixed with `httpclient.okhttp` to OkHttpClient and the ones prefixed with `httpclient.http2` to Http2Client. You can find a full list of properties you can customise in the appendix. - -TIP: Starting with Spring Cloud OpenFeign 4, the Feign Apache HttpClient 4 is no longer supported. We suggest using Apache HttpClient 5 instead. - -Spring Cloud OpenFeign _does not_ provide the following beans by default for feign, but still looks up beans of these types from the application context to create the feign client: - -* `Logger.Level` -* `Retryer` -* `ErrorDecoder` -* `Request.Options` -* `Collection` -* `SetterFactory` -* `QueryMapEncoder` -* `Capability` (`MicrometerObservationCapability` and `CachingCapability` are provided by default) - -A bean of `Retryer.NEVER_RETRY` with the type `Retryer` is created by default, which will disable retrying. -Notice this retrying behavior is different from the Feign default one, where it will automatically retry IOExceptions, -treating them as transient network related exceptions, and any RetryableException thrown from an ErrorDecoder. - -Creating a bean of one of those type and placing it in a `@FeignClient` configuration (such as `FooConfiguration` above) allows you to override each one of the beans described. Example: - -[source,java,indent=0] ----- -@Configuration -public class FooConfiguration { - @Bean - public Contract feignContract() { - return new feign.Contract.Default(); - } - - @Bean - public BasicAuthRequestInterceptor basicAuthRequestInterceptor() { - return new BasicAuthRequestInterceptor("user", "password"); - } -} ----- - -This replaces the `SpringMvcContract` with `feign.Contract.Default` and adds a `RequestInterceptor` to the collection of `RequestInterceptor`. - -`@FeignClient` also can be configured using configuration properties. - -application.yml -[source,yaml] ----- -spring: - cloud: - openfeign: - client: - config: - feignName: - url: http://remote-service.com - connectTimeout: 5000 - readTimeout: 5000 - loggerLevel: full - errorDecoder: com.example.SimpleErrorDecoder - retryer: com.example.SimpleRetryer - defaultQueryParameters: - query: queryValue - defaultRequestHeaders: - header: headerValue - requestInterceptors: - - com.example.FooRequestInterceptor - - com.example.BarRequestInterceptor - responseInterceptor: com.example.BazResponseInterceptor - dismiss404: false - encoder: com.example.SimpleEncoder - decoder: com.example.SimpleDecoder - contract: com.example.SimpleContract - capabilities: - - com.example.FooCapability - - com.example.BarCapability - queryMapEncoder: com.example.SimpleQueryMapEncoder - micrometer.enabled: false ----- -`feignName` in this example refers to `@FeignClient` `value`, that is also aliased with `@FeignClient` `name` and `@FeignClient` `contextId`. In a load-balanced scenario, it also corresponds to the `serviceId` of the server app that will be used to retrieve the instances. - - -Default configurations can be specified in the `@EnableFeignClients` attribute `defaultConfiguration` in a similar manner as described above. The difference is that this configuration will apply to _all_ feign clients. - -If you prefer using configuration properties to configure all `@FeignClient`, you can create configuration properties with `default` feign name. - -You can use `spring.cloud.openfeign.client.config.feignName.defaultQueryParameters` and `spring.cloud.openfeign.client.config.feignName.defaultRequestHeaders` to specify query parameters and headers that will be sent with every request of the client named `feignName`. - -application.yml -[source,yaml] ----- -spring: - cloud: - openfeign: - client: - config: - default: - connectTimeout: 5000 - readTimeout: 5000 - loggerLevel: basic ----- - -If we create both `@Configuration` bean and configuration properties, configuration properties will win. -It will override `@Configuration` values. But if you want to change the priority to `@Configuration`, -you can change `spring.cloud.openfeign.client.default-to-properties` to `false`. - -If we want to create multiple feign clients with the same name or url -so that they would point to the same server but each with a different custom configuration then -we have to use `contextId` attribute of the `@FeignClient` in order to avoid name -collision of these configuration beans. - -[source,java,indent=0] ----- -@FeignClient(contextId = "fooClient", name = "stores", configuration = FooConfiguration.class) -public interface FooClient { - //.. -} ----- - -[source,java,indent=0] ----- -@FeignClient(contextId = "barClient", name = "stores", configuration = BarConfiguration.class) -public interface BarClient { - //.. -} ----- - -It is also possible to configure FeignClient not to inherit beans from the parent context. -You can do this by overriding the `inheritParentConfiguration()` in a `FeignClientConfigurer` -bean to return `false`: - -[source,java,indent=0] ----- -@Configuration -public class CustomConfiguration{ - -@Bean -public FeignClientConfigurer feignClientConfigurer() { - return new FeignClientConfigurer() { - - @Override - public boolean inheritParentConfiguration() { - return false; - } - }; - - } -} ----- - -TIP: By default, Feign clients do not encode slash `/` characters. You can change this behaviour, by setting the value of `spring.cloud.openfeign.client.decodeSlash` to `false`. - -[[springencoder-configuration]] -==== `SpringEncoder` configuration - -In the `SpringEncoder` that we provide, we set `null` charset for binary content types and `UTF-8` for all the other ones. - -You can modify this behaviour to derive the charset from the `Content-Type` header charset instead by setting the value of `spring.cloud.openfeign.encoder.charset-from-content-type` to `true`. - -[[timeout-handling]] -=== Timeout Handling - -We can configure timeouts on both the default and the named client. OpenFeign works with two timeout parameters: - -- `connectTimeout` prevents blocking the caller due to the long server processing time. -- `readTimeout` is applied from the time of connection establishment and is triggered when returning the response takes too long. - -NOTE: In case the server is not running or available a packet results in _connection refused_. The communication ends either with an error message or in a fallback. This can happen _before_ the `connectTimeout` if it is set very low. The time taken to perform a lookup and to receive such a packet causes a significant part of this delay. It is subject to change based on the remote host that involves a DNS lookup. - -[[creating-feign-clients-manually]] -=== Creating Feign Clients Manually - -In some cases it might be necessary to customize your Feign Clients in a way that is not -possible using the methods above. In this case you can create Clients using the -https://github.com/OpenFeign/feign/#basics[Feign Builder API]. Below is an example -which creates two Feign Clients with the same interface but configures each one with -a separate request interceptor. - -[source,java,indent=0] ----- -@Import(FeignClientsConfiguration.class) -class FooController { - - private FooClient fooClient; - - private FooClient adminClient; - - @Autowired - public FooController(Client client, Encoder encoder, Decoder decoder, Contract contract, MicrometerObservationCapability micrometerObservationCapability) { - this.fooClient = Feign.builder().client(client) - .encoder(encoder) - .decoder(decoder) - .contract(contract) - .addCapability(micrometerObservationCapability) - .requestInterceptor(new BasicAuthRequestInterceptor("user", "user")) - .target(FooClient.class, "https://PROD-SVC"); - - this.adminClient = Feign.builder().client(client) - .encoder(encoder) - .decoder(decoder) - .contract(contract) - .addCapability(micrometerObservationCapability) - .requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin")) - .target(FooClient.class, "https://PROD-SVC"); - } -} ----- - -NOTE: In the above example `FeignClientsConfiguration.class` is the default configuration -provided by Spring Cloud OpenFeign. - -NOTE: `PROD-SVC` is the name of the service the Clients will be making requests to. - -NOTE: The Feign `Contract` object defines what annotations and values are valid on interfaces. The -autowired `Contract` bean provides supports for SpringMVC annotations, instead of -the default Feign native annotations. - -You can also use the `Builder`to configure FeignClient not to inherit beans from the parent context. -You can do this by overriding calling `inheritParentContext(false)` on the `Builder`. - -[[spring-cloud-feign-circuitbreaker]] -=== Feign Spring Cloud CircuitBreaker Support - -If Spring Cloud CircuitBreaker is on the classpath and `spring.cloud.openfeign.circuitbreaker.enabled=true`, Feign will wrap all methods with a circuit breaker. - -To disable Spring Cloud CircuitBreaker support on a per-client basis create a vanilla `Feign.Builder` with the "prototype" scope, e.g.: - -[source,java,indent=0] ----- -@Configuration -public class FooConfiguration { - @Bean - @Scope("prototype") - public Feign.Builder feignBuilder() { - return Feign.builder(); - } -} ----- - -The circuit breaker name follows this pattern `#()`. When calling a `@FeignClient` with `FooClient` interface and the called interface method that has no parameters is `bar` then the circuit breaker name will be `FooClient#bar()`. - -NOTE: As of 2020.0.2, the circuit breaker name pattern has changed from `_`. -Using `CircuitBreakerNameResolver` introduced in 2020.0.4, circuit breaker names can retain the old pattern. - -Providing a bean of `CircuitBreakerNameResolver`, you can change the circuit breaker name pattern. -[source,java,indent=0] ----- -@Configuration -public class FooConfiguration { - @Bean - public CircuitBreakerNameResolver circuitBreakerNameResolver() { - return (String feignClientName, Target target, Method method) -> feignClientName + "_" + method.getName(); - } -} ----- - -To enable Spring Cloud CircuitBreaker group set the `spring.cloud.openfeign.circuitbreaker.group.enabled` property to `true` (by default `false`). - -[[spring-clou-feign-circuitbreaker-configurationproperties]] -=== Configuring CircuitBreakers With Configuration Properties - -You can configure CircuitBreakers via configuration properties. - -For example, if you had this Feign client - -[source,java,indent=0] ----- -@FeignClient(url = "http://localhost:8080") -public interface DemoClient { - - @GetMapping("demo") - String getDemo(); -} ----- - -You could configure it using configuration properties by doing the following - -[source,yaml,indent=0] ----- -spring: - cloud: - openfeign: - circuitbreaker: - enabled: true - alphanumeric-ids: - enabled: true -resilience4j: - circuitbreaker: - instances: - DemoClientgetDemo: - minimumNumberOfCalls: 69 - timelimiter: - instances: - DemoClientgetDemo: - timeoutDuration: 10s ----- - -NOTE: If you want to switch back to the circuit breaker names used prior to Spring Cloud -2022.0.0 you can set `spring.cloud.openfeign.circuitbreaker.alphanumeric-ids.enabled` to `false`. - -[[spring-cloud-feign-circuitbreaker-fallback]] -=== Feign Spring Cloud CircuitBreaker Fallbacks - -Spring Cloud CircuitBreaker supports the notion of a fallback: a default code path that is executed when the circuit is open or there is an error. To enable fallbacks for a given `@FeignClient` set the `fallback` attribute to the class name that implements the fallback. You also need to declare your implementation as a Spring bean. - -[source,java,indent=0] ----- -@FeignClient(name = "test", url = "http://localhost:${server.port}/", fallback = Fallback.class) - protected interface TestClient { - - @RequestMapping(method = RequestMethod.GET, value = "/hello") - Hello getHello(); - - @RequestMapping(method = RequestMethod.GET, value = "/hellonotfound") - String getException(); - - } - - @Component - static class Fallback implements TestClient { - - @Override - public Hello getHello() { - throw new NoFallbackAvailableException("Boom!", new RuntimeException()); - } - - @Override - public String getException() { - return "Fixed response"; - } - - } ----- - -If one needs access to the cause that made the fallback trigger, one can use the `fallbackFactory` attribute inside `@FeignClient`. - -[source,java,indent=0] ----- -@FeignClient(name = "testClientWithFactory", url = "http://localhost:${server.port}/", - fallbackFactory = TestFallbackFactory.class) - protected interface TestClientWithFactory { - - @RequestMapping(method = RequestMethod.GET, value = "/hello") - Hello getHello(); - - @RequestMapping(method = RequestMethod.GET, value = "/hellonotfound") - String getException(); - - } - - @Component - static class TestFallbackFactory implements FallbackFactory { - - @Override - public FallbackWithFactory create(Throwable cause) { - return new FallbackWithFactory(); - } - - } - - static class FallbackWithFactory implements TestClientWithFactory { - - @Override - public Hello getHello() { - throw new NoFallbackAvailableException("Boom!", new RuntimeException()); - } - - @Override - public String getException() { - return "Fixed response"; - } - - } ----- - -[[feign-and-primary]] -=== Feign and `@Primary` - -When using Feign with Spring Cloud CircuitBreaker fallbacks, there are multiple beans in the `ApplicationContext` of the same type. This will cause `@Autowired` to not work because there isn't exactly one bean, or one marked as primary. To work around this, Spring Cloud OpenFeign marks all Feign instances as `@Primary`, so Spring Framework will know which bean to inject. In some cases, this may not be desirable. To turn off this behavior set the `primary` attribute of `@FeignClient` to false. - -[source,java,indent=0] ----- -@FeignClient(name = "hello", primary = false) -public interface HelloClient { - // methods here -} ----- - -[[spring-cloud-feign-inheritance]] -=== Feign Inheritance Support - -Feign supports boilerplate apis via single-inheritance interfaces. -This allows grouping common operations into convenient base interfaces. - -.UserService.java -[source,java,indent=0] ----- -public interface UserService { - - @RequestMapping(method = RequestMethod.GET, value ="/users/{id}") - User getUser(@PathVariable("id") long id); -} ----- - -.UserResource.java -[source,java,indent=0] ----- -@RestController -public class UserResource implements UserService { - -} ----- - -.UserClient.java -[source,java,indent=0] ----- -package project.user; - -@FeignClient("users") -public interface UserClient extends UserService { - -} ----- - -WARNING: `@FeignClient` interfaces should not be shared between server and client and annotating `@FeignClient` interfaces with `@RequestMapping` on class level is no longer supported. - -[[feign-request/response-compression]] -=== Feign request/response compression - -You may consider enabling the request or response GZIP compression for your -Feign requests. You can do this by enabling one of the properties: - -[source,java] ----- -spring.cloud.openfeign.compression.request.enabled=true -spring.cloud.openfeign.compression.response.enabled=true ----- - -Feign request compression gives you settings similar to what you may set for your web server: - -[source,java] ----- -spring.cloud.openfeign.compression.request.enabled=true -spring.cloud.openfeign.compression.request.mime-types=text/xml,application/xml,application/json -spring.cloud.openfeign.compression.request.min-request-size=2048 ----- - -These properties allow you to be selective about the compressed media types and minimum request threshold length. - -TIP: Since the OkHttpClient uses "transparent" compression, that is disabled if the `content-encoding` or `accept-encoding` header is present, we do not enable compression when `feign.okhttp.OkHttpClient` is present on the classpath and `spring.cloud.openfeign.okhttp.enabled` is set to `true`. - -[[feign-logging]] -=== Feign logging - -A logger is created for each Feign client created. By default, the name of the logger is the full class name of the interface used to create the Feign client. Feign logging only responds to the `DEBUG` level. - -.application.yml - -[source,yaml] ----- -logging.level.project.user.UserClient: DEBUG ----- - -The `Logger.Level` object that you may configure per client, tells Feign how much to log. Choices are: - -* `NONE`, No logging (*DEFAULT*). -* `BASIC`, Log only the request method and URL and the response status code and execution time. -* `HEADERS`, Log the basic information along with request and response headers. -* `FULL`, Log the headers, body, and metadata for both requests and responses. - -For example, the following would set the `Logger.Level` to `FULL`: - -[source,java,indent=0] ----- -@Configuration -public class FooConfiguration { - @Bean - Logger.Level feignLoggerLevel() { - return Logger.Level.FULL; - } -} ----- - -[[feign-capability-support]] -=== Feign Capability support - -The Feign capabilities expose core Feign components so that these components can be modified. For example, the capabilities can take the `Client`, _decorate_ it, and give the decorated instance back to Feign. -The support for Micrometer is a good real-life example for this. See xref:spring-cloud-openfeign.adoc#micrometer-support[Micrometer Support]. - -Creating one or more `Capability` beans and placing them in a `@FeignClient` configuration lets you register them and modify the behavior of the involved client. - -[source,java,indent=0] ----- -@Configuration -public class FooConfiguration { - @Bean - Capability customCapability() { - return new CustomCapability(); - } -} ----- - -[[micrometer-support]] -=== Micrometer Support - -If all of the following conditions are true, a `MicrometerObservationCapability` bean is created and registered so that your Feign client is observable by Micrometer: - -* `feign-micrometer` is on the classpath -* A `ObservationRegistry` bean is available -* feign micrometer properties are set to `true` (by default) - - `spring.cloud.openfeign.micrometer.enabled=true` (for all clients) - - `spring.cloud.openfeign.client.config.feignName.micrometer.enabled=true` (for a single client) - -NOTE: If your application already uses Micrometer, enabling this feature is as simple as putting `feign-micrometer` onto your classpath. - -You can also disable the feature by either: - -* excluding `feign-micrometer` from your classpath -* setting one of the feign micrometer properties to `false` - - `spring.cloud.openfeign.micrometer.enabled=false` - - `spring.cloud.openfeign.client.config.feignName.micrometer.enabled=false` - -NOTE: `spring.cloud.openfeign.micrometer.enabled=false` disables Micrometer support for *all* Feign clients regardless of the value of the client-level flags: `spring.cloud.openfeign.client.config.feignName.micrometer.enabled`. -If you want to enable or disable Micrometer support per client, don't set `spring.cloud.openfeign.micrometer.enabled` and use `spring.cloud.openfeign.client.config.feignName.micrometer.enabled`. - -You can also customize the `MicrometerObservationCapability` by registering your own bean: - -[source,java,indent=0] ----- -@Configuration -public class FooConfiguration { - @Bean - public MicrometerObservationCapability micrometerObservationCapability(ObservationRegistry registry) { - return new MicrometerObservationCapability(registry); - } -} ----- - -It is still possible to use `MicrometerCapability` with Feign (metrics-only support), you need to disable Micrometer support (`spring.cloud.openfeign.micrometer.enabled=false`) and create a `MicrometerCapability` bean: - -[source,java,indent=0] ----- -@Configuration -public class FooConfiguration { - @Bean - public MicrometerCapability micrometerCapability(MeterRegistry meterRegistry) { - return new MicrometerCapability(meterRegistry); - } -} ----- - -[[feign-caching]] -=== Feign Caching - -If `@EnableCaching` annotation is used, a `CachingCapability` bean is created and registered so that your Feign client recognizes `@Cache*` annotations on its interface: - -[source,java,indent=0] ----- -public interface DemoClient { - - @GetMapping("/demo/{filterParam}") - @Cacheable(cacheNames = "demo-cache", key = "#keyParam") - String demoEndpoint(String keyParam, @PathVariable String filterParam); -} ----- - -You can also disable the feature via property `spring.cloud.openfeign.cache.enabled=false`. - -[[feign-querymap-support]] -=== Feign @QueryMap support - -Spring Cloud OpenFeign provides an equivalent `@SpringQueryMap` annotation, which -is used to annotate a POJO or Map parameter as a query parameter map. - -For example, the `Params` class defines parameters `param1` and `param2`: - -[source,java,indent=0] ----- -// Params.java -public class Params { - private String param1; - private String param2; - - // [Getters and setters omitted for brevity] -} ----- - -The following feign client uses the `Params` class by using the `@SpringQueryMap` annotation: - -[source,java,indent=0] ----- -@FeignClient("demo") -public interface DemoTemplate { - - @GetMapping(path = "/demo") - String demoEndpoint(@SpringQueryMap Params params); -} ----- - -If you need more control over the generated query parameter map, you can implement a custom `QueryMapEncoder` bean. - -[[hateoas-support]] -=== HATEOAS support - -Spring provides some APIs to create REST representations that follow the https://en.wikipedia.org/wiki/HATEOAS[HATEOAS] principle, https://spring.io/projects/spring-hateoas[Spring Hateoas] and https://spring.io/projects/spring-data-rest[Spring Data REST]. - -If your project use the `org.springframework.boot:spring-boot-starter-hateoas` starter -or the `org.springframework.boot:spring-boot-starter-data-rest` starter, Feign HATEOAS support is enabled by default. - -When HATEOAS support is enabled, Feign clients are allowed to serialize -and deserialize HATEOAS representation models: https://docs.spring.io/spring-hateoas/docs/1.0.0.M1/apidocs/org/springframework/hateoas/EntityModel.html[EntityModel], https://docs.spring.io/spring-hateoas/docs/1.0.0.M1/apidocs/org/springframework/hateoas/CollectionModel.html[CollectionModel] and https://docs.spring.io/spring-hateoas/docs/1.0.0.M1/apidocs/org/springframework/hateoas/PagedModel.html[PagedModel]. - -[source,java,indent=0] ----- -@FeignClient("demo") -public interface DemoTemplate { - - @GetMapping(path = "/stores") - CollectionModel getStores(); -} ----- - -[[spring-matrixvariable-support]] -=== Spring @MatrixVariable Support - -Spring Cloud OpenFeign provides support for the Spring `@MatrixVariable` annotation. - -If a map is passed as the method argument, the `@MatrixVariable` path segment is created by joining key-value pairs from the map with a `=`. - -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, 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: - -[source,java,indent=0] ----- -@GetMapping("/objects/links/{matrixVars}") -Map> getObjects(@MatrixVariable Map> matrixVars); ----- -Note that both variable name and the path segment placeholder are called `matrixVars`. - -[source,java,indent=0] ----- -@FeignClient("demo") -public interface DemoTemplate { - - @GetMapping(path = "/stores") - CollectionModel getStores(); -} ----- - -[[feign-collectionformat-support]] -=== Feign `CollectionFormat` support -We support `feign.CollectionFormat` by providing the `@CollectionFormat` annotation. -You can annotate a Feign client method (or the whole class to affect all methods) with it by passing the desired `feign.CollectionFormat` as annotation value. - -In the following example, the `CSV` format is used instead of the default `EXPLODED` to process the method. - -[source,java,indent=0] ----- -@FeignClient(name = "demo") -protected interface DemoFeignClient { - - @CollectionFormat(feign.CollectionFormat.CSV) - @GetMapping(path = "/test") - ResponseEntity performRequest(String test); - -} ----- - -[[reactive-support]] -=== Reactive Support -As the https://github.com/OpenFeign/feign[OpenFeign project] does not currently support reactive clients, such as https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/reactive/function/client/WebClient.html[Spring WebClient], neither does Spring Cloud OpenFeign.We will add support for it here as soon as it becomes available in the core project. - -Until that is done, we recommend using https://github.com/Playtika/feign-reactive[feign-reactive] for Spring WebClient support. - -[[early-initialization-errors]] -==== Early Initialization Errors - -Depending on how you are using your Feign clients you may see initialization errors when starting your application. -To work around this problem you can use an `ObjectProvider` when autowiring your client. - -[source,java,indent=0] ----- -@Autowired -ObjectProvider testFeignClient; ----- - -[[spring-data-support]] -=== Spring Data Support - -If Jackson Databind and Spring Data Commons are on the classpath, converters for `org.springframework.data.domain.Page` and `org.springframework.data.domain.Sort` will be added automatically. - -To disable this behaviour set -[source,java] ----- -spring.cloud.openfeign.autoconfiguration.jackson.enabled=false ----- - -See `org.springframework.cloud.openfeign.FeignAutoConfiguration.FeignJacksonConfiguration` for details. - -[[spring-refreshscope-support]] -=== Spring `@RefreshScope` Support -If Feign client refresh is enabled, each Feign client is created with: - -* `feign.Request.Options` as a refresh-scoped bean. This means properties such as `connectTimeout` and `readTimeout` can be refreshed against any Feign client instance. -* A url wrapped under `org.springframework.cloud.openfeign.RefreshableUrl`. This means the URL of Feign client, if defined -with `spring.cloud.openfeign.client.config.{feignName}.url` property, can be refreshed against any Feign client instance. - -You can refresh these properties through `POST /actuator/refresh`. - -By default, refresh behavior in Feign clients is disabled. Use the following property to enable refresh behavior: -[source,java] ----- -spring.cloud.openfeign.client.refresh-enabled=true ----- -TIP: DO NOT annotate the `@FeignClient` interface with the `@RefreshScope` annotation. - -[[oauth2-support]] -=== OAuth2 Support -OAuth2 support can be enabled by setting following flag: ----- -spring.cloud.openfeign.oauth2.enabled=true ----- -When the flag is set to true, and the oauth2 client context resource details are present, a bean of class `OAuth2AccessTokenInterceptor` is created. Before each request, the interceptor resolves the required access token and includes it as a header. -`OAuth2AccessTokenInterceptor` uses the `OAuth2AuthorizedClientManager` to get `OAuth2AuthorizedClient` that holds an `OAuth2AccessToken`. If the user has specified an OAuth2 `clientRegistrationId` using the `spring.cloud.openfeign.oauth2.clientRegistrationId` property, it will be used to retrieve the token. If the token is not retrieved or the `clientRegistrationId` has not been specified, the `serviceId` retrieved from the `url` host segment will be used. - -TIP:: Using the `serviceId` as OAuth2 client registrationId is convenient for load-balanced Feign clients. For non-load-balanced ones, the property-based `clientRegistrationId` is a suitable approach. - -TIP:: If you do not want to use the default setup for the `OAuth2AuthorizedClientManager`, you can just instantiate a bean of this type in your configuration. - -[[transform-the-load-balanced-http-request]] -=== Transform the load-balanced HTTP request - -You can use the selected `ServiceInstance` to transform the load-balanced HTTP Request. - -For `Request`, you need to implement and define `LoadBalancerFeignRequestTransformer`, as follows: - -[source,java,indent=0] ----- - @Bean - public LoadBalancerFeignRequestTransformer transformer() { - return new LoadBalancerFeignRequestTransformer() { - - @Override - public Request transformRequest(Request request, ServiceInstance instance) { - Map> headers = new HashMap<>(request.headers()); - headers.put("X-ServiceId", Collections.singletonList(instance.getServiceId())); - headers.put("X-InstanceId", Collections.singletonList(instance.getInstanceId())); - return Request.create(request.httpMethod(), request.url(), headers, request.body(), request.charset(), - request.requestTemplate()); - } - }; - } ----- - -If multiple transformers are defined, they are applied in the order in which beans are defined. -Alternatively, you can use `LoadBalancerFeignRequestTransformer.DEFAULT_ORDER` to specify the order. - -[[x-forwarded-headers-support]] -=== X-Forwarded Headers Support - -`X-Forwarded-Host` and `X-Forwarded-Proto` support can be enabled by setting following flag: - -[source,properties] ----- -spring.cloud.loadbalancer.x-forwarded.enabled=true ----- - -[[supported-ways-to-provide-url-to-a-feign-client]] -=== Supported Ways To Provide URL To A Feign Client -You can provide a URL to a Feign client in any of the following ways: - -|=== -|Case |Example |Details - -|The URL is provided in the `@FeignClient` annotation. -|`@FeignClient(name="testClient", url="http://localhost:8081")` -|The URL is resolved from the `url` attribute of the annotation, without load-balancing. - -|The URL is provided in the `@FeignClient` annotation and in the -configuration properties. -|`@FeignClient(name="testClient", url="http://localhost:8081")` and the property defined in `application.yml` as -`spring.cloud.openfeign.client.config.testClient.url=http://localhost:8081` -|The URL is resolved from the `url` attribute of the annotation, without load-balancing. -The URL provided in the configuration properties remains unused. - -|The URL is not provided in the `@FeignClient` annotation but is provided in configuration properties. -| `@FeignClient(name="testClient")` and the property defined in `application.yml` as -`spring.cloud.openfeign.client.config.testClient.url=http://localhost:8081` -|The URL is resolved from configuration properties, without load-balancing. If -`spring.cloud.openfeign.client.refresh-enabled=true`, then the URL defined in configuration properties can be refreshed as described in <>. - -|The URL is neither provided in the `@FeignClient` annotation nor in configuration properties. -|`@FeignClient(name="testClient")` -|The URL is resolved from `name` attribute of annotation, with load balancing. - -|=== - -[[aot-and-native-image-support]] -=== AOT and Native Image Support - -Spring Cloud OpenFeign supports Spring AOT transformations and native images, however, only with refresh mode disabled, Feign clients refresh disabled (default setting) and xref:spring-cloud-openfeign.adoc#attribute-resolution-mode[lazy `@FeignClient` attribute resolution] disabled (default setting). - -WARNING: If you want to run Spring Cloud OpenFeign clients in AOT or native image modes, make sure to set `spring.cloud.refresh.enabled` to `false`. - -TIP: If you want to run Spring Cloud OpenFeign clients in AOT or native image modes, ensure `spring.cloud.openfeign.client.refresh-enabled` has not been set to `true`. - -TIP: If you want to run Spring Cloud OpenFeign clients in AOT or native image modes, ensure `spring.cloud.openfeign.lazy-attributes-resolution` has not been set to `true`. - -TIP: However, if you set the `url` value via properties, it is possible to override the `@FeignClient` `url` value by running the image with `-Dspring.cloud.openfeign.client.config.[clientId].url=[url]` flag. In order to enable overriding, a `url` value also has to be set via properties and not `@FeignClient` attribute during buildtime. - -[[configuration-properties]] -== Configuration properties - -To see the list of all Spring Cloud OpenFeign related configuration properties please check link:appendix.html[the Appendix page]. diff --git a/docs/pom.xml b/docs/pom.xml deleted file mode 100644 index 23974a740..000000000 --- a/docs/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - 4.0.0 - - org.springframework.cloud - spring-cloud-openfeign - 4.1.0-SNAPSHOT - - - https://github.com/spring-cloud/spring-cloud-openfeign - - spring-cloud-openfeign-docs - jar - Spring Cloud OpenFeign Docs - Spring Cloud Docs - - spring-cloud-openfeign - ${basedir}/.. - feign.* - deploy - - none - - - - ${project.groupId} - spring-cloud-starter-openfeign - - - - src/main/asciidoc - - - - docs - - - - pl.project13.maven - git-commit-id-plugin - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.maven.plugins - maven-resources-plugin - - - org.codehaus.mojo - exec-maven-plugin - - - org.asciidoctor - asciidoctor-maven-plugin - - - org.apache.maven.plugins - maven-antrun-plugin - - - maven-deploy-plugin - - - - - - diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh deleted file mode 100755 index 8bb835786..000000000 --- a/docs/src/main/asciidoc/ghpages.sh +++ /dev/null @@ -1,330 +0,0 @@ -#!/bin/bash -x - -set -e - -# Set default props like MAVEN_PATH, ROOT_FOLDER etc. -function set_default_props() { - # The script should be executed from the root folder - ROOT_FOLDER=`pwd` - echo "Current folder is ${ROOT_FOLDER}" - - if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then - echo "You're not in the root folder of the project!" - exit 1 - fi - - # Prop that will let commit the changes - COMMIT_CHANGES="no" - MAVEN_PATH=${MAVEN_PATH:-} - echo "Path to Maven is [${MAVEN_PATH}]" - REPO_NAME=${PWD##*/} - echo "Repo name is [${REPO_NAME}]" - SPRING_CLOUD_STATIC_REPO=${SPRING_CLOUD_STATIC_REPO:-git@github.com:spring-cloud/spring-cloud-static.git} - echo "Spring Cloud Static repo is [${SPRING_CLOUD_STATIC_REPO}" -} - -# Check if gh-pages exists and docs have been built -function check_if_anything_to_sync() { - git remote set-url --push origin `git config remote.origin.url | sed -e 's/^git:/https:/'` - - if ! (git remote set-branches --add origin gh-pages && git fetch -q); then - echo "No gh-pages, so not syncing" - exit 0 - fi - - if ! [ -d docs/target/generated-docs ] && ! [ "${BUILD}" == "yes" ]; then - echo "No gh-pages sources in docs/target/generated-docs, so not syncing" - exit 0 - fi -} - -function retrieve_current_branch() { - # Code getting the name of the current branch. For main we want to publish as we did until now - # https://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch - # If there is a branch already passed will reuse it - otherwise will try to find it - CURRENT_BRANCH=${BRANCH} - if [[ -z "${CURRENT_BRANCH}" ]] ; then - CURRENT_BRANCH=$(git symbolic-ref -q HEAD) - CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/} - CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD} - fi - echo "Current branch is [${CURRENT_BRANCH}]" - git checkout ${CURRENT_BRANCH} || echo "Failed to check the branch... continuing with the script" -} - -# Switches to the provided value of the release version. We always prefix it with `v` -function switch_to_tag() { - git checkout v${VERSION} -} - -# Build the docs if switch is on -function build_docs_if_applicable() { - if [[ "${BUILD}" == "yes" ]] ; then - ./mvnw clean install -P docs -pl docs -DskipTests - fi -} - -# Get the name of the `docs.main` property -# Get whitelisted branches - assumes that a `docs` module is available under `docs` profile -function retrieve_doc_properties() { - MAIN_ADOC_VALUE=$("${MAVEN_PATH}"mvn -q \ - -Dexec.executable="echo" \ - -Dexec.args='${docs.main}' \ - --non-recursive \ - org.codehaus.mojo:exec-maven-plugin:1.3.1:exec) - echo "Extracted 'main.adoc' from Maven build [${MAIN_ADOC_VALUE}]" - - - WHITELIST_PROPERTY=${WHITELIST_PROPERTY:-"docs.whitelisted.branches"} - WHITELISTED_BRANCHES_VALUE=$("${MAVEN_PATH}"mvn -q \ - -Dexec.executable="echo" \ - -Dexec.args="\${${WHITELIST_PROPERTY}}" \ - org.codehaus.mojo:exec-maven-plugin:1.3.1:exec \ - -P docs \ - -pl docs) - echo "Extracted '${WHITELIST_PROPERTY}' from Maven build [${WHITELISTED_BRANCHES_VALUE}]" -} - -# Stash any outstanding changes -function stash_changes() { - git diff-index --quiet HEAD && dirty=$? || (echo "Failed to check if the current repo is dirty. Assuming that it is." && dirty="1") - if [ "$dirty" != "0" ]; then git stash; fi -} - -# Switch to gh-pages branch to sync it with current branch -function add_docs_from_target() { - local DESTINATION_REPO_FOLDER - if [[ -z "${DESTINATION}" && -z "${CLONE}" ]] ; then - DESTINATION_REPO_FOLDER=${ROOT_FOLDER} - elif [[ "${CLONE}" == "yes" ]]; then - mkdir -p ${ROOT_FOLDER}/target - local clonedStatic=${ROOT_FOLDER}/target/spring-cloud-static - if [[ ! -e "${clonedStatic}/.git" ]]; then - echo "Cloning Spring Cloud Static to target" - git clone ${SPRING_CLOUD_STATIC_REPO} ${clonedStatic} && git checkout gh-pages - else - echo "Spring Cloud Static already cloned - will pull changes" - cd ${clonedStatic} && git checkout gh-pages && git pull origin gh-pages - fi - DESTINATION_REPO_FOLDER=${clonedStatic}/${REPO_NAME} - mkdir -p ${DESTINATION_REPO_FOLDER} - else - if [[ ! -e "${DESTINATION}/.git" ]]; then - echo "[${DESTINATION}] is not a git repository" - exit 1 - fi - DESTINATION_REPO_FOLDER=${DESTINATION}/${REPO_NAME} - mkdir -p ${DESTINATION_REPO_FOLDER} - echo "Destination was provided [${DESTINATION}]" - fi - cd ${DESTINATION_REPO_FOLDER} - git checkout gh-pages - git pull origin gh-pages - - # Add git branches - ################################################################### - if [[ -z "${VERSION}" ]] ; then - copy_docs_for_current_version - else - copy_docs_for_provided_version - fi - commit_changes_if_applicable -} - - -# Copies the docs by using the retrieved properties from Maven build -function copy_docs_for_current_version() { - if [[ "${CURRENT_BRANCH}" == "main" ]] ; then - echo -e "Current branch is main - will copy the current docs only to the root folder" - for f in docs/target/generated-docs/*; do - file=${f#docs/target/generated-docs/*} - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then - # Not ignored... - cp -rf $f ${ROOT_FOLDER}/ - git add -A ${ROOT_FOLDER}/$file - fi - done - COMMIT_CHANGES="yes" - else - echo -e "Current branch is [${CURRENT_BRANCH}]" - # https://stackoverflow.com/questions/29300806/a-bash-script-to-check-if-a-string-is-present-in-a-comma-separated-list-of-strin - if [[ ",${WHITELISTED_BRANCHES_VALUE}," = *",${CURRENT_BRANCH},"* ]] ; then - mkdir -p ${ROOT_FOLDER}/${CURRENT_BRANCH} - echo -e "Branch [${CURRENT_BRANCH}] is whitelisted! Will copy the current docs to the [${CURRENT_BRANCH}] folder" - for f in docs/target/generated-docs/*; do - file=${f#docs/target/generated-docs/*} - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then - # Not ignored... - # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html - if [[ "${file}" == "${MAIN_ADOC_VALUE}.html" ]] ; then - # We don't want to copy the spring-cloud-sleuth.html - # we want it to be converted to index.html - cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html - git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html - else - cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH} - git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/$file - fi - fi - done - COMMIT_CHANGES="yes" - else - echo -e "Branch [${CURRENT_BRANCH}] is not on the white list! Check out the Maven [${WHITELIST_PROPERTY}] property in - [docs] module available under [docs] profile. Won't commit any changes to gh-pages for this branch." - fi - fi -} - -# Copies the docs by using the explicitly provided version -function copy_docs_for_provided_version() { - local FOLDER=${DESTINATION_REPO_FOLDER}/${VERSION} - mkdir -p ${FOLDER} - echo -e "Current tag is [v${VERSION}] Will copy the current docs to the [${FOLDER}] folder" - for f in ${ROOT_FOLDER}/docs/target/generated-docs/*; do - file=${f#${ROOT_FOLDER}/docs/target/generated-docs/*} - copy_docs_for_branch ${file} ${FOLDER} - done - COMMIT_CHANGES="yes" - CURRENT_BRANCH="v${VERSION}" -} - -# Copies the docs from target to the provided destination -# Params: -# $1 - file from target -# $2 - destination to which copy the files -function copy_docs_for_branch() { - local file=$1 - local destination=$2 - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^${file}$; then - # Not ignored... - # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html - if [[ ("${file}" == "${MAIN_ADOC_VALUE}.html") || ("${file}" == "${REPO_NAME}.html") ]] ; then - # We don't want to copy the spring-cloud-sleuth.html - # we want it to be converted to index.html - cp -rf $f ${destination}/index.html - git add -A ${destination}/index.html - else - cp -rf $f ${destination} - git add -A ${destination}/$file - fi - fi -} - -function commit_changes_if_applicable() { - if [[ "${COMMIT_CHANGES}" == "yes" ]] ; then - COMMIT_SUCCESSFUL="no" - git commit -a -m "Sync docs from ${CURRENT_BRANCH} to gh-pages" && COMMIT_SUCCESSFUL="yes" || echo "Failed to commit changes" - - # Uncomment the following push if you want to auto push to - # the gh-pages branch whenever you commit to main locally. - # This is a little extreme. Use with care! - ################################################################### - if [[ "${COMMIT_SUCCESSFUL}" == "yes" ]] ; then - git push origin gh-pages - fi - fi -} - -# Switch back to the previous branch and exit block -function checkout_previous_branch() { - # If -version was provided we need to come back to root project - cd ${ROOT_FOLDER} - git checkout ${CURRENT_BRANCH} || echo "Failed to check the branch... continuing with the script" - if [ "$dirty" != "0" ]; then git stash pop; fi - exit 0 -} - -# Assert if properties have been properly passed -function assert_properties() { -echo "VERSION [${VERSION}], DESTINATION [${DESTINATION}], CLONE [${CLONE}]" -if [[ "${VERSION}" != "" && (-z "${DESTINATION}" && -z "${CLONE}") ]] ; then echo "Version was set but destination / clone was not!"; exit 1;fi -if [[ ("${DESTINATION}" != "" && "${CLONE}" != "") && -z "${VERSION}" ]] ; then echo "Destination / clone was set but version was not!"; exit 1;fi -if [[ "${DESTINATION}" != "" && "${CLONE}" == "yes" ]] ; then echo "Destination and clone was set. Pick one!"; exit 1;fi -} - -# Prints the usage -function print_usage() { -cat </` -- if the destination switch is passed (-d) then the script will check if the provided dir is a git repo and then will - switch to gh-pages of that repo and copy the generated docs to `docs//` - -USAGE: - -You can use the following options: - --v|--version - the script will apply the whole procedure for a particular library version --d|--destination - the root of destination folder where the docs should be copied. You have to use the full path. - E.g. point to spring-cloud-static folder. Can't be used with (-c) --b|--build - will run the standard build process after checking out the branch --c|--clone - will automatically clone the spring-cloud-static repo instead of providing the destination. - Obviously can't be used with (-d) - -EOF -} - - -# ========================================== -# ____ ____ _____ _____ _____ _______ -# / ____|/ ____| __ \|_ _| __ \__ __| -# | (___ | | | |__) | | | | |__) | | | -# \___ \| | | _ / | | | ___/ | | -# ____) | |____| | \ \ _| |_| | | | -# |_____/ \_____|_| \_\_____|_| |_| -# -# ========================================== - -while [[ $# > 0 ]] -do -key="$1" -case ${key} in - -v|--version) - VERSION="$2" - shift # past argument - ;; - -d|--destination) - DESTINATION="$2" - shift # past argument - ;; - -b|--build) - BUILD="yes" - ;; - -c|--clone) - CLONE="yes" - ;; - -h|--help) - print_usage - exit 0 - ;; - *) - echo "Invalid option: [$1]" - print_usage - exit 1 - ;; -esac -shift # past argument or value -done - -assert_properties -set_default_props -check_if_anything_to_sync -if [[ -z "${VERSION}" ]] ; then - retrieve_current_branch -else - switch_to_tag -fi -build_docs_if_applicable -retrieve_doc_properties -stash_changes -add_docs_from_target -checkout_previous_branch diff --git a/mvnw b/mvnw index 8d937f4c1..41c0f0c23 100755 --- a/mvnw +++ b/mvnw @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Apache Maven Wrapper startup batch script, version 3.2.0 +# Maven Start Up Batch script # # Required ENV vars: # ------------------ @@ -27,6 +27,7 @@ # # Optional ENV vars # ----------------- +# M2_HOME - location of maven2's installed home dir # MAVEN_OPTS - parameters passed to the Java VM when running Maven # e.g. to debug Maven itself, use # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @@ -35,10 +36,6 @@ if [ -z "$MAVEN_SKIP_RC" ] ; then - if [ -f /usr/local/etc/mavenrc ] ; then - . /usr/local/etc/mavenrc - fi - if [ -f /etc/mavenrc ] ; then . /etc/mavenrc fi @@ -53,7 +50,7 @@ fi cygwin=false; darwin=false; mingw=false -case "$(uname)" in +case "`uname`" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; Darwin*) darwin=true @@ -61,9 +58,9 @@ case "$(uname)" in # See https://developer.apple.com/library/mac/qa/qa1170/_index.html if [ -z "$JAVA_HOME" ]; then if [ -x "/usr/libexec/java_home" ]; then - JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME + export JAVA_HOME="`/usr/libexec/java_home`" else - JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + export JAVA_HOME="/Library/Java/Home" fi fi ;; @@ -71,38 +68,68 @@ esac if [ -z "$JAVA_HOME" ] ; then if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=$(java-config --jre-home) + JAVA_HOME=`java-config --jre-home` fi fi +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + # For Cygwin, ensure paths are in UNIX format before anything is touched if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --unix "$CLASSPATH") + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` fi # For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then - [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && - JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" fi if [ -z "$JAVA_HOME" ]; then - javaExecutable="$(which javac)" - if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then # readlink(1) is not available as standard on Solaris 10. - readLink=$(which readlink) - if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then if $darwin ; then - javaHome="$(dirname "\"$javaExecutable\"")" - javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" else - javaExecutable="$(readlink -f "\"$javaExecutable\"")" + javaExecutable="`readlink -f \"$javaExecutable\"`" fi - javaHome="$(dirname "\"$javaExecutable\"")" - javaHome=$(expr "$javaHome" : '\(.*\)/bin') + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` JAVA_HOME="$javaHome" export JAVA_HOME fi @@ -118,7 +145,7 @@ if [ -z "$JAVACMD" ] ; then JAVACMD="$JAVA_HOME/bin/java" fi else - JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" + JAVACMD="`which java`" fi fi @@ -132,9 +159,12 @@ if [ -z "$JAVA_HOME" ] ; then echo "Warning: JAVA_HOME environment variable is not set." fi +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { + if [ -z "$1" ] then echo "Path not specified to find_maven_basedir" @@ -150,99 +180,96 @@ find_maven_basedir() { fi # workaround for JBEAP-8937 (on Solaris 10/Sparc) if [ -d "${wdir}" ]; then - wdir=$(cd "$wdir/.." || exit 1; pwd) + wdir=`cd "$wdir/.."; pwd` fi # end of workaround done - printf '%s' "$(cd "$basedir" || exit 1; pwd)" + echo "${basedir}" } # concatenates all lines of a file concat_lines() { if [ -f "$1" ]; then - # Remove \r in case we run on Windows within Git Bash - # and check out the repository with auto CRLF management - # enabled. Otherwise, we may read lines that are delimited with - # \r\n and produce $'-Xarg\r' rather than -Xarg due to word - # splitting rules. - tr -s '\r\n' ' ' < "$1" - fi -} - -log() { - if [ "$MVNW_VERBOSE" = true ]; then - printf '%s\n' "$1" + echo "$(tr -s '\n' ' ' < "$1")" fi } -BASE_DIR=$(find_maven_basedir "$(dirname "$0")") +BASE_DIR=`find_maven_basedir "$(pwd)"` if [ -z "$BASE_DIR" ]; then exit 1; fi -MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR -log "$MAVEN_PROJECTBASEDIR" - ########################################################################################## # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central # This allows using the maven wrapper in projects that prohibit checking in binary data. ########################################################################################## -wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" -if [ -r "$wrapperJarPath" ]; then - log "Found $wrapperJarPath" +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi else - log "Couldn't find $wrapperJarPath, downloading it ..." - + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi if [ -n "$MVNW_REPOURL" ]; then - wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" else - wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" fi - while IFS="=" read -r key value; do - # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) - safeValue=$(echo "$value" | tr -d '\r') - case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; esac - done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" - log "Downloading from: $wrapperUrl" - + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" if $cygwin; then - wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` fi if command -v wget > /dev/null; then - log "Found wget ... using wget" - [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + wget "$jarUrl" -O "$wrapperJarPath" else - wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" fi elif command -v curl > /dev/null; then - log "Found curl ... using curl" - [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + curl -o "$wrapperJarPath" "$jarUrl" -f else - curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f fi + else - log "Falling back to using Java to download" - javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" - javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" # For Cygwin, switch paths to Windows format before running javac if $cygwin; then - javaSource=$(cygpath --path --windows "$javaSource") - javaClass=$(cygpath --path --windows "$javaClass") + javaClass=`cygpath --path --windows "$javaClass"` fi - if [ -e "$javaSource" ]; then - if [ ! -e "$javaClass" ]; then - log " - Compiling MavenWrapperDownloader.java ..." - ("$JAVA_HOME/bin/javac" "$javaSource") + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") fi - if [ -e "$javaClass" ]; then - log " - Running MavenWrapperDownloader.java ..." - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") fi fi fi @@ -251,58 +278,33 @@ fi # End of extension ########################################################################################## -# If specified, validate the SHA-256 sum of the Maven wrapper jar file -wrapperSha256Sum="" -while IFS="=" read -r key value; do - case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; - esac -done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" -if [ -n "$wrapperSha256Sum" ]; then - wrapperSha256Result=false - if command -v sha256sum > /dev/null; then - if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then - wrapperSha256Result=true - fi - elif command -v shasum > /dev/null; then - if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then - wrapperSha256Result=true - fi - else - echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." - echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." - exit 1 - fi - if [ $wrapperSha256Result = false ]; then - echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 - echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 - echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 - exit 1 - fi +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR fi - MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" # For Cygwin, switch paths to Windows format before running java if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` fi # Provide a "standardized" way to retrieve the CLI args that will # work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" export MAVEN_CMD_LINE_ARGS WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -# shellcheck disable=SC2086 # safe args exec "$JAVACMD" \ $MAVEN_OPTS \ - $MAVEN_DEBUG_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd index c4586b564..86115719e 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -18,12 +18,13 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Apache Maven Wrapper startup batch script, version 3.2.0 +@REM Maven Start Up Batch script @REM @REM Required ENV vars: @REM JAVA_HOME - location of a JDK home dir @REM @REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven @@ -45,8 +46,8 @@ if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") @REM Execute a user defined script before this one if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre @REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* -if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" :skipRcPre @setlocal @@ -119,10 +120,10 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" -FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B ) @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central @@ -133,11 +134,11 @@ if exist %WRAPPER_JAR% ( ) ) else ( if not "%MVNW_REPOURL%" == "" ( - SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" ) if "%MVNW_VERBOSE%" == "true" ( echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %WRAPPER_URL% + echo Downloading from: %DOWNLOAD_URL% ) powershell -Command "&{"^ @@ -145,7 +146,7 @@ if exist %WRAPPER_JAR% ( "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ "}" if "%MVNW_VERBOSE%" == "true" ( echo Finished downloading %WRAPPER_JAR% @@ -153,35 +154,11 @@ if exist %WRAPPER_JAR% ( ) @REM End of extension -@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file -SET WRAPPER_SHA_256_SUM="" -FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B -) -IF NOT %WRAPPER_SHA_256_SUM%=="" ( - powershell -Command "&{"^ - "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ - "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ - " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ - " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ - " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ - " exit 1;"^ - "}"^ - "}" - if ERRORLEVEL 1 goto error -) - @REM Provide a "standardized" way to retrieve the CLI args that will @REM work with both Windows and non-Windows executions. set MAVEN_CMD_LINE_ARGS=%* -%MAVEN_JAVA_EXE% ^ - %JVM_CONFIG_MAVEN_PROPS% ^ - %MAVEN_OPTS% ^ - %MAVEN_DEBUG_OPTS% ^ - -classpath %WRAPPER_JAR% ^ - "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ - %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* if ERRORLEVEL 1 goto error goto end @@ -191,15 +168,15 @@ set ERROR_CODE=1 :end @endlocal & set ERROR_CODE=%ERROR_CODE% -if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost @REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" -if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" :skipRcPost @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%"=="on" pause +if "%MAVEN_BATCH_PAUSE%" == "on" pause -if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% -cmd /C exit /B %ERROR_CODE% +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml index 5d341fa67..02934cb06 100644 --- a/pom.xml +++ b/pom.xml @@ -1,238 +1,70 @@ - - + + + 4.0.0 - spring-cloud-openfeign - 4.1.0-SNAPSHOT - pom - Spring Cloud OpenFeign - Spring Cloud OpenFeign - - org.springframework.cloud - spring-cloud-build - 4.1.0-SNAPSHOT - - + + org.springframework.cloud + spring-cloud-openfeign-docs-build + 0.0.1-SNAPSHOT + + Spring Cloud Openfeign Docs Build + Builds Spring Cloud Openfeign Docs. + https://spring.io/projects/spring-cloud-openfeign - https://github.com/spring-cloud/spring-cloud-openfeign - scm:git:git://github.com/spring-cloud/spring-cloud-openfeign.git + scm:git:https://github.com/spring-cloud/spring-cloud-openfeign.git - scm:git:ssh://git@github.com/spring-cloud/spring-cloud-openfeign.git + scm:git:git@github.com:spring-cloud/spring-cloud-openfeign.git - HEAD + https://github.com/spring-cloud/spring-cloud-openfeign - - ${basedir} - 2.11.3 - 4.1.0-SNAPSHOT + + https://github.com/spring-cloud/spring-cloud-openfeign/issues + - - 2.10 - - 2.19.1 - jacoco - reuseReports - ${project.basedir}/../target/jacoco.exec - - java + + 0.0.3 + + - org.codehaus.mojo - flatten-maven-plugin - - - org.apache.maven.plugins - maven-eclipse-plugin - ${maven-eclipse-plugin.version} + io.spring.maven.antora + antora-maven-plugin + ${io.spring.maven.antora-version} + true - false - - - .settings/org.eclipse.jdt.ui.prefs - ${main.basedir}/eclipse/org.eclipse.jdt.ui.prefs - - - - .settings/org.eclipse.jdt.core.prefs - ${main.basedir}/eclipse/org.eclipse.jdt.core.prefs - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - io.spring.javaformat - spring-javaformat-maven-plugin - - - org.basepom.maven - duplicate-finder-maven-plugin - - - mozilla/public-suffix-list.txt - + + + + + + + 9d489079e5ec46dbb238909fee5c9c29 + WB1FQYI187 + springcloudopenfeign + - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - + + + spring-snapshot + https://repo.spring.io/snapshot + + true + + + false + + + + spring-milestone + https://repo.spring.io/milestone + + - - - - org.springframework.cloud - spring-cloud-commons-dependencies - ${spring-cloud-commons.version} - pom - import - - - org.springframework.cloud - spring-cloud-openfeign-dependencies - ${project.version} - pom - import - - - org.springframework.cloud - spring-cloud-test-support - test - ${spring-cloud-commons.version} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-smile - ${jackson.version} - - - - - spring-cloud-openfeign-dependencies - spring-cloud-openfeign-core - spring-cloud-starter-openfeign - docs - - - - spring - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - sonar - - - - org.jacoco - jacoco-maven-plugin - - - pre-unit-test - - prepare-agent - - - surefireArgLine - ${project.build.directory}/jacoco.exec - - - - - post-unit-test - test - - report - - - - ${project.build.directory}/jacoco.exec - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${surefireArgLine} --add-opens=java.base/java.net=ALL-UNNAMED - - - - - - diff --git a/spring-cloud-openfeign-core/.flattened-pom.xml b/spring-cloud-openfeign-core/.flattened-pom.xml new file mode 100644 index 000000000..645f3fb9a --- /dev/null +++ b/spring-cloud-openfeign-core/.flattened-pom.xml @@ -0,0 +1,302 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-openfeign + 4.1.0-SNAPSHOT + .. + + org.springframework.cloud + spring-cloud-openfeign-core + 4.1.0-SNAPSHOT + Spring Cloud OpenFeign Core + Spring Cloud OpenFeign Core + https://spring.io/spring-cloud/spring-cloud-openfeign/spring-cloud-openfeign-core + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 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. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-openfeign.git/spring-cloud-openfeign-core + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-openfeign.git/spring-cloud-openfeign-core + https://github.com/spring-cloud/spring-cloud-openfeign + + + + org.springframework.boot + spring-boot-autoconfigure + 3.2.0-SNAPSHOT + compile + + + org.springframework.boot + spring-boot-starter-actuator + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.boot + spring-boot-starter-security + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.boot + spring-boot-starter-web + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.boot + spring-boot-starter-webflux + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.boot + spring-boot-starter-reactor-netty + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.boot + spring-boot-starter-hateoas + 3.2.0-SNAPSHOT + compile + true + + + io.netty + netty-codec-http + 4.1.97.Final + compile + true + + + io.projectreactor + reactor-core + 3.6.0-M3 + compile + true + + + org.springframework.retry + spring-retry + 2.0.3-SNAPSHOT + compile + + + javax.annotation + javax.annotation-api + + + true + + + org.springframework.boot + spring-boot-starter-aop + 3.2.0-SNAPSHOT + compile + + + org.springframework.cloud + spring-cloud-commons + 4.1.0-SNAPSHOT + compile + true + + + org.springframework.cloud + spring-cloud-context + 4.1.0-SNAPSHOT + compile + true + + + io.github.openfeign + feign-core + 12.4 + compile + true + + + io.github.openfeign.form + feign-form-spring + 3.8.0 + compile + + + commons-io + commons-io + + + commons-fileupload + commons-fileupload + + + + + commons-fileupload + commons-fileupload + 1.5 + compile + + + io.github.openfeign + feign-slf4j + 12.4 + compile + true + + + io.github.openfeign + feign-micrometer + 12.4 + compile + true + + + io.github.openfeign + feign-hc5 + 12.4 + compile + true + + + io.github.openfeign + feign-okhttp + 12.4 + compile + true + + + io.github.openfeign + feign-java11 + 12.4 + compile + true + + + com.squareup.okhttp3 + okhttp + 4.11.0 + compile + true + + + org.springframework.boot + spring-boot-autoconfigure-processor + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.boot + spring-boot-configuration-processor + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.data + spring-data-commons + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.cloud + spring-cloud-loadbalancer + 4.1.0-SNAPSHOT + compile + true + + + org.springframework.security + spring-security-oauth2-client + 6.2.0-SNAPSHOT + compile + true + + + diff --git a/spring-cloud-openfeign-core/pom.xml b/spring-cloud-openfeign-core/pom.xml deleted file mode 100644 index cc62b6478..000000000 --- a/spring-cloud-openfeign-core/pom.xml +++ /dev/null @@ -1,247 +0,0 @@ - - - 4.0.0 - - org.springframework.cloud - spring-cloud-openfeign - 4.1.0-SNAPSHOT - .. - - - https://github.com/spring-cloud/spring-cloud-openfeign - - spring-cloud-openfeign-core - jar - Spring Cloud OpenFeign Core - Spring Cloud OpenFeign Core - - ${basedir}/.. - - - - org.springframework.boot - spring-boot-autoconfigure - - - org.springframework.boot - spring-boot-starter-actuator - true - - - org.springframework.boot - spring-boot-starter-security - true - - - org.springframework.boot - spring-boot-starter-web - true - - - org.springframework.boot - spring-boot-starter-webflux - true - - - org.springframework.boot - spring-boot-starter-reactor-netty - true - - - org.springframework.boot - spring-boot-starter-hateoas - true - - - io.netty - netty-codec-http - true - - - io.projectreactor - reactor-core - true - - - org.springframework.retry - spring-retry - true - - - javax.annotation - javax.annotation-api - - - - - org.springframework.boot - spring-boot-starter-aop - - - org.springframework.cloud - spring-cloud-commons - true - - - org.springframework.cloud - spring-cloud-context - true - - - io.github.openfeign - feign-core - true - - - io.github.openfeign.form - feign-form-spring - - - - commons-io - commons-io - - - commons-fileupload - commons-fileupload - - - - - commons-fileupload - commons-fileupload - - - io.github.openfeign - feign-slf4j - true - - - io.github.openfeign - feign-micrometer - true - - - io.github.openfeign - feign-hc5 - true - - - io.github.openfeign - feign-okhttp - true - - - io.github.openfeign - feign-java11 - true - - - com.squareup.okhttp3 - okhttp - true - - - org.springframework.boot - spring-boot-autoconfigure-processor - true - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.cloud - spring-cloud-test-support - test - - - org.springframework.data - spring-data-commons - true - - - io.projectreactor - reactor-test - test - - - org.springframework.boot - spring-boot-starter-data-rest - test - - - com.googlecode.protobuf-java-format - protobuf-java-format - 1.4 - test - - - com.google.protobuf - protobuf-java - 3.19.6 - test - - - io.vavr - vavr - 0.10.4 - test - - - org.springframework.cloud - spring-cloud-loadbalancer - true - - - commons-io - commons-io - 2.11.0 - test - - - org.springframework - spring-core-test - test - - - org.junit.platform - junit-platform-launcher - test - - - org.springframework.security - spring-security-oauth2-client - true - - - - - java8plus - - [1.8,2.0) - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - -parameters - - - - - - - - diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/AnnotatedParameterProcessor.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/AnnotatedParameterProcessor.java deleted file mode 100644 index 13cfaff0d..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/AnnotatedParameterProcessor.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Collection; - -import feign.MethodMetadata; - -/** - * Feign contract method parameter processor. - * - * @author Jakub Narloch - * @author Abhijit Sarkar - */ -public interface AnnotatedParameterProcessor { - - /** - * Retrieves the processor supported annotation type. - * @return the annotation type - */ - Class getAnnotationType(); - - /** - * Process the annotated parameter. - * @param context the parameter context - * @param annotation the annotation instance - * @param method the method that contains the annotation - * @return whether the parameter is http - */ - boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method); - - /** - * Specifies the parameter context. - * - * @author Jakub Narloch - */ - interface AnnotatedParameterContext { - - /** - * Retrieves the method metadata. - * @return the method metadata - */ - MethodMetadata getMethodMetadata(); - - /** - * Retrieves the index of the parameter. - * @return the parameter index - */ - int getParameterIndex(); - - /** - * Sets the parameter name. - * @param name the name of the parameter - */ - void setParameterName(String name); - - /** - * Sets the template parameter. - * @param name the template parameter - * @param rest the existing parameter values - * @return parameters - */ - Collection setTemplateParameter(String name, Collection rest); - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/CachingCapability.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/CachingCapability.java deleted file mode 100644 index f323350bb..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/CachingCapability.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import feign.Capability; -import feign.InvocationHandlerFactory; - -import org.springframework.cache.interceptor.CacheInterceptor; - -/** - * Allows Spring's @Cache* annotations to be declared on the feign client's methods. - * - * @author Sam Kruglov - */ -public class CachingCapability implements Capability { - - private final CacheInterceptor cacheInterceptor; - - public CachingCapability(CacheInterceptor cacheInterceptor) { - this.cacheInterceptor = cacheInterceptor; - } - - @Override - public InvocationHandlerFactory enrich(InvocationHandlerFactory invocationHandlerFactory) { - return new FeignCachingInvocationHandlerFactory(invocationHandlerFactory, cacheInterceptor); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/CircuitBreakerNameResolver.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/CircuitBreakerNameResolver.java deleted file mode 100644 index 67db1158e..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/CircuitBreakerNameResolver.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.reflect.Method; - -import feign.Target; - -/** - * Used to resolve a circuitbreaker name which will be used in - * {@link org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory}. - * - * @author Kwangyong Kim - * @since 2020.0.4 - */ -public interface CircuitBreakerNameResolver { - - String resolveCircuitBreakerName(String feignClientName, Target target, Method method); - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/CollectionFormat.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/CollectionFormat.java deleted file mode 100644 index 9286b86ad..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/CollectionFormat.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Indicates which collection format should be used while processing the annotated method. - * - * @author Olga Maciaszek-Sharma - * @author Sam Kruglov - * @see feign.CollectionFormat - */ -@Target({ ElementType.METHOD, ElementType.TYPE }) -@Retention(RetentionPolicy.RUNTIME) -public @interface CollectionFormat { - - /** - * Allows setting the {@link feign.CollectionFormat} to be used while processing the - * annotated method. - * @return the {@link feign.CollectionFormat} to be used - */ - feign.CollectionFormat value(); - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/DefaultFeignLoggerFactory.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/DefaultFeignLoggerFactory.java deleted file mode 100644 index 41e9635c7..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/DefaultFeignLoggerFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2016-2022 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; - -import feign.Logger; -import feign.slf4j.Slf4jLogger; - -/** - * @author Venil Noronha - * @author Olga Maciaszek-Sharma - */ -public class DefaultFeignLoggerFactory implements FeignLoggerFactory { - - private final Logger logger; - - public DefaultFeignLoggerFactory(Logger logger) { - this.logger = logger; - } - - @Override - public Logger create(Class type) { - return this.logger != null ? this.logger : new Slf4jLogger(type); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/DefaultTargeter.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/DefaultTargeter.java deleted file mode 100644 index 29d9c2154..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/DefaultTargeter.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import feign.Feign; -import feign.Target; - -/** - * @author Spencer Gibb - */ -class DefaultTargeter implements Targeter { - - @Override - public T target(FeignClientFactoryBean factory, Feign.Builder feign, FeignClientFactory context, - Target.HardCodedTarget target) { - return feign.target(target); - } - -} 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 deleted file mode 100644 index e09cddfe4..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/EnableFeignClients.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.context.annotation.Import; - -/** - * Scans for interfaces that declare they are feign clients (via - * {@link org.springframework.cloud.openfeign.FeignClient} @FeignClient). - * Configures component scanning directives for use with - * {@link org.springframework.context.annotation.Configuration} - * @Configuration classes. - * - * @author Spencer Gibb - * @author Dave Syer - * @since 1.0 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@Import(FeignClientsRegistrar.class) -public @interface EnableFeignClients { - - /** - * Alias for the {@link #basePackages()} attribute. Allows for more concise annotation - * declarations e.g.: {@code @ComponentScan("org.my.pkg")} instead of - * {@code @ComponentScan(basePackages="org.my.pkg")}. - * @return the array of 'basePackages'. - */ - String[] value() default {}; - - /** - * Base packages to scan for annotated components. - *

- * {@link #value()} is an alias for (and mutually exclusive with) this attribute. - *

- * Use {@link #basePackageClasses()} for a type-safe alternative to String-based - * package names. - * @return the array of 'basePackages'. - */ - String[] basePackages() default {}; - - /** - * Type-safe alternative to {@link #basePackages()} for specifying the packages to - * scan for annotated components. The package of each class specified will be scanned. - *

- * Consider creating a special no-op marker class or interface in each package that - * serves no purpose other than being referenced by this attribute. - * @return the array of 'basePackageClasses'. - */ - Class[] basePackageClasses() default {}; - - /** - * A custom @Configuration for all feign clients. Can contain override - * @Bean definition for the pieces that make up the client, for instance - * {@link feign.codec.Decoder}, {@link feign.codec.Encoder}, {@link feign.Contract}. - * - * @see FeignClientsConfiguration for the defaults - * @return list of default configurations - */ - Class[] defaultConfiguration() default {}; - - /** - * List of classes annotated with @FeignClient. If not empty, disables classpath - * scanning. - * @return list of FeignClient classes - */ - Class[] clients() default {}; - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FallbackFactory.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FallbackFactory.java deleted file mode 100644 index 4d87adeb5..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FallbackFactory.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import static feign.Util.checkNotNull; - -/** - * Used to control the fallback given its cause. - * - * Ex. - * - *

- * {@code
- * // This instance will be invoked if there are errors of any kind.
- * FallbackFactory fallbackFactory = cause -> (owner, repo) -> {
- *   if (cause instanceof FeignException && ((FeignException) cause).status() == 403) {
- *     return Collections.emptyList();
- *   } else {
- *     return Arrays.asList("yogi");
- *   }
- * };
- *
- * GitHub github = FeignCircuitBreaker.builder()
- *                             ...
- *                             .target(GitHub.class, "https://api.github.com", fallbackFactory);
- * }
- * 
- * - * @param the feign interface type - */ -public interface FallbackFactory { - - /** - * Returns an instance of the fallback appropriate for the given cause. - * @param cause cause of an exception. - * @return fallback - */ - T create(Throwable cause); - - final class Default implements FallbackFactory { - - final Log logger; - - final T constant; - - public Default(T constant) { - this(constant, LogFactory.getLog(Default.class)); - } - - Default(T constant, Log logger) { - this.constant = checkNotNull(constant, "fallback"); - this.logger = checkNotNull(logger, "logger"); - } - - @Override - public T create(Throwable cause) { - if (logger.isTraceEnabled()) { - logger.trace("fallback due to: " + cause.getMessage(), cause); - } - return constant; - } - - @Override - public String toString() { - return constant.toString(); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignAutoConfiguration.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignAutoConfiguration.java deleted file mode 100644 index 4fa906c81..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignAutoConfiguration.java +++ /dev/null @@ -1,421 +0,0 @@ -/* - * Copyright 2013-2023 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; - -import java.lang.reflect.Method; -import java.net.http.HttpClient; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.X509Certificate; -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import com.fasterxml.jackson.databind.Module; -import feign.Capability; -import feign.Client; -import feign.Feign; -import feign.Target; -import feign.hc5.ApacheHttp5Client; -import feign.http2client.Http2Client; -import feign.okhttp.OkHttpClient; -import jakarta.annotation.PreDestroy; -import okhttp3.ConnectionPool; -import okhttp3.Protocol; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.aot.hint.MemberCategory; -import org.springframework.aot.hint.RuntimeHints; -import org.springframework.aot.hint.RuntimeHintsRegistrar; -import org.springframework.aot.hint.TypeReference; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cache.interceptor.CacheInterceptor; -import org.springframework.cloud.client.actuator.HasFeatures; -import org.springframework.cloud.client.circuitbreaker.CircuitBreaker; -import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; -import org.springframework.cloud.openfeign.aot.FeignChildContextInitializer; -import org.springframework.cloud.openfeign.aot.FeignClientBeanFactoryInitializationAotProcessor; -import org.springframework.cloud.openfeign.security.OAuth2AccessTokenInterceptor; -import org.springframework.cloud.openfeign.support.FeignEncoderProperties; -import org.springframework.cloud.openfeign.support.FeignHttpClientProperties; -import org.springframework.cloud.openfeign.support.PageJacksonModule; -import org.springframework.cloud.openfeign.support.SortJacksonModule; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.context.support.GenericApplicationContext; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Sort; -import org.springframework.security.oauth2.client.AuthorizedClientServiceOAuth2AuthorizedClientManager; -import org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager; -import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService; -import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; -import org.springframework.util.ClassUtils; - -/** - * @author Spencer Gibb - * @author Julien Roy - * @author Grzegorz Poznachowski - * @author Nikita Konev - * @author Tim Peeters - * @author Olga Maciaszek-Sharma - * @author Nguyen Ky Thanh - * @author Andrii Bohutskyi - * @author Kwangyong Kim - * @author Sam Kruglov - * @author Wojciech Mąka - * @author Dangzhicairang(小水牛) - * @author changjin wei(魏昌进) - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnClass(Feign.class) -@EnableConfigurationProperties({ FeignClientProperties.class, FeignHttpClientProperties.class, - FeignEncoderProperties.class }) -public class FeignAutoConfiguration { - - private static final Log LOG = LogFactory.getLog(FeignAutoConfiguration.class); - - @Autowired(required = false) - private List configurations = new ArrayList<>(); - - @Bean - public HasFeatures feignFeature() { - return HasFeatures.namedFeature("Feign", Feign.class); - } - - @Bean - public FeignClientFactory feignContext() { - FeignClientFactory context = new FeignClientFactory(); - context.setConfigurations(this.configurations); - return context; - } - - @Bean - static FeignChildContextInitializer feignChildContextInitializer(GenericApplicationContext parentContext, - FeignClientFactory feignClientFactory) { - return new FeignChildContextInitializer(parentContext, feignClientFactory); - } - - @Bean - static FeignClientBeanFactoryInitializationAotProcessor feignClientBeanFactoryInitializationCodeGenerator( - GenericApplicationContext applicationContext, FeignClientFactory feignClientFactory) { - return new FeignClientBeanFactoryInitializationAotProcessor(applicationContext, feignClientFactory); - } - - @Bean - @ConditionalOnProperty(value = "spring.cloud.openfeign.cache.enabled", matchIfMissing = true) - @ConditionalOnBean(CacheInterceptor.class) - public Capability cachingCapability(CacheInterceptor cacheInterceptor) { - return new CachingCapability(cacheInterceptor); - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass({ Module.class, Page.class, Sort.class }) - @ConditionalOnProperty(value = "spring.cloud.openfeign.autoconfiguration.jackson.enabled", havingValue = "true", - matchIfMissing = true) - protected static class FeignJacksonConfiguration { - - @Bean - @ConditionalOnMissingBean(PageJacksonModule.class) - public PageJacksonModule pageJacksonModule() { - return new PageJacksonModule(); - } - - @Bean - @ConditionalOnMissingBean(SortJacksonModule.class) - public SortJacksonModule sortModule() { - return new SortJacksonModule(); - } - - } - - @Configuration(proxyBeanMethods = false) - @Conditional(FeignCircuitBreakerDisabledConditions.class) - protected static class DefaultFeignTargeterConfiguration { - - @Bean - @ConditionalOnMissingBean - public Targeter feignTargeter() { - return new DefaultTargeter(); - } - - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(CircuitBreaker.class) - @ConditionalOnProperty(value = "spring.cloud.openfeign.circuitbreaker.enabled", havingValue = "true") - protected static class CircuitBreakerPresentFeignTargeterConfiguration { - - @Bean - @ConditionalOnMissingBean(CircuitBreakerFactory.class) - public Targeter defaultFeignTargeter() { - return new DefaultTargeter(); - } - - @Bean - @ConditionalOnMissingBean(CircuitBreakerNameResolver.class) - @ConditionalOnProperty(value = "spring.cloud.openfeign.circuitbreaker.alphanumeric-ids.enabled", - havingValue = "false") - public CircuitBreakerNameResolver circuitBreakerNameResolver() { - return new DefaultCircuitBreakerNameResolver(); - } - - @Bean - @ConditionalOnMissingBean(CircuitBreakerNameResolver.class) - @ConditionalOnProperty(value = "spring.cloud.openfeign.circuitbreaker.alphanumeric-ids.enabled", - havingValue = "true", matchIfMissing = true) - public CircuitBreakerNameResolver alphanumericCircuitBreakerNameResolver() { - return new AlphanumericCircuitBreakerNameResolver(); - } - - @SuppressWarnings("rawtypes") - @Bean - @ConditionalOnMissingBean - @ConditionalOnBean(CircuitBreakerFactory.class) - public Targeter circuitBreakerFeignTargeter(CircuitBreakerFactory circuitBreakerFactory, - @Value("${spring.cloud.openfeign.circuitbreaker.group.enabled:false}") boolean circuitBreakerGroupEnabled, - CircuitBreakerNameResolver circuitBreakerNameResolver) { - return new FeignCircuitBreakerTargeter(circuitBreakerFactory, circuitBreakerGroupEnabled, - circuitBreakerNameResolver); - } - - static class DefaultCircuitBreakerNameResolver implements CircuitBreakerNameResolver { - - @Override - public String resolveCircuitBreakerName(String feignClientName, Target target, Method method) { - return Feign.configKey(target.type(), method); - } - - } - - static class AlphanumericCircuitBreakerNameResolver extends DefaultCircuitBreakerNameResolver { - - @Override - public String resolveCircuitBreakerName(String feignClientName, Target target, Method method) { - return super.resolveCircuitBreakerName(feignClientName, target, method).replaceAll("[^a-zA-Z0-9]", ""); - } - - } - - } - - // the following configuration is for alternate feign clients if - // SC loadbalancer is not on the class path. - // see corresponding configurations in FeignLoadBalancerAutoConfiguration - // for load-balanced clients. - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(OkHttpClient.class) - @ConditionalOnMissingBean(okhttp3.OkHttpClient.class) - @ConditionalOnProperty("spring.cloud.openfeign.okhttp.enabled") - protected static class OkHttpFeignConfiguration { - - private okhttp3.OkHttpClient okHttpClient; - - @Bean - @ConditionalOnMissingBean - public okhttp3.OkHttpClient.Builder okHttpClientBuilder() { - return new okhttp3.OkHttpClient.Builder(); - } - - @Bean - @ConditionalOnMissingBean(ConnectionPool.class) - public ConnectionPool httpClientConnectionPool(FeignHttpClientProperties httpClientProperties) { - int maxTotalConnections = httpClientProperties.getMaxConnections(); - long timeToLive = httpClientProperties.getTimeToLive(); - TimeUnit ttlUnit = httpClientProperties.getTimeToLiveUnit(); - return new ConnectionPool(maxTotalConnections, timeToLive, ttlUnit); - } - - @Bean - public okhttp3.OkHttpClient okHttpClient(okhttp3.OkHttpClient.Builder builder, ConnectionPool connectionPool, - FeignHttpClientProperties httpClientProperties) { - boolean followRedirects = httpClientProperties.isFollowRedirects(); - int connectTimeout = httpClientProperties.getConnectionTimeout(); - boolean disableSslValidation = httpClientProperties.isDisableSslValidation(); - Duration readTimeout = httpClientProperties.getOkHttp().getReadTimeout(); - List protocols = httpClientProperties.getOkHttp().getProtocols().stream().map(Protocol::valueOf) - .collect(Collectors.toList()); - if (disableSslValidation) { - disableSsl(builder); - } - this.okHttpClient = builder.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS) - .followRedirects(followRedirects).readTimeout(readTimeout).connectionPool(connectionPool) - .protocols(protocols).build(); - return this.okHttpClient; - } - - private void disableSsl(okhttp3.OkHttpClient.Builder builder) { - try { - X509TrustManager disabledTrustManager = new DisableValidationTrustManager(); - TrustManager[] trustManagers = new TrustManager[1]; - trustManagers[0] = disabledTrustManager; - SSLContext sslContext = SSLContext.getInstance("SSL"); - sslContext.init(null, trustManagers, new java.security.SecureRandom()); - SSLSocketFactory disabledSSLSocketFactory = sslContext.getSocketFactory(); - builder.sslSocketFactory(disabledSSLSocketFactory, disabledTrustManager); - builder.hostnameVerifier(new TrustAllHostnames()); - } - catch (NoSuchAlgorithmException | KeyManagementException e) { - LOG.warn("Error setting SSLSocketFactory in OKHttpClient", e); - } - } - - @PreDestroy - public void destroy() { - if (this.okHttpClient != null) { - this.okHttpClient.dispatcher().executorService().shutdown(); - this.okHttpClient.connectionPool().evictAll(); - } - } - - @Bean - @ConditionalOnMissingBean(Client.class) - public Client feignClient(okhttp3.OkHttpClient client) { - return new OkHttpClient(client); - } - - /** - * A {@link X509TrustManager} that does not validate SSL certificates. - */ - class DisableValidationTrustManager implements X509TrustManager { - - @Override - public void checkClientTrusted(X509Certificate[] x509Certificates, String s) { - } - - @Override - public void checkServerTrusted(X509Certificate[] x509Certificates, String s) { - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - - } - - /** - * A {@link HostnameVerifier} that does not validate any hostnames. - */ - class TrustAllHostnames implements HostnameVerifier { - - @Override - public boolean verify(String s, SSLSession sslSession) { - return true; - } - - } - - } - - // the following configuration is for alternate feign clients if - // SC loadbalancer is not on the class path. - // see corresponding configurations in FeignLoadBalancerAutoConfiguration - // for load-balanced clients. - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(ApacheHttp5Client.class) - @ConditionalOnMissingBean(org.apache.hc.client5.http.impl.classic.CloseableHttpClient.class) - @ConditionalOnProperty(value = "spring.cloud.openfeign.httpclient.hc5.enabled", havingValue = "true", - matchIfMissing = true) - @Import(org.springframework.cloud.openfeign.clientconfig.HttpClient5FeignConfiguration.class) - protected static class HttpClient5FeignConfiguration { - - @Bean - @ConditionalOnMissingBean(Client.class) - public Client feignClient(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient5) { - return new ApacheHttp5Client(httpClient5); - } - - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(OAuth2AuthorizedClientManager.class) - @ConditionalOnProperty("spring.cloud.openfeign.oauth2.enabled") - protected static class Oauth2FeignConfiguration { - - @Bean - @ConditionalOnBean({ OAuth2AuthorizedClientService.class, ClientRegistrationRepository.class }) - @ConditionalOnMissingBean - OAuth2AuthorizedClientManager feignOAuth2AuthorizedClientManager( - ClientRegistrationRepository clientRegistrationRepository, - OAuth2AuthorizedClientService oAuth2AuthorizedClientService) { - return new AuthorizedClientServiceOAuth2AuthorizedClientManager(clientRegistrationRepository, - oAuth2AuthorizedClientService); - - } - - @Bean - @ConditionalOnBean(OAuth2AuthorizedClientManager.class) - public OAuth2AccessTokenInterceptor defaultOAuth2AccessTokenInterceptor( - @Value("${spring.cloud.openfeign.oauth2.clientRegistrationId:}") String clientRegistrationId, - OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager) { - return new OAuth2AccessTokenInterceptor(clientRegistrationId, oAuth2AuthorizedClientManager); - } - - } - - // the following configuration is for alternate feign clients if - // SC loadbalancer is not on the class path. - // see corresponding configurations in FeignLoadBalancerAutoConfiguration - // for load-balanced clients. - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass({ Http2Client.class, HttpClient.class }) - @ConditionalOnMissingBean(HttpClient.class) - @ConditionalOnProperty("spring.cloud.openfeign.http2client.enabled") - @Import(org.springframework.cloud.openfeign.clientconfig.Http2ClientFeignConfiguration.class) - protected static class Http2ClientFeignConfiguration { - - @Bean - @ConditionalOnMissingBean(Client.class) - public Client feignClient(HttpClient httpClient) { - return new Http2Client(httpClient); - } - - } - -} - -class FeignHints implements RuntimeHintsRegistrar { - - @Override - public void registerHints(RuntimeHints hints, ClassLoader classLoader) { - if (!ClassUtils.isPresent("feign.Feign", classLoader)) { - return; - } - hints.reflection().registerType(TypeReference.of(FeignClientFactoryBean.class), - hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, - MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS)); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignBuilderCustomizer.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignBuilderCustomizer.java deleted file mode 100644 index 82f5a150e..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignBuilderCustomizer.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import feign.Feign; - -/** - * Allows application to customize the Feign builder. - * - * @author Matt King - */ -@FunctionalInterface -public interface FeignBuilderCustomizer { - - void customize(Feign.Builder builder); - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCachingInvocationHandlerFactory.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCachingInvocationHandlerFactory.java deleted file mode 100644 index 1fa380bd7..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCachingInvocationHandlerFactory.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.reflect.AccessibleObject; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.util.Map; -import java.util.Optional; - -import feign.InvocationHandlerFactory; -import feign.Target; -import org.aopalliance.intercept.MethodInvocation; - -import org.springframework.cache.interceptor.CacheInterceptor; - -/** - * Allows Spring's @Cache* annotations to be declared on the feign client's methods. - * - * @author Sam Kruglov - */ -public class FeignCachingInvocationHandlerFactory implements InvocationHandlerFactory { - - private final InvocationHandlerFactory delegateFactory; - - private final CacheInterceptor cacheInterceptor; - - public FeignCachingInvocationHandlerFactory(InvocationHandlerFactory delegateFactory, - CacheInterceptor cacheInterceptor) { - this.delegateFactory = delegateFactory; - this.cacheInterceptor = cacheInterceptor; - } - - @Override - public InvocationHandler create(Target target, Map dispatch) { - final InvocationHandler delegateHandler = delegateFactory.create(target, dispatch); - return (proxy, method, argsNullable) -> { - Object[] args = Optional.ofNullable(argsNullable).orElseGet(() -> new Object[0]); - return cacheInterceptor.invoke(new MethodInvocation() { - @Override - public Method getMethod() { - return method; - } - - @Override - public Object[] getArguments() { - return args; - } - - @Override - public Object proceed() throws Throwable { - return delegateHandler.invoke(proxy, method, args); - } - - @Override - public Object getThis() { - return target; - } - - @Override - public AccessibleObject getStaticPart() { - return method; - } - }); - }; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreaker.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreaker.java deleted file mode 100644 index 7868b1ae2..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreaker.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import feign.Feign; -import feign.Target; - -import org.springframework.cloud.client.circuitbreaker.CircuitBreaker; -import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; - -/** - * Allows Feign interfaces to work with {@link CircuitBreaker}. - * - * @author Marcin Grzejszczak - * @author Andrii Bohutskyi - * @author Kwangyong Kim - * @since 3.0.0 - */ -public final class FeignCircuitBreaker { - - private FeignCircuitBreaker() { - throw new IllegalStateException("Don't instantiate a utility class"); - } - - /** - * @return builder for Feign CircuitBreaker integration - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Builder for Feign CircuitBreaker integration. - */ - public static final class Builder extends Feign.Builder { - - private CircuitBreakerFactory circuitBreakerFactory; - - private String feignClientName; - - private boolean circuitBreakerGroupEnabled; - - private CircuitBreakerNameResolver circuitBreakerNameResolver; - - Builder circuitBreakerFactory(CircuitBreakerFactory circuitBreakerFactory) { - this.circuitBreakerFactory = circuitBreakerFactory; - return this; - } - - Builder feignClientName(String feignClientName) { - this.feignClientName = feignClientName; - return this; - } - - Builder circuitBreakerGroupEnabled(boolean circuitBreakerGroupEnabled) { - this.circuitBreakerGroupEnabled = circuitBreakerGroupEnabled; - return this; - } - - Builder circuitBreakerNameResolver(CircuitBreakerNameResolver circuitBreakerNameResolver) { - this.circuitBreakerNameResolver = circuitBreakerNameResolver; - return this; - } - - public T target(Target target, T fallback) { - return build(fallback != null ? new FallbackFactory.Default<>(fallback) : null).newInstance(target); - } - - public T target(Target target, FallbackFactory fallbackFactory) { - return build(fallbackFactory).newInstance(target); - } - - @Override - public T target(Target target) { - return build(null).newInstance(target); - } - - public Feign build(final FallbackFactory nullableFallbackFactory) { - super.invocationHandlerFactory((target, dispatch) -> new FeignCircuitBreakerInvocationHandler( - circuitBreakerFactory, feignClientName, target, dispatch, nullableFallbackFactory, - circuitBreakerGroupEnabled, circuitBreakerNameResolver)); - return super.build(); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerDisabledConditions.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerDisabledConditions.java deleted file mode 100644 index a3997d52a..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerDisabledConditions.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; - -class FeignCircuitBreakerDisabledConditions extends AnyNestedCondition { - - FeignCircuitBreakerDisabledConditions() { - super(ConfigurationPhase.PARSE_CONFIGURATION); - } - - @ConditionalOnMissingClass("org.springframework.cloud.client.circuitbreaker.CircuitBreaker") - static class CircuitBreakerClassMissing { - - } - - @ConditionalOnProperty(value = "spring.cloud.openfeign.circuitbreaker.enabled", havingValue = "false", - matchIfMissing = true) - static class CircuitBreakerDisabled { - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerInvocationHandler.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerInvocationHandler.java deleted file mode 100644 index 048e24045..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerInvocationHandler.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright 2013-2023 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; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.function.Function; -import java.util.function.Supplier; - -import feign.InvocationHandlerFactory; -import feign.Target; - -import org.springframework.cloud.client.circuitbreaker.CircuitBreaker; -import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; -import org.springframework.cloud.client.circuitbreaker.NoFallbackAvailableException; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.context.request.RequestContextHolder; - -import static feign.Util.checkNotNull; - -/** - * @author Marcin Grzejszczak - * @author Olga Maciaszek-Sharma - * @author Niang - * @author Bohutskyi - * @author kim - * @author Vicasong - */ -class FeignCircuitBreakerInvocationHandler implements InvocationHandler { - - private final CircuitBreakerFactory factory; - - private final String feignClientName; - - private final Target target; - - private final Map dispatch; - - private final FallbackFactory nullableFallbackFactory; - - private final Map fallbackMethodMap; - - private final boolean circuitBreakerGroupEnabled; - - private final CircuitBreakerNameResolver circuitBreakerNameResolver; - - FeignCircuitBreakerInvocationHandler(CircuitBreakerFactory factory, String feignClientName, Target target, - Map dispatch, FallbackFactory nullableFallbackFactory, - boolean circuitBreakerGroupEnabled, CircuitBreakerNameResolver circuitBreakerNameResolver) { - this.factory = factory; - this.feignClientName = feignClientName; - this.target = checkNotNull(target, "target"); - this.dispatch = checkNotNull(dispatch, "dispatch"); - this.fallbackMethodMap = toFallbackMethod(dispatch); - this.nullableFallbackFactory = nullableFallbackFactory; - this.circuitBreakerGroupEnabled = circuitBreakerGroupEnabled; - this.circuitBreakerNameResolver = circuitBreakerNameResolver; - } - - @Override - public Object invoke(final Object proxy, final Method method, final Object[] args) { - // early exit if the invoked method is from java.lang.Object - // code is the same as ReflectiveFeign.FeignInvocationHandler - if ("equals".equals(method.getName())) { - try { - Object otherHandler = args.length > 0 && args[0] != null ? Proxy.getInvocationHandler(args[0]) : null; - return equals(otherHandler); - } - catch (IllegalArgumentException e) { - return false; - } - } - else if ("hashCode".equals(method.getName())) { - return hashCode(); - } - else if ("toString".equals(method.getName())) { - return toString(); - } - - String circuitName = circuitBreakerNameResolver.resolveCircuitBreakerName(feignClientName, target, method); - CircuitBreaker circuitBreaker = circuitBreakerGroupEnabled ? factory.create(circuitName, feignClientName) - : factory.create(circuitName); - Supplier supplier = asSupplier(method, args); - if (this.nullableFallbackFactory != null) { - Function fallbackFunction = throwable -> { - Object fallback = this.nullableFallbackFactory.create(throwable); - try { - return this.fallbackMethodMap.get(method).invoke(fallback, args); - } - catch (Exception exception) { - unwrapAndRethrow(exception); - } - return null; - }; - return circuitBreaker.run(supplier, fallbackFunction); - } - return circuitBreaker.run(supplier); - } - - private void unwrapAndRethrow(Exception exception) { - if (exception instanceof InvocationTargetException || exception instanceof NoFallbackAvailableException) { - Throwable underlyingException = exception.getCause(); - if (underlyingException instanceof RuntimeException) { - throw (RuntimeException) underlyingException; - } - if (underlyingException != null) { - throw new IllegalStateException(underlyingException); - } - throw new IllegalStateException(exception); - } - } - - private Supplier asSupplier(final Method method, final Object[] args) { - final RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); - final Thread caller = Thread.currentThread(); - return () -> { - boolean isAsync = caller != Thread.currentThread(); - try { - if (isAsync) { - RequestContextHolder.setRequestAttributes(requestAttributes); - } - return dispatch.get(method).invoke(args); - } - catch (RuntimeException throwable) { - throw throwable; - } - catch (Throwable throwable) { - throw new RuntimeException(throwable); - } - finally { - if (isAsync) { - RequestContextHolder.resetRequestAttributes(); - } - } - }; - } - - /** - * If the method param of {@link InvocationHandler#invoke(Object, Method, Object[])} - * is not accessible, i.e in a package-private interface, the fallback call will cause - * of access restrictions. But methods in dispatch are copied methods. So setting - * access to dispatch method doesn't take effect to the method in - * InvocationHandler.invoke. Use map to store a copy of method to invoke the fallback - * to bypass this and reducing the count of reflection calls. - * @return cached methods map for fallback invoking - */ - static Map toFallbackMethod(Map dispatch) { - Map result = new LinkedHashMap<>(); - for (Method method : dispatch.keySet()) { - method.setAccessible(true); - result.put(method, method); - } - return result; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof FeignCircuitBreakerInvocationHandler other) { - return this.target.equals(other.target); - } - return false; - } - - @Override - public int hashCode() { - return this.target.hashCode(); - } - - @Override - public String toString() { - return this.target.toString(); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerTargeter.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerTargeter.java deleted file mode 100644 index cdc8df415..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerTargeter.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import feign.Feign; -import feign.Target; - -import org.springframework.beans.factory.FactoryBean; -import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; -import org.springframework.util.StringUtils; - -/** - * @author 黄学敏(huangxuemin) - */ -@SuppressWarnings("unchecked") -class FeignCircuitBreakerTargeter implements Targeter { - - private final CircuitBreakerFactory circuitBreakerFactory; - - private final boolean circuitBreakerGroupEnabled; - - private final CircuitBreakerNameResolver circuitBreakerNameResolver; - - FeignCircuitBreakerTargeter(CircuitBreakerFactory circuitBreakerFactory, boolean circuitBreakerGroupEnabled, - CircuitBreakerNameResolver circuitBreakerNameResolver) { - this.circuitBreakerFactory = circuitBreakerFactory; - this.circuitBreakerGroupEnabled = circuitBreakerGroupEnabled; - this.circuitBreakerNameResolver = circuitBreakerNameResolver; - } - - @Override - public T target(FeignClientFactoryBean factory, Feign.Builder feign, FeignClientFactory context, - Target.HardCodedTarget target) { - if (!(feign instanceof FeignCircuitBreaker.Builder builder)) { - return feign.target(target); - } - String name = !StringUtils.hasText(factory.getContextId()) ? factory.getName() : factory.getContextId(); - Class fallback = factory.getFallback(); - if (fallback != void.class) { - return targetWithFallback(name, context, target, builder, fallback); - } - Class fallbackFactory = factory.getFallbackFactory(); - if (fallbackFactory != void.class) { - return targetWithFallbackFactory(name, context, target, builder, fallbackFactory); - } - return builder(name, builder).target(target); - } - - private T targetWithFallbackFactory(String feignClientName, FeignClientFactory context, - Target.HardCodedTarget target, FeignCircuitBreaker.Builder builder, Class fallbackFactoryClass) { - FallbackFactory fallbackFactory = (FallbackFactory) getFromContext("fallbackFactory", - feignClientName, context, fallbackFactoryClass, FallbackFactory.class); - return builder(feignClientName, builder).target(target, fallbackFactory); - } - - private T targetWithFallback(String feignClientName, FeignClientFactory context, - Target.HardCodedTarget target, FeignCircuitBreaker.Builder builder, Class fallback) { - T fallbackInstance = getFromContext("fallback", feignClientName, context, fallback, target.type()); - return builder(feignClientName, builder).target(target, fallbackInstance); - } - - private T getFromContext(String fallbackMechanism, String feignClientName, FeignClientFactory context, - Class beanType, Class targetType) { - Object fallbackInstance = context.getInstance(feignClientName, beanType); - if (fallbackInstance == null) { - throw new IllegalStateException( - String.format("No " + fallbackMechanism + " instance of type %s found for feign client %s", - beanType, feignClientName)); - } - - if (fallbackInstance instanceof FactoryBean factoryBean) { - try { - fallbackInstance = factoryBean.getObject(); - } - catch (Exception e) { - throw new IllegalStateException(fallbackMechanism + " create fail", e); - } - - if (!targetType.isAssignableFrom(fallbackInstance.getClass())) { - throw new IllegalStateException(String.format("Incompatible " + fallbackMechanism - + " instance. Fallback/fallbackFactory of type %s is not assignable to %s for feign client %s", - fallbackInstance.getClass(), targetType, feignClientName)); - } - - } - else { - if (!targetType.isAssignableFrom(beanType)) { - throw new IllegalStateException(String.format("Incompatible " + fallbackMechanism - + " instance. Fallback/fallbackFactory of type %s is not assignable to %s for feign client %s", - beanType, targetType, feignClientName)); - } - } - return (T) fallbackInstance; - } - - private FeignCircuitBreaker.Builder builder(String feignClientName, FeignCircuitBreaker.Builder builder) { - return builder.circuitBreakerFactory(circuitBreakerFactory).feignClientName(feignClientName) - .circuitBreakerGroupEnabled(circuitBreakerGroupEnabled) - .circuitBreakerNameResolver(circuitBreakerNameResolver); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClient.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClient.java deleted file mode 100644 index ad3941cfe..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClient.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2013-2022 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; - -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.core.annotation.AliasFor; - -/** - * Annotation for interfaces declaring that a REST client with that interface should be - * created (e.g. for autowiring into another component). If SC LoadBalancer is available - * it will be used to load balance the backend requests, and the load balancer can be - * configured using the same name (i.e. value) as the feign client. - * - * @author Spencer Gibb - * @author Venil Noronha - * @author Olga Maciaszek-Sharma - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Inherited -public @interface FeignClient { - - /** - * The name of the service with optional protocol prefix. Synonym for {@link #name() - * name}. A name must be specified for all clients, whether or not a url is provided. - * Can be specified as property key, eg: ${propertyKey}. - * @return the name of the service with optional protocol prefix - */ - @AliasFor("name") - String value() default ""; - - /** - * This will be used as the bean name instead of name if present, but will not be used - * as a service id. - * @return bean name instead of name if present - */ - String contextId() default ""; - - /** - * @return The service id with optional protocol prefix. Synonym for {@link #value() - * value}. - */ - @AliasFor("value") - String name() default ""; - - /** - * @return the @Qualifiers value for the feign client. - */ - String[] qualifiers() default {}; - - /** - * @return an absolute URL or resolvable hostname (the protocol is optional). - */ - String url() default ""; - - /** - * @return whether 404s should be decoded instead of throwing FeignExceptions - */ - boolean dismiss404() default false; - - /** - * A custom configuration class for the feign client. Can contain override - * @Bean definition for the pieces that make up the client, for instance - * {@link feign.codec.Decoder}, {@link feign.codec.Encoder}, {@link feign.Contract}. - * - * @see FeignClientsConfiguration for the defaults - * @return list of configurations for feign client - */ - Class[] configuration() default {}; - - /** - * Fallback class for the specified Feign client interface. The fallback class must - * implement the interface annotated by this annotation and be a valid spring bean. - * @return fallback class for the specified Feign client interface - */ - Class fallback() default void.class; - - /** - * Define a fallback factory for the specified Feign client interface. The fallback - * factory must produce instances of fallback classes that implement the interface - * annotated by {@link FeignClient}. The fallback factory must be a valid spring bean. - * - * @see FallbackFactory for details. - * @return fallback factory for the specified Feign client interface - */ - Class fallbackFactory() default void.class; - - /** - * @return path prefix to be used by all method-level mappings. - */ - String path() default ""; - - /** - * @return whether to mark the feign proxy as a primary bean. Defaults to true. - */ - boolean primary() default true; - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientBuilder.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientBuilder.java deleted file mode 100644 index 227feb5b4..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientBuilder.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import feign.Feign; - -import org.springframework.context.ApplicationContext; - -/** - * A builder for creating Feign clients without using the {@link FeignClient} annotation. - *

- * This builder builds the Feign client exactly like it would be created by using the - * {@link FeignClient} annotation. - * - * @author Sven Döring - * @author Matt King - * @author Sam Kruglov - * @author Olga Maciaszek-Sharma - */ -public class FeignClientBuilder { - - private final ApplicationContext applicationContext; - - public FeignClientBuilder(final ApplicationContext applicationContext) { - this.applicationContext = applicationContext; - } - - public Builder forType(final Class type, final String name) { - return new Builder<>(this.applicationContext, type, name); - } - - public Builder forType(final Class type, final FeignClientFactoryBean clientFactoryBean, - final String name) { - return new Builder<>(this.applicationContext, clientFactoryBean, type, name); - } - - /** - * Builder of feign targets. - * - * @param type of target - */ - public static final class Builder { - - private final FeignClientFactoryBean feignClientFactoryBean; - - private Builder(final ApplicationContext applicationContext, final Class type, final String name) { - this(applicationContext, new FeignClientFactoryBean(), type, name); - } - - private Builder(final ApplicationContext applicationContext, final FeignClientFactoryBean clientFactoryBean, - final Class type, final String name) { - this.feignClientFactoryBean = clientFactoryBean; - - this.feignClientFactoryBean.setApplicationContext(applicationContext); - this.feignClientFactoryBean.setType(type); - this.feignClientFactoryBean.setName(FeignClientsRegistrar.getName(name)); - this.feignClientFactoryBean.setContextId(FeignClientsRegistrar.getName(name)); - this.feignClientFactoryBean.setInheritParentContext(true); - // preset default values - these values resemble the default values on the - // FeignClient annotation - this.url("").path("").dismiss404(false); - } - - public Builder url(final String url) { - this.feignClientFactoryBean.setUrl(FeignClientsRegistrar.getUrl(url)); - return this; - } - - /** - * Applies a {@link FeignBuilderCustomizer} to the underlying - * {@link Feign.Builder}. May be called multiple times. - * @param customizer applied in the same order as supplied here after applying - * customizers found in the context. - * @return the {@link Builder} with the customizer added - */ - public Builder customize(final FeignBuilderCustomizer customizer) { - this.feignClientFactoryBean.addCustomizer(customizer); - return this; - } - - public Builder contextId(final String contextId) { - this.feignClientFactoryBean.setContextId(contextId); - return this; - } - - public Builder path(final String path) { - this.feignClientFactoryBean.setPath(FeignClientsRegistrar.getPath(path)); - return this; - } - - public Builder dismiss404(final boolean dismiss404) { - this.feignClientFactoryBean.setDismiss404(dismiss404); - return this; - } - - public Builder inheritParentContext(final boolean inheritParentContext) { - this.feignClientFactoryBean.setInheritParentContext(inheritParentContext); - return this; - } - - public Builder fallback(final Class fallback) { - FeignClientsRegistrar.validateFallback(fallback); - this.feignClientFactoryBean.setFallback(fallback); - return this; - } - - /** - * @return the created Feign client - */ - public T build() { - return this.feignClientFactoryBean.getTarget(); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactory.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactory.java deleted file mode 100644 index 2ef8ba662..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.HashMap; -import java.util.Map; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.BeanFactoryUtils; -import org.springframework.cloud.context.named.NamedContextFactory; -import org.springframework.context.ApplicationContextInitializer; -import org.springframework.context.support.GenericApplicationContext; -import org.springframework.lang.Nullable; - -/** - * A factory that creates instances of feign classes. It creates a Spring - * ApplicationContext per client name, and extracts the beans that it needs from there. - * - * @author Spencer Gibb - * @author Dave Syer - * @author Matt King - * @author Jasbir Singh - * @author Olga Maciaszek-Sharma - */ -public class FeignClientFactory extends NamedContextFactory { - - public FeignClientFactory() { - this(new HashMap<>()); - } - - public FeignClientFactory( - Map> applicationContextInitializers) { - super(FeignClientsConfiguration.class, "spring.cloud.openfeign", "spring.cloud.openfeign.client.name", - applicationContextInitializers); - } - - @Nullable - public T getInstanceWithoutAncestors(String name, Class type) { - try { - return BeanFactoryUtils.beanOfType(getContext(name), type); - } - catch (BeansException ex) { - return null; - } - } - - @Nullable - public Map getInstancesWithoutAncestors(String name, Class type) { - return getContext(name).getBeansOfType(type); - } - - public T getInstance(String contextName, String beanName, Class type) { - return getContext(contextName).getBean(beanName, type); - } - - @SuppressWarnings("unchecked") - public FeignClientFactory withApplicationContextInitializers(Map applicationContextInitializers) { - Map> convertedInitializers = new HashMap<>(); - applicationContextInitializers.keySet() - .forEach(contextId -> convertedInitializers.put(contextId, - (ApplicationContextInitializer) applicationContextInitializers - .get(contextId))); - return new FeignClientFactory(convertedInitializers); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactoryBean.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactoryBean.java deleted file mode 100644 index 5ae1c6e0c..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactoryBean.java +++ /dev/null @@ -1,675 +0,0 @@ -/* - * Copyright 2013-2023 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; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.TimeUnit; - -import feign.Capability; -import feign.Client; -import feign.Contract; -import feign.ExceptionPropagationPolicy; -import feign.Feign; -import feign.Logger; -import feign.QueryMapEncoder; -import feign.Request; -import feign.RequestInterceptor; -import feign.ResponseInterceptor; -import feign.Retryer; -import feign.Target.HardCodedTarget; -import feign.codec.Decoder; -import feign.codec.Encoder; -import feign.codec.ErrorDecoder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.BeanUtils; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.cloud.openfeign.clientconfig.FeignClientConfigurer; -import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient; -import org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.core.annotation.AnnotationAwareOrderComparator; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; - -/** - * @author Spencer Gibb - * @author Venil Noronha - * @author Eko Kurniawan Khannedy - * @author Gregor Zurowski - * @author Matt King - * @author Olga Maciaszek-Sharma - * @author Ilia Ilinykh - * @author Marcin Grzejszczak - * @author Jonatan Ivanov - * @author Sam Kruglov - * @author Jasbir Singh - * @author Hyeonmin Park - * @author Felix Dittrich - * @author Dominique Villard - */ -public class FeignClientFactoryBean - implements FactoryBean, InitializingBean, ApplicationContextAware, BeanFactoryAware { - - /*********************************** - * WARNING! Nothing in this class should be @Autowired. It causes NPEs because of some - * lifecycle race condition. - ***********************************/ - - private static final Log LOG = LogFactory.getLog(FeignClientFactoryBean.class); - - private Class type; - - private String name; - - private String url; - - private String contextId; - - private String path; - - private boolean dismiss404; - - private boolean inheritParentContext = true; - - private ApplicationContext applicationContext; - - private BeanFactory beanFactory; - - private Class fallback = void.class; - - private Class fallbackFactory = void.class; - - private int readTimeoutMillis = new Request.Options().readTimeoutMillis(); - - private int connectTimeoutMillis = new Request.Options().connectTimeoutMillis(); - - private boolean followRedirects = new Request.Options().isFollowRedirects(); - - private boolean refreshableClient = false; - - private final List additionalCustomizers = new ArrayList<>(); - - private String[] qualifiers = new String[] {}; - - // For AOT testing - public FeignClientFactoryBean() { - if (LOG.isDebugEnabled()) { - LOG.debug("Creating a FeignClientFactoryBean."); - } - } - - @Override - public void afterPropertiesSet() { - Assert.hasText(contextId, "Context id must be set"); - Assert.hasText(name, "Name must be set"); - } - - protected Feign.Builder feign(FeignClientFactory context) { - FeignLoggerFactory loggerFactory = get(context, FeignLoggerFactory.class); - Logger logger = loggerFactory.create(type); - - // @formatter:off - Feign.Builder builder = get(context, Feign.Builder.class) - // required values - .logger(logger) - .encoder(get(context, Encoder.class)) - .decoder(get(context, Decoder.class)) - .contract(get(context, Contract.class)); - // @formatter:on - - configureFeign(context, builder); - - return builder; - } - - private void applyBuildCustomizers(FeignClientFactory context, Feign.Builder builder) { - Map customizerMap = context.getInstances(contextId, - FeignBuilderCustomizer.class); - - if (customizerMap != null) { - customizerMap.values().stream().sorted(AnnotationAwareOrderComparator.INSTANCE) - .forEach(feignBuilderCustomizer -> feignBuilderCustomizer.customize(builder)); - } - additionalCustomizers.forEach(customizer -> customizer.customize(builder)); - } - - protected void configureFeign(FeignClientFactory context, Feign.Builder builder) { - FeignClientProperties properties = beanFactory != null ? beanFactory.getBean(FeignClientProperties.class) - : applicationContext.getBean(FeignClientProperties.class); - - FeignClientConfigurer feignClientConfigurer = getOptional(context, FeignClientConfigurer.class); - setInheritParentContext(feignClientConfigurer.inheritParentConfiguration()); - - if (properties != null && inheritParentContext) { - if (properties.isDefaultToProperties()) { - configureUsingConfiguration(context, builder); - configureUsingProperties(properties.getConfig().get(properties.getDefaultConfig()), builder); - configureUsingProperties(properties.getConfig().get(contextId), builder); - } - else { - configureUsingProperties(properties.getConfig().get(properties.getDefaultConfig()), builder); - configureUsingProperties(properties.getConfig().get(contextId), builder); - configureUsingConfiguration(context, builder); - } - } - else { - configureUsingConfiguration(context, builder); - } - } - - protected void configureUsingConfiguration(FeignClientFactory context, Feign.Builder builder) { - Logger.Level level = getInheritedAwareOptional(context, Logger.Level.class); - if (level != null) { - builder.logLevel(level); - } - Retryer retryer = getInheritedAwareOptional(context, Retryer.class); - if (retryer != null) { - builder.retryer(retryer); - } - ErrorDecoder errorDecoder = getInheritedAwareOptional(context, ErrorDecoder.class); - if (errorDecoder != null) { - builder.errorDecoder(errorDecoder); - } - else { - FeignErrorDecoderFactory errorDecoderFactory = getOptional(context, FeignErrorDecoderFactory.class); - if (errorDecoderFactory != null) { - ErrorDecoder factoryErrorDecoder = errorDecoderFactory.create(type); - builder.errorDecoder(factoryErrorDecoder); - } - } - Request.Options options = getInheritedAwareOptional(context, Request.Options.class); - if (options == null) { - options = getOptionsByName(context, contextId); - } - - if (options != null) { - builder.options(options); - readTimeoutMillis = options.readTimeoutMillis(); - connectTimeoutMillis = options.connectTimeoutMillis(); - followRedirects = options.isFollowRedirects(); - } - Map requestInterceptors = getInheritedAwareInstances(context, - RequestInterceptor.class); - if (requestInterceptors != null) { - List interceptors = new ArrayList<>(requestInterceptors.values()); - AnnotationAwareOrderComparator.sort(interceptors); - builder.requestInterceptors(interceptors); - } - ResponseInterceptor responseInterceptor = getInheritedAwareOptional(context, ResponseInterceptor.class); - if (responseInterceptor != null) { - builder.responseInterceptor(responseInterceptor); - } - QueryMapEncoder queryMapEncoder = getInheritedAwareOptional(context, QueryMapEncoder.class); - if (queryMapEncoder != null) { - builder.queryMapEncoder(queryMapEncoder); - } - if (dismiss404) { - builder.dismiss404(); - } - ExceptionPropagationPolicy exceptionPropagationPolicy = getInheritedAwareOptional(context, - ExceptionPropagationPolicy.class); - if (exceptionPropagationPolicy != null) { - builder.exceptionPropagationPolicy(exceptionPropagationPolicy); - } - - Map capabilities = getInheritedAwareInstances(context, Capability.class); - if (capabilities != null) { - capabilities.values().stream().sorted(AnnotationAwareOrderComparator.INSTANCE) - .forEach(builder::addCapability); - } - } - - protected void configureUsingProperties(FeignClientProperties.FeignClientConfiguration config, - Feign.Builder builder) { - if (config == null) { - return; - } - - if (config.getLoggerLevel() != null) { - builder.logLevel(config.getLoggerLevel()); - } - - if (!refreshableClient) { - connectTimeoutMillis = config.getConnectTimeout() != null ? config.getConnectTimeout() - : connectTimeoutMillis; - readTimeoutMillis = config.getReadTimeout() != null ? config.getReadTimeout() : readTimeoutMillis; - followRedirects = config.isFollowRedirects() != null ? config.isFollowRedirects() : followRedirects; - - builder.options(new Request.Options(connectTimeoutMillis, TimeUnit.MILLISECONDS, readTimeoutMillis, - TimeUnit.MILLISECONDS, followRedirects)); - } - - if (config.getRetryer() != null) { - Retryer retryer = getOrInstantiate(config.getRetryer()); - builder.retryer(retryer); - } - - if (config.getErrorDecoder() != null) { - ErrorDecoder errorDecoder = getOrInstantiate(config.getErrorDecoder()); - builder.errorDecoder(errorDecoder); - } - - if (config.getRequestInterceptors() != null && !config.getRequestInterceptors().isEmpty()) { - // this will add request interceptor to builder, not replace existing - for (Class bean : config.getRequestInterceptors()) { - RequestInterceptor interceptor = getOrInstantiate(bean); - builder.requestInterceptor(interceptor); - } - } - - if (config.getResponseInterceptor() != null) { - builder.responseInterceptor(getOrInstantiate(config.getResponseInterceptor())); - } - - if (config.getDismiss404() != null) { - if (config.getDismiss404()) { - builder.dismiss404(); - } - } - - if (Objects.nonNull(config.getEncoder())) { - builder.encoder(getOrInstantiate(config.getEncoder())); - } - - addDefaultRequestHeaders(config, builder); - addDefaultQueryParams(config, builder); - - if (Objects.nonNull(config.getDecoder())) { - builder.decoder(getOrInstantiate(config.getDecoder())); - } - - if (Objects.nonNull(config.getContract())) { - builder.contract(getOrInstantiate(config.getContract())); - } - - if (Objects.nonNull(config.getExceptionPropagationPolicy())) { - builder.exceptionPropagationPolicy(config.getExceptionPropagationPolicy()); - } - - if (config.getCapabilities() != null) { - config.getCapabilities().stream().map(this::getOrInstantiate).forEach(builder::addCapability); - } - - if (config.getQueryMapEncoder() != null) { - builder.queryMapEncoder(getOrInstantiate(config.getQueryMapEncoder())); - } - } - - private void addDefaultQueryParams(FeignClientProperties.FeignClientConfiguration config, Feign.Builder builder) { - Map> defaultQueryParameters = config.getDefaultQueryParameters(); - if (Objects.nonNull(defaultQueryParameters)) { - builder.requestInterceptor(requestTemplate -> { - Map> queries = requestTemplate.queries(); - defaultQueryParameters.keySet().forEach(key -> { - if (!queries.containsKey(key)) { - requestTemplate.query(key, defaultQueryParameters.get(key)); - } - }); - }); - } - } - - private void addDefaultRequestHeaders(FeignClientProperties.FeignClientConfiguration config, - Feign.Builder builder) { - Map> defaultRequestHeaders = config.getDefaultRequestHeaders(); - if (Objects.nonNull(defaultRequestHeaders)) { - builder.requestInterceptor(requestTemplate -> { - Map> headers = requestTemplate.headers(); - defaultRequestHeaders.keySet().forEach(key -> { - if (!headers.containsKey(key)) { - requestTemplate.header(key, defaultRequestHeaders.get(key)); - } - }); - }); - } - } - - private T getOrInstantiate(Class tClass) { - try { - return beanFactory != null ? beanFactory.getBean(tClass) : applicationContext.getBean(tClass); - } - catch (NoSuchBeanDefinitionException e) { - return BeanUtils.instantiateClass(tClass); - } - } - - protected T get(FeignClientFactory context, Class type) { - T instance = context.getInstance(contextId, type); - if (instance == null) { - throw new IllegalStateException("No bean found of type " + type + " for " + contextId); - } - return instance; - } - - protected T getOptional(FeignClientFactory context, Class type) { - return context.getInstance(contextId, type); - } - - protected T getInheritedAwareOptional(FeignClientFactory context, Class type) { - if (inheritParentContext) { - return getOptional(context, type); - } - else { - return context.getInstanceWithoutAncestors(contextId, type); - } - } - - protected Map getInheritedAwareInstances(FeignClientFactory context, Class type) { - if (inheritParentContext) { - return context.getInstances(contextId, type); - } - else { - return context.getInstancesWithoutAncestors(contextId, type); - } - } - - protected T loadBalance(Feign.Builder builder, FeignClientFactory context, HardCodedTarget target) { - Client client = getOptional(context, Client.class); - if (client != null) { - builder.client(client); - applyBuildCustomizers(context, builder); - Targeter targeter = get(context, Targeter.class); - return targeter.target(this, builder, context, target); - } - - throw new IllegalStateException( - "No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?"); - } - - /** - * Meant to get Options bean from context with bean name. - * @param context context of Feign client - * @param contextId name of feign client - * @return returns Options found in context - */ - protected Request.Options getOptionsByName(FeignClientFactory context, String contextId) { - if (refreshableClient) { - return context.getInstance(contextId, Request.Options.class.getCanonicalName() + "-" + contextId, - Request.Options.class); - } - return null; - } - - @Override - public Object getObject() { - return getTarget(); - } - - /** - * @param the target type of the Feign client - * @return a {@link Feign} client created with the specified data and the context - * information - */ - @SuppressWarnings("unchecked") - T getTarget() { - FeignClientFactory feignClientFactory = beanFactory != null ? beanFactory.getBean(FeignClientFactory.class) - : applicationContext.getBean(FeignClientFactory.class); - Feign.Builder builder = feign(feignClientFactory); - if (!StringUtils.hasText(url) && !isUrlAvailableInConfig(contextId)) { - - if (LOG.isInfoEnabled()) { - LOG.info("For '" + name + "' URL not provided. Will try picking an instance via load-balancing."); - } - if (!name.startsWith("http")) { - url = "http://" + name; - } - else { - url = name; - } - url += cleanPath(); - return (T) loadBalance(builder, feignClientFactory, new HardCodedTarget<>(type, name, url)); - } - if (StringUtils.hasText(url) && !url.startsWith("http")) { - url = "http://" + url; - } - String url = this.url + cleanPath(); - Client client = getOptional(feignClientFactory, Client.class); - if (client != null) { - if (client instanceof FeignBlockingLoadBalancerClient) { - // not load balancing because we have a url, - // but Spring Cloud LoadBalancer is on the classpath, so unwrap - client = ((FeignBlockingLoadBalancerClient) client).getDelegate(); - } - if (client instanceof RetryableFeignBlockingLoadBalancerClient) { - // not load balancing because we have a url, - // but Spring Cloud LoadBalancer is on the classpath, so unwrap - client = ((RetryableFeignBlockingLoadBalancerClient) client).getDelegate(); - } - builder.client(client); - } - - applyBuildCustomizers(feignClientFactory, builder); - - Targeter targeter = get(feignClientFactory, Targeter.class); - return targeter.target(this, builder, feignClientFactory, resolveTarget(feignClientFactory, contextId, url)); - } - - private String cleanPath() { - if (path == null) { - return ""; - } - String path = this.path.trim(); - if (StringUtils.hasLength(path)) { - if (!path.startsWith("/")) { - path = "/" + path; - } - if (path.endsWith("/")) { - path = path.substring(0, path.length() - 1); - } - } - return path; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private HardCodedTarget resolveTarget(FeignClientFactory context, String contextId, String url) { - if (StringUtils.hasText(url)) { - return new HardCodedTarget(type, name, url); - } - - if (refreshableClient) { - RefreshableUrl refreshableUrl = context.getInstance(contextId, - RefreshableUrl.class.getCanonicalName() + "-" + contextId, RefreshableUrl.class); - if (Objects.nonNull(refreshableUrl) && StringUtils.hasText(refreshableUrl.getUrl())) { - return new RefreshableHardCodedTarget<>(type, name, refreshableUrl); - } - } - FeignClientProperties.FeignClientConfiguration config = findConfigByKey(contextId); - if (Objects.isNull(config) || !StringUtils.hasText(config.getUrl())) { - throw new IllegalStateException( - "Provide Feign client URL either in @FeignClient() or in config properties."); - } - - return new PropertyBasedTarget(type, name, config); - } - - private boolean isUrlAvailableInConfig(String contextId) { - FeignClientProperties.FeignClientConfiguration config = findConfigByKey(contextId); - return Objects.nonNull(config) && StringUtils.hasText(config.getUrl()); - } - - private FeignClientProperties.FeignClientConfiguration findConfigByKey(String configKey) { - FeignClientProperties properties = beanFactory != null ? beanFactory.getBean(FeignClientProperties.class) - : applicationContext.getBean(FeignClientProperties.class); - return properties.getConfig().get(configKey); - } - - @Override - public Class getObjectType() { - return type; - } - - @Override - public boolean isSingleton() { - return true; - } - - public Class getType() { - return type; - } - - public void setType(Class type) { - this.type = type; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getContextId() { - return contextId; - } - - public void setContextId(String contextId) { - this.contextId = contextId; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public boolean isDismiss404() { - return dismiss404; - } - - public void setDismiss404(boolean dismiss404) { - this.dismiss404 = dismiss404; - } - - public boolean isInheritParentContext() { - return inheritParentContext; - } - - public void setInheritParentContext(boolean inheritParentContext) { - this.inheritParentContext = inheritParentContext; - } - - public void addCustomizer(FeignBuilderCustomizer customizer) { - additionalCustomizers.add(customizer); - } - - public ApplicationContext getApplicationContext() { - return applicationContext; - } - - @Override - public void setApplicationContext(ApplicationContext context) throws BeansException { - applicationContext = context; - beanFactory = context; - } - - public Class getFallback() { - return fallback; - } - - public void setFallback(Class fallback) { - this.fallback = fallback; - } - - public Class getFallbackFactory() { - return fallbackFactory; - } - - public void setFallbackFactory(Class fallbackFactory) { - this.fallbackFactory = fallbackFactory; - } - - public void setRefreshableClient(boolean refreshableClient) { - this.refreshableClient = refreshableClient; - } - - public String[] getQualifiers() { - return qualifiers; - } - - public void setQualifiers(String[] qualifiers) { - this.qualifiers = qualifiers; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - FeignClientFactoryBean that = (FeignClientFactoryBean) o; - return Objects.equals(applicationContext, that.applicationContext) - && Objects.equals(beanFactory, that.beanFactory) && dismiss404 == that.dismiss404 - && inheritParentContext == that.inheritParentContext && Objects.equals(fallback, that.fallback) - && Objects.equals(fallbackFactory, that.fallbackFactory) && Objects.equals(name, that.name) - && Objects.equals(path, that.path) && Objects.equals(type, that.type) && Objects.equals(url, that.url) - && Objects.equals(connectTimeoutMillis, that.connectTimeoutMillis) - && Objects.equals(readTimeoutMillis, that.readTimeoutMillis) - && Objects.equals(followRedirects, that.followRedirects) - && Objects.equals(refreshableClient, that.refreshableClient); - } - - @Override - public int hashCode() { - return Objects.hash(applicationContext, beanFactory, dismiss404, inheritParentContext, fallback, - fallbackFactory, name, path, type, url, readTimeoutMillis, connectTimeoutMillis, followRedirects, - refreshableClient); - } - - @Override - public String toString() { - return new StringBuilder("FeignClientFactoryBean{").append("type=").append(type).append(", ").append("name='") - .append(name).append("', ").append("url='").append(url).append("', ").append("path='").append(path) - .append("', ").append("dismiss404=").append(dismiss404).append(", ").append("inheritParentContext=") - .append(inheritParentContext).append(", ").append("applicationContext=").append(applicationContext) - .append(", ").append("beanFactory=").append(beanFactory).append(", ").append("fallback=") - .append(fallback).append(", ").append("fallbackFactory=").append(fallbackFactory).append("}") - .append("connectTimeoutMillis=").append(connectTimeoutMillis).append("}").append("readTimeoutMillis=") - .append(readTimeoutMillis).append("}").append("followRedirects=").append(followRedirects) - .append("refreshableClient=").append(refreshableClient).append("}").toString(); - } - - @Override - public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - this.beanFactory = beanFactory; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientMicrometerEnabledCondition.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientMicrometerEnabledCondition.java deleted file mode 100644 index bef662ca2..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientMicrometerEnabledCondition.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2021-2022 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; - -import java.util.Map; - -import org.springframework.context.annotation.Condition; -import org.springframework.context.annotation.ConditionContext; -import org.springframework.core.type.AnnotatedTypeMetadata; - -/** - * @author Jonatan Ivanov - */ -class FeignClientMicrometerEnabledCondition implements Condition { - - @Override - public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { - FeignClientProperties feignClientProperties = context.getBeanFactory() - .getBeanProvider(FeignClientProperties.class).getIfAvailable(); - if (feignClientProperties != null) { - Map feignClientConfigMap = feignClientProperties - .getConfig(); - if (feignClientConfigMap != null) { - FeignClientProperties.FeignClientConfiguration feignClientConfig = feignClientConfigMap - .get(context.getEnvironment().getProperty("spring.cloud.openfeign.client.name")); - if (feignClientConfig != null) { - FeignClientProperties.MicrometerProperties micrometer = feignClientConfig.getMicrometer(); - if (micrometer != null && micrometer.getEnabled() != null) { - return micrometer.getEnabled(); - } - } - } - } - - return true; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientProperties.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientProperties.java deleted file mode 100644 index b826aa214..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientProperties.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import feign.Capability; -import feign.Contract; -import feign.ExceptionPropagationPolicy; -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.properties.ConfigurationProperties; - -/** - * @author Eko Kurniawan Khannedy - * @author Ilia Ilinykh - * @author Ram Anaswara - * @author Jonatan Ivanov - * @author Olga Maciaszek-Sharma - * @author Hyeonmin Park - * @author Jasbir Singh - * @author Dominique Villard - */ -@ConfigurationProperties("spring.cloud.openfeign.client") -public class FeignClientProperties { - - private boolean defaultToProperties = true; - - private String defaultConfig = "default"; - - private Map config = new HashMap<>(); - - /** - * Feign clients do not encode slash `/` characters by default. To change this - * behavior, set the `decodeSlash` to `false`. - */ - private boolean decodeSlash = true; - - public boolean isDefaultToProperties() { - return defaultToProperties; - } - - public void setDefaultToProperties(boolean defaultToProperties) { - this.defaultToProperties = defaultToProperties; - } - - public String getDefaultConfig() { - return defaultConfig; - } - - public void setDefaultConfig(String defaultConfig) { - this.defaultConfig = defaultConfig; - } - - public Map getConfig() { - return config; - } - - public void setConfig(Map config) { - this.config = config; - } - - public boolean isDecodeSlash() { - return decodeSlash; - } - - public void setDecodeSlash(boolean decodeSlash) { - this.decodeSlash = decodeSlash; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - FeignClientProperties that = (FeignClientProperties) o; - return defaultToProperties == that.defaultToProperties && Objects.equals(defaultConfig, that.defaultConfig) - && Objects.equals(config, that.config) && Objects.equals(decodeSlash, that.decodeSlash); - } - - @Override - public int hashCode() { - return Objects.hash(defaultToProperties, defaultConfig, config, decodeSlash); - } - - /** - * Feign client configuration. - */ - public static class FeignClientConfiguration { - - private Logger.Level loggerLevel; - - private Integer connectTimeout; - - private Integer readTimeout; - - private Class retryer; - - private Class errorDecoder; - - private List> requestInterceptors; - - private Class responseInterceptor; - - private Map> defaultRequestHeaders; - - private Map> defaultQueryParameters; - - private Boolean dismiss404; - - private Class decoder; - - private Class encoder; - - private Class contract; - - private ExceptionPropagationPolicy exceptionPropagationPolicy; - - private List> capabilities; - - private Class queryMapEncoder; - - private MicrometerProperties micrometer; - - private Boolean followRedirects; - - /** - * Allows setting Feign client host URL. This value will only be taken into - * account if the url is not set in the @FeignClient annotation. - */ - private String url; - - public Logger.Level getLoggerLevel() { - return loggerLevel; - } - - public void setLoggerLevel(Logger.Level loggerLevel) { - this.loggerLevel = loggerLevel; - } - - public Integer getConnectTimeout() { - return connectTimeout; - } - - public void setConnectTimeout(Integer connectTimeout) { - this.connectTimeout = connectTimeout; - } - - public Integer getReadTimeout() { - return readTimeout; - } - - public void setReadTimeout(Integer readTimeout) { - this.readTimeout = readTimeout; - } - - public Class getRetryer() { - return retryer; - } - - public void setRetryer(Class retryer) { - this.retryer = retryer; - } - - public Class getErrorDecoder() { - return errorDecoder; - } - - public void setErrorDecoder(Class errorDecoder) { - this.errorDecoder = errorDecoder; - } - - public List> getRequestInterceptors() { - return requestInterceptors; - } - - public void setRequestInterceptors(List> requestInterceptors) { - this.requestInterceptors = requestInterceptors; - } - - public Class getResponseInterceptor() { - return responseInterceptor; - } - - public void setResponseInterceptor(Class responseInterceptor) { - this.responseInterceptor = responseInterceptor; - } - - public Map> getDefaultRequestHeaders() { - return defaultRequestHeaders; - } - - public void setDefaultRequestHeaders(Map> defaultRequestHeaders) { - this.defaultRequestHeaders = defaultRequestHeaders; - } - - public Map> getDefaultQueryParameters() { - return defaultQueryParameters; - } - - public void setDefaultQueryParameters(Map> defaultQueryParameters) { - this.defaultQueryParameters = defaultQueryParameters; - } - - public Boolean getDismiss404() { - return dismiss404; - } - - public void setDismiss404(Boolean dismiss404) { - this.dismiss404 = dismiss404; - } - - public Class getDecoder() { - return decoder; - } - - public void setDecoder(Class decoder) { - this.decoder = decoder; - } - - public Class getEncoder() { - return encoder; - } - - public void setEncoder(Class encoder) { - this.encoder = encoder; - } - - public Class getContract() { - return contract; - } - - public void setContract(Class contract) { - this.contract = contract; - } - - public ExceptionPropagationPolicy getExceptionPropagationPolicy() { - return exceptionPropagationPolicy; - } - - public void setExceptionPropagationPolicy(ExceptionPropagationPolicy exceptionPropagationPolicy) { - this.exceptionPropagationPolicy = exceptionPropagationPolicy; - } - - public List> getCapabilities() { - return capabilities; - } - - public void setCapabilities(List> capabilities) { - this.capabilities = capabilities; - } - - public Class getQueryMapEncoder() { - return queryMapEncoder; - } - - public void setQueryMapEncoder(Class queryMapEncoder) { - this.queryMapEncoder = queryMapEncoder; - } - - public MicrometerProperties getMicrometer() { - return micrometer; - } - - public void setMicrometer(MicrometerProperties micrometer) { - this.micrometer = micrometer; - } - - public Boolean isFollowRedirects() { - return followRedirects; - } - - public void setFollowRedirects(Boolean followRedirects) { - this.followRedirects = followRedirects; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - FeignClientConfiguration that = (FeignClientConfiguration) o; - return loggerLevel == that.loggerLevel && Objects.equals(connectTimeout, that.connectTimeout) - && Objects.equals(readTimeout, that.readTimeout) && Objects.equals(retryer, that.retryer) - && Objects.equals(errorDecoder, that.errorDecoder) - && Objects.equals(requestInterceptors, that.requestInterceptors) - && Objects.equals(responseInterceptor, that.responseInterceptor) - && Objects.equals(dismiss404, that.dismiss404) && Objects.equals(encoder, that.encoder) - && Objects.equals(decoder, that.decoder) && Objects.equals(contract, that.contract) - && Objects.equals(exceptionPropagationPolicy, that.exceptionPropagationPolicy) - && Objects.equals(defaultRequestHeaders, that.defaultRequestHeaders) - && Objects.equals(defaultQueryParameters, that.defaultQueryParameters) - && Objects.equals(capabilities, that.capabilities) - && Objects.equals(queryMapEncoder, that.queryMapEncoder) - && Objects.equals(micrometer, that.micrometer) - && Objects.equals(followRedirects, that.followRedirects) && Objects.equals(url, that.url); - } - - @Override - public int hashCode() { - return Objects.hash(loggerLevel, connectTimeout, readTimeout, retryer, errorDecoder, requestInterceptors, - responseInterceptor, dismiss404, encoder, decoder, contract, exceptionPropagationPolicy, - defaultQueryParameters, defaultRequestHeaders, capabilities, queryMapEncoder, micrometer, - followRedirects, url); - } - - } - - /** - * Micrometer configuration for Feign Client. - */ - public static class MicrometerProperties { - - private Boolean enabled = true; - - public Boolean getEnabled() { - return enabled; - } - - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - MicrometerProperties that = (MicrometerProperties) o; - return Objects.equals(enabled, that.enabled); - } - - @Override - public int hashCode() { - return Objects.hash(enabled); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientSpecification.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientSpecification.java deleted file mode 100644 index 345ad8b01..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientSpecification.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.Arrays; -import java.util.Objects; - -import org.springframework.cloud.context.named.NamedContextFactory; - -/** - * @author Dave Syer - * @author Gregor Zurowski - * @author Olga Maciaszek-Sharma - */ -public class FeignClientSpecification implements NamedContextFactory.Specification { - - private String name; - - private String className; - - private Class[] configuration; - - public FeignClientSpecification() { - } - - public FeignClientSpecification(String name, String className, Class[] configuration) { - this.name = name; - this.className = className; - this.configuration = configuration; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getClassName() { - return className; - } - - public void setClassName(String className) { - this.className = className; - } - - public Class[] getConfiguration() { - return this.configuration; - } - - public void setConfiguration(Class[] configuration) { - this.configuration = configuration; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof FeignClientSpecification that)) { - return false; - } - return Objects.equals(name, that.name) && Objects.equals(className, that.className) - && Arrays.equals(configuration, that.configuration); - } - - @Override - public int hashCode() { - int result = Objects.hash(name, className); - result = 31 * result + Arrays.hashCode(configuration); - return result; - } - - @Override - public String toString() { - return "FeignClientSpecification{" + "name='" + name + "', " + "className='" + className + "', " - + "configuration=" + Arrays.toString(configuration) + "}"; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsConfiguration.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsConfiguration.java deleted file mode 100644 index 3372a0c55..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsConfiguration.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.ArrayList; -import java.util.List; - -import feign.Contract; -import feign.Feign; -import feign.Logger; -import feign.QueryMapEncoder; -import feign.Retryer; -import feign.codec.Decoder; -import feign.codec.Encoder; -import feign.form.MultipartFormContentProcessor; -import feign.form.spring.SpringFormEncoder; -import feign.micrometer.MicrometerCapability; -import feign.micrometer.MicrometerObservationCapability; -import feign.optionals.OptionalDecoder; -import io.micrometer.core.instrument.MeterRegistry; -import io.micrometer.observation.ObservationRegistry; - -import org.springframework.beans.factory.ObjectFactory; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.data.web.SpringDataWebProperties; -import org.springframework.boot.autoconfigure.http.HttpMessageConverters; -import org.springframework.cloud.client.circuitbreaker.CircuitBreaker; -import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; -import org.springframework.cloud.openfeign.clientconfig.FeignClientConfigurer; -import org.springframework.cloud.openfeign.support.AbstractFormWriter; -import org.springframework.cloud.openfeign.support.FeignEncoderProperties; -import org.springframework.cloud.openfeign.support.HttpMessageConverterCustomizer; -import org.springframework.cloud.openfeign.support.PageableSpringEncoder; -import org.springframework.cloud.openfeign.support.PageableSpringQueryMapEncoder; -import org.springframework.cloud.openfeign.support.ResponseEntityDecoder; -import org.springframework.cloud.openfeign.support.SpringDecoder; -import org.springframework.cloud.openfeign.support.SpringEncoder; -import org.springframework.cloud.openfeign.support.SpringMvcContract; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Scope; -import org.springframework.core.convert.ConversionService; -import org.springframework.format.support.DefaultFormattingConversionService; -import org.springframework.format.support.FormattingConversionService; - -import static feign.form.ContentType.MULTIPART; - -/** - * @author Dave Syer - * @author Venil Noronha - * @author Darren Foong - * @author Jonatan Ivanov - * @author Olga Maciaszek-Sharma - * @author Hyeonmin Park - * @author Yanming Zhou - */ -@Configuration(proxyBeanMethods = false) -public class FeignClientsConfiguration { - - @Autowired - private ObjectFactory messageConverters; - - @Autowired(required = false) - private List parameterProcessors = new ArrayList<>(); - - @Autowired(required = false) - private List feignFormatterRegistrars = new ArrayList<>(); - - @Autowired(required = false) - private Logger logger; - - @Autowired(required = false) - private SpringDataWebProperties springDataWebProperties; - - @Autowired(required = false) - private FeignClientProperties feignClientProperties; - - @Autowired(required = false) - private FeignEncoderProperties encoderProperties; - - @Bean - @ConditionalOnMissingBean - public Decoder feignDecoder(ObjectProvider customizers) { - return new OptionalDecoder(new ResponseEntityDecoder(new SpringDecoder(messageConverters, customizers))); - } - - @Bean - @ConditionalOnMissingBean - @ConditionalOnMissingClass("org.springframework.data.domain.Pageable") - public Encoder feignEncoder(ObjectProvider formWriterProvider, - ObjectProvider customizers) { - return springEncoder(formWriterProvider, encoderProperties, customizers); - } - - @Bean - @ConditionalOnClass(name = "org.springframework.data.domain.Pageable") - @ConditionalOnMissingBean - public Encoder feignEncoderPageable(ObjectProvider formWriterProvider, - ObjectProvider customizers) { - PageableSpringEncoder encoder = new PageableSpringEncoder( - springEncoder(formWriterProvider, encoderProperties, customizers)); - - if (springDataWebProperties != null) { - encoder.setPageParameter(springDataWebProperties.getPageable().getPageParameter()); - encoder.setSizeParameter(springDataWebProperties.getPageable().getSizeParameter()); - encoder.setSortParameter(springDataWebProperties.getSort().getSortParameter()); - } - return encoder; - } - - @Bean - @ConditionalOnClass(name = "org.springframework.data.domain.Pageable") - @ConditionalOnMissingBean - public QueryMapEncoder feignQueryMapEncoderPageable() { - PageableSpringQueryMapEncoder queryMapEncoder = new PageableSpringQueryMapEncoder(); - if (springDataWebProperties != null) { - queryMapEncoder.setPageParameter(springDataWebProperties.getPageable().getPageParameter()); - queryMapEncoder.setSizeParameter(springDataWebProperties.getPageable().getSizeParameter()); - queryMapEncoder.setSortParameter(springDataWebProperties.getSort().getSortParameter()); - } - return queryMapEncoder; - } - - @Bean - @ConditionalOnMissingBean - public Contract feignContract(ConversionService feignConversionService) { - boolean decodeSlash = feignClientProperties == null || feignClientProperties.isDecodeSlash(); - return new SpringMvcContract(parameterProcessors, feignConversionService, decodeSlash); - } - - @Bean - public FormattingConversionService feignConversionService() { - FormattingConversionService conversionService = new DefaultFormattingConversionService(); - for (FeignFormatterRegistrar feignFormatterRegistrar : feignFormatterRegistrars) { - feignFormatterRegistrar.registerFormatters(conversionService); - } - return conversionService; - } - - @Bean - @ConditionalOnMissingBean - public Retryer feignRetryer() { - return Retryer.NEVER_RETRY; - } - - @Bean - @ConditionalOnMissingBean(FeignLoggerFactory.class) - public FeignLoggerFactory feignLoggerFactory() { - return new DefaultFeignLoggerFactory(logger); - } - - @Bean - @ConditionalOnMissingBean(FeignClientConfigurer.class) - public FeignClientConfigurer feignClientConfigurer() { - return new FeignClientConfigurer() { - }; - } - - private Encoder springEncoder(ObjectProvider formWriterProvider, - FeignEncoderProperties encoderProperties, ObjectProvider customizers) { - AbstractFormWriter formWriter = formWriterProvider.getIfAvailable(); - - if (formWriter != null) { - return new SpringEncoder(new SpringPojoFormEncoder(formWriter), messageConverters, encoderProperties, - customizers); - } - else { - return new SpringEncoder(new SpringFormEncoder(), messageConverters, encoderProperties, customizers); - } - } - - private class SpringPojoFormEncoder extends SpringFormEncoder { - - SpringPojoFormEncoder(AbstractFormWriter formWriter) { - super(); - - MultipartFormContentProcessor processor = (MultipartFormContentProcessor) getContentProcessor(MULTIPART); - processor.addFirstWriter(formWriter); - } - - } - - @Configuration(proxyBeanMethods = false) - @Conditional(FeignCircuitBreakerDisabledConditions.class) - protected static class DefaultFeignBuilderConfiguration { - - @Bean - @Scope("prototype") - @ConditionalOnMissingBean - public Feign.Builder feignBuilder(Retryer retryer) { - return Feign.builder().retryer(retryer); - } - - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(CircuitBreaker.class) - @ConditionalOnProperty("spring.cloud.openfeign.circuitbreaker.enabled") - protected static class CircuitBreakerPresentFeignBuilderConfiguration { - - @Bean - @Scope("prototype") - @ConditionalOnMissingBean({ Feign.Builder.class, CircuitBreakerFactory.class }) - public Feign.Builder defaultFeignBuilder(Retryer retryer) { - return Feign.builder().retryer(retryer); - } - - @Bean - @Scope("prototype") - @ConditionalOnMissingBean - @ConditionalOnBean(CircuitBreakerFactory.class) - public Feign.Builder circuitBreakerFeignBuilder() { - return FeignCircuitBreaker.builder(); - } - - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnProperty(name = "spring.cloud.openfeign.micrometer.enabled", matchIfMissing = true) - @ConditionalOnClass({ MicrometerObservationCapability.class, MicrometerCapability.class, MeterRegistry.class }) - @Conditional(FeignClientMicrometerEnabledCondition.class) - protected static class MicrometerConfiguration { - - @Bean - @ConditionalOnMissingBean - @ConditionalOnBean(type = "io.micrometer.observation.ObservationRegistry") - public MicrometerObservationCapability micrometerObservationCapability(ObservationRegistry registry) { - return new MicrometerObservationCapability(registry); - } - - @Bean - @ConditionalOnBean(type = "io.micrometer.core.instrument.MeterRegistry") - @ConditionalOnMissingBean({ MicrometerCapability.class, MicrometerObservationCapability.class }) - public MicrometerCapability micrometerCapability(MeterRegistry registry) { - return new MicrometerCapability(registry); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java deleted file mode 100644 index cb7185dbe..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java +++ /dev/null @@ -1,502 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import feign.Request; - -import org.springframework.aop.scope.ScopedProxyUtils; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; -import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.BeanDefinitionHolder; -import org.springframework.beans.factory.config.BeanExpressionContext; -import org.springframework.beans.factory.config.BeanExpressionResolver; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.support.BeanDefinitionReaderUtils; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.context.EnvironmentAware; -import org.springframework.context.ResourceLoaderAware; -import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; -import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; -import org.springframework.core.annotation.AnnotationAttributes; -import org.springframework.core.env.Environment; -import org.springframework.core.io.ResourceLoader; -import org.springframework.core.type.AnnotationMetadata; -import org.springframework.core.type.filter.AnnotationTypeFilter; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; -import org.springframework.util.ObjectUtils; -import org.springframework.util.StringUtils; - -/** - * @author Spencer Gibb - * @author Jakub Narloch - * @author Venil Noronha - * @author Gang Li - * @author Michal Domagala - * @author Marcin Grzejszczak - * @author Olga Maciaszek-Sharma - * @author Jasbir Singh - */ -class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar, ResourceLoaderAware, EnvironmentAware { - - // patterned after Spring Integration IntegrationComponentScanRegistrar - // and RibbonClientsConfigurationRegistrar - - private ResourceLoader resourceLoader; - - private Environment environment; - - FeignClientsRegistrar() { - } - - static void validateFallback(final Class clazz) { - Assert.isTrue(!clazz.isInterface(), "Fallback class must implement the interface annotated by @FeignClient"); - } - - static void validateFallbackFactory(final Class clazz) { - Assert.isTrue(!clazz.isInterface(), "Fallback factory must produce instances " - + "of fallback classes that implement the interface annotated by @FeignClient"); - } - - static String getName(String name) { - if (!StringUtils.hasText(name)) { - return ""; - } - - String host = null; - try { - String url; - if (!name.startsWith("http://") && !name.startsWith("https://")) { - url = "http://" + name; - } - else { - url = name; - } - host = new URI(url).getHost(); - - } - catch (URISyntaxException ignored) { - } - Assert.state(host != null, "Service id not legal hostname (" + name + ")"); - return name; - } - - static String getUrl(String url) { - if (StringUtils.hasText(url) && !(url.startsWith("#{") && url.contains("}"))) { - if (!url.contains("://")) { - url = "http://" + url; - } - try { - new URL(url); - } - catch (MalformedURLException e) { - throw new IllegalArgumentException(url + " is malformed", e); - } - } - return url; - } - - static String getPath(String path) { - if (StringUtils.hasText(path)) { - path = path.trim(); - if (!path.startsWith("/")) { - path = "/" + path; - } - if (path.endsWith("/")) { - path = path.substring(0, path.length() - 1); - } - } - return path; - } - - @Override - public void setResourceLoader(ResourceLoader resourceLoader) { - this.resourceLoader = resourceLoader; - } - - @Override - public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { - registerDefaultConfiguration(metadata, registry); - registerFeignClients(metadata, registry); - } - - private void registerDefaultConfiguration(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { - Map defaultAttrs = metadata.getAnnotationAttributes(EnableFeignClients.class.getName(), true); - - if (defaultAttrs != null && defaultAttrs.containsKey("defaultConfiguration")) { - String name; - if (metadata.hasEnclosingClass()) { - name = "default." + metadata.getEnclosingClassName(); - } - else { - name = "default." + metadata.getClassName(); - } - registerClientConfiguration(registry, name, "default", defaultAttrs.get("defaultConfiguration")); - } - } - - public void registerFeignClients(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { - LinkedHashSet candidateComponents = new LinkedHashSet<>(); - Map attrs = metadata.getAnnotationAttributes(EnableFeignClients.class.getName()); - final Class[] clients = attrs == null ? null : (Class[]) attrs.get("clients"); - if (clients == null || clients.length == 0) { - ClassPathScanningCandidateComponentProvider scanner = getScanner(); - scanner.setResourceLoader(this.resourceLoader); - scanner.addIncludeFilter(new AnnotationTypeFilter(FeignClient.class)); - Set basePackages = getBasePackages(metadata); - for (String basePackage : basePackages) { - candidateComponents.addAll(scanner.findCandidateComponents(basePackage)); - } - } - else { - for (Class clazz : clients) { - candidateComponents.add(new AnnotatedGenericBeanDefinition(clazz)); - } - } - - for (BeanDefinition candidateComponent : candidateComponents) { - if (candidateComponent instanceof AnnotatedBeanDefinition beanDefinition) { - // verify annotated class is an interface - AnnotationMetadata annotationMetadata = beanDefinition.getMetadata(); - Assert.isTrue(annotationMetadata.isInterface(), "@FeignClient can only be specified on an interface"); - - Map attributes = annotationMetadata - .getAnnotationAttributes(FeignClient.class.getCanonicalName()); - - String name = getClientName(attributes); - String className = annotationMetadata.getClassName(); - registerClientConfiguration(registry, name, className, attributes.get("configuration")); - - registerFeignClient(registry, annotationMetadata, attributes); - } - } - } - - private void registerFeignClient(BeanDefinitionRegistry registry, AnnotationMetadata annotationMetadata, - Map attributes) { - String className = annotationMetadata.getClassName(); - if (String.valueOf(false).equals( - environment.getProperty("spring.cloud.openfeign.lazy-attributes-resolution", String.valueOf(false)))) { - eagerlyRegisterFeignClientBeanDefinition(className, attributes, registry); - } - else { - lazilyRegisterFeignClientBeanDefinition(className, attributes, registry); - } - } - - private void eagerlyRegisterFeignClientBeanDefinition(String className, Map attributes, - BeanDefinitionRegistry registry) { - validate(attributes); - BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(FeignClientFactoryBean.class); - definition.addPropertyValue("url", getUrl(null, attributes)); - definition.addPropertyValue("path", getPath(null, attributes)); - String name = getName(attributes); - definition.addPropertyValue("name", name); - String contextId = getContextId(null, attributes); - definition.addPropertyValue("contextId", contextId); - definition.addPropertyValue("type", className); - definition.addPropertyValue("dismiss404", Boolean.parseBoolean(String.valueOf(attributes.get("dismiss404")))); - Object fallback = attributes.get("fallback"); - if (fallback != null) { - definition.addPropertyValue("fallback", - (fallback instanceof Class ? fallback : ClassUtils.resolveClassName(fallback.toString(), null))); - } - Object fallbackFactory = attributes.get("fallbackFactory"); - if (fallbackFactory != null) { - definition.addPropertyValue("fallbackFactory", fallbackFactory instanceof Class ? fallbackFactory - : ClassUtils.resolveClassName(fallbackFactory.toString(), null)); - } - definition.addPropertyValue("fallbackFactory", attributes.get("fallbackFactory")); - definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE); - definition.addPropertyValue("refreshableClient", isClientRefreshEnabled()); - String[] qualifiers = getQualifiers(attributes); - if (ObjectUtils.isEmpty(qualifiers)) { - qualifiers = new String[] { contextId + "FeignClient" }; - } - // This is done so that there's a way to retrieve qualifiers while generating AOT - // code - definition.addPropertyValue("qualifiers", qualifiers); - AbstractBeanDefinition beanDefinition = definition.getBeanDefinition(); - // has a default, won't be null - boolean primary = (Boolean) attributes.get("primary"); - beanDefinition.setPrimary(primary); - BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, className, qualifiers); - BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry); - registerRefreshableBeanDefinition(registry, contextId, Request.Options.class, OptionsFactoryBean.class); - registerRefreshableBeanDefinition(registry, contextId, RefreshableUrl.class, RefreshableUrlFactoryBean.class); - } - - private void lazilyRegisterFeignClientBeanDefinition(String className, Map attributes, - BeanDefinitionRegistry registry) { - ConfigurableBeanFactory beanFactory = registry instanceof ConfigurableBeanFactory - ? (ConfigurableBeanFactory) registry : null; - Class clazz = ClassUtils.resolveClassName(className, null); - String contextId = getContextId(beanFactory, attributes); - String name = getName(attributes); - FeignClientFactoryBean factoryBean = new FeignClientFactoryBean(); - factoryBean.setBeanFactory(beanFactory); - factoryBean.setName(name); - factoryBean.setContextId(contextId); - factoryBean.setType(clazz); - factoryBean.setRefreshableClient(isClientRefreshEnabled()); - BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(clazz, () -> { - factoryBean.setUrl(getUrl(beanFactory, attributes)); - factoryBean.setPath(getPath(beanFactory, attributes)); - factoryBean.setDismiss404(Boolean.parseBoolean(String.valueOf(attributes.get("dismiss404")))); - Object fallback = attributes.get("fallback"); - if (fallback != null) { - factoryBean.setFallback(fallback instanceof Class ? (Class) fallback - : ClassUtils.resolveClassName(fallback.toString(), null)); - } - Object fallbackFactory = attributes.get("fallbackFactory"); - if (fallbackFactory != null) { - factoryBean.setFallbackFactory(fallbackFactory instanceof Class ? (Class) fallbackFactory - : ClassUtils.resolveClassName(fallbackFactory.toString(), null)); - } - return factoryBean.getObject(); - }); - definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE); - definition.setLazyInit(true); - validate(attributes); - - AbstractBeanDefinition beanDefinition = definition.getBeanDefinition(); - beanDefinition.setAttribute(FactoryBean.OBJECT_TYPE_ATTRIBUTE, className); - beanDefinition.setAttribute("feignClientsRegistrarFactoryBean", factoryBean); - - // has a default, won't be null - boolean primary = (Boolean) attributes.get("primary"); - - beanDefinition.setPrimary(primary); - - String[] qualifiers = getQualifiers(attributes); - if (ObjectUtils.isEmpty(qualifiers)) { - qualifiers = new String[] { contextId + "FeignClient" }; - } - - BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, className, qualifiers); - BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry); - - registerRefreshableBeanDefinition(registry, contextId, Request.Options.class, OptionsFactoryBean.class); - registerRefreshableBeanDefinition(registry, contextId, RefreshableUrl.class, RefreshableUrlFactoryBean.class); - } - - private void validate(Map attributes) { - AnnotationAttributes annotation = AnnotationAttributes.fromMap(attributes); - // This blows up if an aliased property is overspecified - // FIXME annotation.getAliasedString("name", FeignClient.class, null); - validateFallback(annotation.getClass("fallback")); - validateFallbackFactory(annotation.getClass("fallbackFactory")); - } - - /* for testing */ String getName(Map attributes) { - return getName(null, attributes); - } - - String getName(ConfigurableBeanFactory beanFactory, Map attributes) { - String name = (String) attributes.get("serviceId"); - if (!StringUtils.hasText(name)) { - name = (String) attributes.get("name"); - } - if (!StringUtils.hasText(name)) { - name = (String) attributes.get("value"); - } - name = resolve(beanFactory, name); - return getName(name); - } - - private String getContextId(ConfigurableBeanFactory beanFactory, Map attributes) { - String contextId = (String) attributes.get("contextId"); - if (!StringUtils.hasText(contextId)) { - return getName(attributes); - } - - contextId = resolve(beanFactory, contextId); - return getName(contextId); - } - - private String resolve(ConfigurableBeanFactory beanFactory, String value) { - if (StringUtils.hasText(value)) { - if (beanFactory == null) { - return this.environment.resolvePlaceholders(value); - } - BeanExpressionResolver resolver = beanFactory.getBeanExpressionResolver(); - String resolved = beanFactory.resolveEmbeddedValue(value); - if (resolver == null) { - return resolved; - } - Object evaluateValue = resolver.evaluate(resolved, new BeanExpressionContext(beanFactory, null)); - if (evaluateValue != null) { - return String.valueOf(evaluateValue); - } - return null; - } - return value; - } - - private String getUrl(ConfigurableBeanFactory beanFactory, Map attributes) { - String url = resolve(beanFactory, (String) attributes.get("url")); - return getUrl(url); - } - - private String getPath(ConfigurableBeanFactory beanFactory, Map attributes) { - String path = resolve(beanFactory, (String) attributes.get("path")); - return getPath(path); - } - - protected ClassPathScanningCandidateComponentProvider getScanner() { - return new ClassPathScanningCandidateComponentProvider(false, this.environment) { - @Override - protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) { - boolean isCandidate = false; - if (beanDefinition.getMetadata().isIndependent()) { - if (!beanDefinition.getMetadata().isAnnotation()) { - isCandidate = true; - } - } - return isCandidate; - } - }; - } - - protected Set getBasePackages(AnnotationMetadata importingClassMetadata) { - Map attributes = importingClassMetadata - .getAnnotationAttributes(EnableFeignClients.class.getCanonicalName()); - - Set basePackages = new HashSet<>(); - for (String pkg : (String[]) attributes.get("value")) { - if (StringUtils.hasText(pkg)) { - basePackages.add(pkg); - } - } - for (String pkg : (String[]) attributes.get("basePackages")) { - if (StringUtils.hasText(pkg)) { - basePackages.add(pkg); - } - } - for (Class clazz : (Class[]) attributes.get("basePackageClasses")) { - basePackages.add(ClassUtils.getPackageName(clazz)); - } - - if (basePackages.isEmpty()) { - basePackages.add(ClassUtils.getPackageName(importingClassMetadata.getClassName())); - } - return basePackages; - } - - private String getQualifier(Map client) { - if (client == null) { - return null; - } - String qualifier = (String) client.get("qualifier"); - if (StringUtils.hasText(qualifier)) { - return qualifier; - } - return null; - } - - private String[] getQualifiers(Map client) { - if (client == null) { - return null; - } - List qualifierList = new ArrayList<>(Arrays.asList((String[]) client.get("qualifiers"))); - qualifierList.removeIf(qualifier -> !StringUtils.hasText(qualifier)); - if (qualifierList.isEmpty() && getQualifier(client) != null) { - qualifierList = Collections.singletonList(getQualifier(client)); - } - return !qualifierList.isEmpty() ? qualifierList.toArray(new String[0]) : null; - } - - private String getClientName(Map client) { - if (client == null) { - return null; - } - String value = (String) client.get("contextId"); - if (!StringUtils.hasText(value)) { - value = (String) client.get("value"); - } - if (!StringUtils.hasText(value)) { - value = (String) client.get("name"); - } - if (!StringUtils.hasText(value)) { - value = (String) client.get("serviceId"); - } - if (StringUtils.hasText(value)) { - return value; - } - - throw new IllegalStateException( - "Either 'name' or 'value' must be provided in @" + FeignClient.class.getSimpleName()); - } - - private void registerClientConfiguration(BeanDefinitionRegistry registry, Object name, Object className, - Object configuration) { - BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(FeignClientSpecification.class); - builder.addConstructorArgValue(name); - builder.addConstructorArgValue(className); - builder.addConstructorArgValue(configuration); - registry.registerBeanDefinition(name + "." + FeignClientSpecification.class.getSimpleName(), - builder.getBeanDefinition()); - } - - @Override - public void setEnvironment(Environment environment) { - this.environment = environment; - } - - /** - * This method registers beans definition with refreshScope. - * @param registry spring bean definition registry - * @param contextId name of feign client - * @param beanType type of bean - * @param factoryBeanType points to a relevant bean factory - */ - private void registerRefreshableBeanDefinition(BeanDefinitionRegistry registry, String contextId, Class beanType, - Class factoryBeanType) { - if (isClientRefreshEnabled()) { - String beanName = beanType.getCanonicalName() + "-" + contextId; - BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(factoryBeanType); - definitionBuilder.setScope("refresh"); - definitionBuilder.addPropertyValue("contextId", contextId); - BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(definitionBuilder.getBeanDefinition(), - beanName); - definitionHolder = ScopedProxyUtils.createScopedProxy(definitionHolder, registry, true); - BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder, registry); - } - } - - private boolean isClientRefreshEnabled() { - return environment.getProperty("spring.cloud.openfeign.client.refresh-enabled", Boolean.class, false); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignErrorDecoderFactory.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignErrorDecoderFactory.java deleted file mode 100644 index 1115e3fca..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignErrorDecoderFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2020-2022 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; - -import feign.codec.ErrorDecoder; - -/** - * Allows an application to use a custom Feign {@link feign.codec.ErrorDecoder}. - * - * @author Michael Cramer - */ -public interface FeignErrorDecoderFactory { - - /** - * Factory method to provide a {@link feign.codec.ErrorDecoder} for a given - * {@link Class}. - * @param type the {@link Class} for which a {@link feign.codec.ErrorDecoder} instance - * is to be created - * @return a {@link feign.codec.ErrorDecoder} instance - */ - ErrorDecoder create(Class type); - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignFormatterRegistrar.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignFormatterRegistrar.java deleted file mode 100644 index c01ce7f80..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignFormatterRegistrar.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import org.springframework.format.FormatterRegistrar; -import org.springframework.format.support.FormattingConversionService; - -/** - * Allows an application to customize the Feign {@link FormattingConversionService}. - * - * @author Matt Benson - */ -public interface FeignFormatterRegistrar extends FormatterRegistrar { - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignLoggerFactory.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignLoggerFactory.java deleted file mode 100644 index e09c9d905..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignLoggerFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2016-2022 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; - -import feign.Logger; - -/** - * Allows an application to use a custom Feign {@link Logger}. - * - * @author Venil Noronha - */ -public interface FeignLoggerFactory { - - /** - * Factory method to provide a {@link Logger} for a given {@link Class}. - * @param type the {@link Class} for which a {@link Logger} instance is to be created - * @return a {@link Logger} instance - */ - Logger create(Class type); - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/OptionsFactoryBean.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/OptionsFactoryBean.java deleted file mode 100644 index 18192bbb5..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/OptionsFactoryBean.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.Objects; -import java.util.concurrent.TimeUnit; - -import feign.Request; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; - -/** - * This factory bean is meant to create {@link Request.Options} instance as per the - * applicable configurations. - * - * @author Jasbir Singh - */ -public class OptionsFactoryBean implements FactoryBean, ApplicationContextAware { - - private ApplicationContext applicationContext; - - private String contextId; - - private Request.Options options; - - @Override - public Class getObjectType() { - return Request.Options.class; - } - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; - } - - @Override - public Request.Options getObject() { - if (options != null) { - return options; - } - - options = new Request.Options(); - FeignClientProperties properties = applicationContext.getBean(FeignClientProperties.class); - options = createOptionsWithApplicableValues(properties.getConfig().get(properties.getDefaultConfig()), options); - options = createOptionsWithApplicableValues(properties.getConfig().get(contextId), options); - return options; - } - - public void setContextId(String contextId) { - this.contextId = contextId; - } - - private Request.Options createOptionsWithApplicableValues( - FeignClientProperties.FeignClientConfiguration clientConfiguration, Request.Options options) { - if (Objects.isNull(clientConfiguration)) { - return options; - } - - int connectTimeoutMillis = Objects.nonNull(clientConfiguration.getConnectTimeout()) - ? clientConfiguration.getConnectTimeout() : options.connectTimeoutMillis(); - int readTimeoutMillis = Objects.nonNull(clientConfiguration.getReadTimeout()) - ? clientConfiguration.getReadTimeout() : options.readTimeoutMillis(); - boolean followRedirects = Objects.nonNull(clientConfiguration.isFollowRedirects()) - ? clientConfiguration.isFollowRedirects() : options.isFollowRedirects(); - return new Request.Options(connectTimeoutMillis, TimeUnit.MILLISECONDS, readTimeoutMillis, - TimeUnit.MILLISECONDS, followRedirects); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/PropertyBasedTarget.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/PropertyBasedTarget.java deleted file mode 100644 index dd7b35ce2..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/PropertyBasedTarget.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013-2023 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; - -import feign.Target; - -/** - * A {@link HardCodedTarget} implementation that resolves url from properties when the - * initial call is made. Using it allows specifying the url at runtime in an AOT-packaged - * application or a native image by setting the value of the - * `spring.cloud.openfeign.client.config.[clientId].url`. - * - * @author Olga Maciaszek-Sharma - * @see FeignClientProperties.FeignClientConfiguration#getUrl() - */ -public class PropertyBasedTarget extends Target.HardCodedTarget { - - private String url; - - private final FeignClientProperties.FeignClientConfiguration config; - - public PropertyBasedTarget(Class type, String name, FeignClientProperties.FeignClientConfiguration config) { - super(type, name, config.getUrl()); - this.config = config; - } - - @Override - public String url() { - if (url == null) { - url = config.getUrl(); - } - return url; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/RefreshableHardCodedTarget.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/RefreshableHardCodedTarget.java deleted file mode 100644 index cd155b1f3..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/RefreshableHardCodedTarget.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import feign.Target; - -/** - * This target provides url wrapped under {@link Target}. - * - * @author Jasbir Singh - * @since 4.0.0 - */ -public class RefreshableHardCodedTarget extends Target.HardCodedTarget { - - private final RefreshableUrl refreshableUrl; - - @SuppressWarnings("unchecked") - public RefreshableHardCodedTarget(Class type, String name, RefreshableUrl refreshableUrl) { - super(type, name, refreshableUrl.getUrl()); - this.refreshableUrl = refreshableUrl; - } - - @Override - public String url() { - return refreshableUrl.getUrl(); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/RefreshableUrl.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/RefreshableUrl.java deleted file mode 100644 index 85878ae1c..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/RefreshableUrl.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2013-2022 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; - -/** - * This class wraps url inside an object so that relevant proxy instance can be created - * using {@link RefreshableUrlFactoryBean}. - * - * @author Jasbir Singh - * @since 4.0.0 - */ -public class RefreshableUrl { - - private final String url; - - public RefreshableUrl(String url) { - this.url = url; - } - - public String getUrl() { - return url; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/RefreshableUrlFactoryBean.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/RefreshableUrlFactoryBean.java deleted file mode 100644 index 996caf612..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/RefreshableUrlFactoryBean.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.Objects; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.util.StringUtils; - -/** - * This factory bean creates {@link RefreshableUrl} instance as per the applicable - * configurations. - * - * @author Jasbir Singh - * @since 4.0.0 - */ -public class RefreshableUrlFactoryBean implements FactoryBean, ApplicationContextAware { - - private ApplicationContext applicationContext; - - private String contextId; - - private RefreshableUrl refreshableUrl; - - @Override - public Class getObjectType() { - return RefreshableUrl.class; - } - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; - } - - @Override - public RefreshableUrl getObject() { - if (refreshableUrl != null) { - return refreshableUrl; - } - - FeignClientProperties properties = applicationContext.getBean(FeignClientProperties.class); - if (Objects.isNull(properties.getConfig())) { - return new RefreshableUrl(null); - } - FeignClientProperties.FeignClientConfiguration configuration = properties.getConfig().get(contextId); - if (Objects.isNull(configuration) || !StringUtils.hasText(configuration.getUrl())) { - return new RefreshableUrl(null); - } - - refreshableUrl = new RefreshableUrl(FeignClientsRegistrar.getUrl(configuration.getUrl())); - return refreshableUrl; - } - - public void setContextId(String contextId) { - this.contextId = contextId; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/SpringQueryMap.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/SpringQueryMap.java deleted file mode 100644 index 918f0438a..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/SpringQueryMap.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Spring MVC equivalent of OpenFeign's {@link feign.QueryMap} parameter annotation. - * - * @author Aram Peres - * @see feign.QueryMap - * @see org.springframework.cloud.openfeign.annotation.QueryMapParameterProcessor - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.PARAMETER }) -public @interface SpringQueryMap { - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/Targeter.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/Targeter.java deleted file mode 100644 index 40c1e4c1f..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/Targeter.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import feign.Feign; -import feign.Target; - -/** - * @author Spencer Gibb - */ -public interface Targeter { - - T target(FeignClientFactoryBean factory, Feign.Builder feign, FeignClientFactory context, - Target.HardCodedTarget target); - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/CookieValueParameterProcessor.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/CookieValueParameterProcessor.java deleted file mode 100644 index 31eceab7b..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/CookieValueParameterProcessor.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2013-2022 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.annotation; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Collections; - -import feign.MethodMetadata; - -import org.springframework.cloud.openfeign.AnnotatedParameterProcessor; -import org.springframework.http.HttpHeaders; -import org.springframework.web.bind.annotation.CookieValue; - -import static feign.Util.checkState; -import static feign.Util.emptyToNull; - -/** - * {@link CookieValue} annotation processor. - * - * @author Gong Yi - * @author Olga Maciaszek-Sharma - * - */ -public class CookieValueParameterProcessor implements AnnotatedParameterProcessor { - - private static final Class ANNOTATION = CookieValue.class; - - @Override - public Class getAnnotationType() { - return ANNOTATION; - } - - @Override - public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) { - int parameterIndex = context.getParameterIndex(); - MethodMetadata data = context.getMethodMetadata(); - CookieValue cookie = ANNOTATION.cast(annotation); - String name = cookie.value().trim(); - checkState(emptyToNull(name) != null, "Cookie.name() was empty on parameter %s", parameterIndex); - context.setParameterName(name); - String cookieExpression = data.template().headers() - .getOrDefault(HttpHeaders.COOKIE, Collections.singletonList("")).stream().findFirst().orElse(""); - if (cookieExpression.length() == 0) { - cookieExpression = String.format("%s={%s}", name, name); - } - else { - cookieExpression += String.format("; %s={%s}", name, name); - } - data.template().removeHeader(HttpHeaders.COOKIE); - data.template().header(HttpHeaders.COOKIE, cookieExpression); - return true; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/MatrixVariableParameterProcessor.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/MatrixVariableParameterProcessor.java deleted file mode 100644 index 644faba52..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/MatrixVariableParameterProcessor.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2013-2022 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.annotation; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Map; -import java.util.stream.Collectors; - -import feign.MethodMetadata; - -import org.springframework.cloud.openfeign.AnnotatedParameterProcessor; -import org.springframework.web.bind.annotation.MatrixVariable; - -import static feign.Util.checkState; -import static feign.Util.emptyToNull; - -/** - * {@link MatrixVariable} annotation processor. - * - * Can expand maps or single objects. Values are assigned from the objects - * {@code toString()} method. - * - * @author Matt King - * @see AnnotatedParameterProcessor - */ -public class MatrixVariableParameterProcessor implements AnnotatedParameterProcessor { - - private static final Class ANNOTATION = MatrixVariable.class; - - @Override - public Class getAnnotationType() { - return ANNOTATION; - } - - @Override - public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) { - int parameterIndex = context.getParameterIndex(); - Class parameterType = method.getParameterTypes()[parameterIndex]; - MethodMetadata data = context.getMethodMetadata(); - String name = ANNOTATION.cast(annotation).value(); - - checkState(emptyToNull(name) != null, "MatrixVariable annotation was empty on param %s.", - context.getParameterIndex()); - - context.setParameterName(name); - - if (Map.class.isAssignableFrom(parameterType)) { - data.indexToExpander().put(parameterIndex, this::expandMap); - } - else { - data.indexToExpander().put(parameterIndex, object -> ";" + name + "=" + object.toString()); - } - - return true; - } - - @SuppressWarnings("unchecked") - private String expandMap(Object object) { - Map paramMap = (Map) object; - - return paramMap.keySet().stream().filter(key -> paramMap.get(key) != null) - .map(key -> ";" + key + "=" + paramMap.get(key).toString()).collect(Collectors.joining()); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/PathVariableParameterProcessor.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/PathVariableParameterProcessor.java deleted file mode 100644 index a2dc86d92..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/PathVariableParameterProcessor.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2013-2022 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.annotation; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.Map; - -import feign.MethodMetadata; - -import org.springframework.cloud.openfeign.AnnotatedParameterProcessor; -import org.springframework.web.bind.annotation.PathVariable; - -import static feign.Util.checkState; -import static feign.Util.emptyToNull; - -/** - * {@link PathVariable} parameter processor. - * - * @author Jakub Narloch - * @author Abhijit Sarkar - * @author Yanming Zhou - * @see AnnotatedParameterProcessor - */ -public class PathVariableParameterProcessor implements AnnotatedParameterProcessor { - - private static final Class ANNOTATION = PathVariable.class; - - @Override - public Class getAnnotationType() { - return ANNOTATION; - } - - @Override - public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) { - String name = ANNOTATION.cast(annotation).value(); - checkState(emptyToNull(name) != null, "PathVariable annotation was empty on param %s.", - context.getParameterIndex()); - context.setParameterName(name); - - MethodMetadata data = context.getMethodMetadata(); - String varName = '{' + name + '}'; - String varNameRegex = ".*\\{" + name + "(:[^}]+)?\\}.*"; - if (!data.template().url().matches(varNameRegex) && !containsMapValues(data.template().queries(), varName) - && !containsMapValues(data.template().headers(), varName)) { - data.formParams().add(name); - } - return true; - } - - private boolean containsMapValues(Map> map, V search) { - Collection> values = map.values(); - if (values == null) { - return false; - } - for (Collection entry : values) { - if (entry.contains(search)) { - return true; - } - } - return false; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/QueryMapParameterProcessor.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/QueryMapParameterProcessor.java deleted file mode 100644 index eb7b747f1..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/QueryMapParameterProcessor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2013-2022 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.annotation; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import feign.MethodMetadata; - -import org.springframework.cloud.openfeign.AnnotatedParameterProcessor; -import org.springframework.cloud.openfeign.SpringQueryMap; - -/** - * {@link SpringQueryMap} parameter processor. - * - * @author Aram Peres - * @author Olga Maciaszek-Sharma - * @see AnnotatedParameterProcessor - */ -public class QueryMapParameterProcessor implements AnnotatedParameterProcessor { - - private static final Class ANNOTATION = SpringQueryMap.class; - - @Override - public Class getAnnotationType() { - return ANNOTATION; - } - - @Override - public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) { - int paramIndex = context.getParameterIndex(); - MethodMetadata metadata = context.getMethodMetadata(); - if (metadata.queryMapIndex() == null) { - metadata.queryMapIndex(paramIndex); - } - return true; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/RequestHeaderParameterProcessor.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/RequestHeaderParameterProcessor.java deleted file mode 100644 index 669371365..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/RequestHeaderParameterProcessor.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2013-2022 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.annotation; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.Map; - -import feign.MethodMetadata; - -import org.springframework.cloud.openfeign.AnnotatedParameterProcessor; -import org.springframework.web.bind.annotation.RequestHeader; - -import static feign.Util.checkState; -import static feign.Util.emptyToNull; - -/** - * {@link RequestHeader} parameter processor. - * - * @author Jakub Narloch - * @author Abhijit Sarkar - * @see AnnotatedParameterProcessor - */ -public class RequestHeaderParameterProcessor implements AnnotatedParameterProcessor { - - private static final Class ANNOTATION = RequestHeader.class; - - @Override - public Class getAnnotationType() { - return ANNOTATION; - } - - @Override - public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) { - int parameterIndex = context.getParameterIndex(); - Class parameterType = method.getParameterTypes()[parameterIndex]; - MethodMetadata data = context.getMethodMetadata(); - - if (Map.class.isAssignableFrom(parameterType)) { - checkState(data.headerMapIndex() == null, "Header map can only be present once."); - data.headerMapIndex(parameterIndex); - - return true; - } - - String name = ANNOTATION.cast(annotation).value(); - checkState(emptyToNull(name) != null, "RequestHeader.value() was empty on parameter %s", parameterIndex); - context.setParameterName(name); - - Collection header = context.setTemplateParameter(name, data.template().headers().get(name)); - data.template().header(name, header); - return true; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/RequestParamParameterProcessor.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/RequestParamParameterProcessor.java deleted file mode 100644 index c73e90894..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/RequestParamParameterProcessor.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2013-2022 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.annotation; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.Map; - -import feign.MethodMetadata; - -import org.springframework.cloud.openfeign.AnnotatedParameterProcessor; -import org.springframework.web.bind.annotation.RequestParam; - -import static feign.Util.checkState; -import static feign.Util.emptyToNull; - -/** - * {@link RequestParam} parameter processor. - * - * @author Jakub Narloch - * @author Abhijit Sarkar - * @see AnnotatedParameterProcessor - */ -public class RequestParamParameterProcessor implements AnnotatedParameterProcessor { - - private static final Class ANNOTATION = RequestParam.class; - - @Override - public Class getAnnotationType() { - return ANNOTATION; - } - - @Override - public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) { - int parameterIndex = context.getParameterIndex(); - Class parameterType = method.getParameterTypes()[parameterIndex]; - MethodMetadata data = context.getMethodMetadata(); - - if (Map.class.isAssignableFrom(parameterType)) { - checkState(data.queryMapIndex() == null, "Query map can only be present once."); - data.queryMapIndex(parameterIndex); - - return true; - } - - RequestParam requestParam = ANNOTATION.cast(annotation); - String name = requestParam.value(); - checkState(emptyToNull(name) != null, "RequestParam.value() was empty on parameter %s", parameterIndex); - context.setParameterName(name); - - Collection query = context.setTemplateParameter(name, data.template().queries().get(name)); - data.template().query(name, query); - return true; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/RequestPartParameterProcessor.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/RequestPartParameterProcessor.java deleted file mode 100644 index bb7ffdc02..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/annotation/RequestPartParameterProcessor.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2013-2022 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.annotation; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Collection; - -import feign.MethodMetadata; - -import org.springframework.cloud.openfeign.AnnotatedParameterProcessor; -import org.springframework.web.bind.annotation.RequestPart; - -import static feign.Util.checkState; -import static feign.Util.emptyToNull; - -/** - * {@link RequestPart} parameter processor. - * - * @author Aaron Whiteside - * @see AnnotatedParameterProcessor - */ -public class RequestPartParameterProcessor implements AnnotatedParameterProcessor { - - private static final Class ANNOTATION = RequestPart.class; - - @Override - public Class getAnnotationType() { - return ANNOTATION; - } - - @Override - public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) { - int parameterIndex = context.getParameterIndex(); - MethodMetadata data = context.getMethodMetadata(); - - String name = ANNOTATION.cast(annotation).value(); - checkState(emptyToNull(name) != null, "RequestPart.value() was empty on parameter %s", parameterIndex); - context.setParameterName(name); - - data.formParams().add(name); - Collection names = context.setTemplateParameter(name, data.indexToName().get(parameterIndex)); - data.indexToName().put(parameterIndex, names); - return true; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/aot/FeignChildContextInitializer.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/aot/FeignChildContextInitializer.java deleted file mode 100644 index 1d3059a08..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/aot/FeignChildContextInitializer.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2022-2022 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.aot; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import javax.lang.model.element.Modifier; - -import org.springframework.aot.generate.GeneratedMethod; -import org.springframework.aot.generate.GenerationContext; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.aot.BeanRegistrationAotContribution; -import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor; -import org.springframework.beans.factory.aot.BeanRegistrationCode; -import org.springframework.beans.factory.support.RegisteredBean; -import org.springframework.cloud.openfeign.FeignClientFactory; -import org.springframework.cloud.openfeign.FeignClientSpecification; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.aot.ApplicationContextAotGenerator; -import org.springframework.context.support.GenericApplicationContext; -import org.springframework.javapoet.ClassName; -import org.springframework.util.Assert; - -/** - * A {@link BeanRegistrationAotProcessor} that creates an - * {@link BeanRegistrationAotContribution} for Feign child contexts. - * - * @author Olga Maciaszek-Sharma - * @since 4.0.0 - */ -public class FeignChildContextInitializer implements BeanRegistrationAotProcessor { - - private final ApplicationContext applicationContext; - - private final FeignClientFactory feignClientFactory; - - public FeignChildContextInitializer(ApplicationContext applicationContext, FeignClientFactory feignClientFactory) { - this.applicationContext = applicationContext; - this.feignClientFactory = feignClientFactory; - } - - @Override - public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) { - Assert.isInstanceOf(ConfigurableApplicationContext.class, applicationContext); - ConfigurableApplicationContext context = ((ConfigurableApplicationContext) applicationContext); - BeanFactory applicationBeanFactory = context.getBeanFactory(); - if (!((registeredBean.getBeanClass().equals(FeignClientFactory.class)) - && registeredBean.getBeanFactory().equals(applicationBeanFactory))) { - return null; - } - Set contextIds = new HashSet<>(getContextIdsFromConfig()); - Map childContextAotContributions = contextIds.stream() - .map(contextId -> Map.entry(contextId, buildChildContext(contextId))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - return new AotContribution(childContextAotContributions); - } - - private GenericApplicationContext buildChildContext(String contextId) { - GenericApplicationContext childContext = feignClientFactory.buildContext(contextId); - feignClientFactory.registerBeans(contextId, childContext); - return childContext; - } - - private Collection getContextIdsFromConfig() { - Map configurations = feignClientFactory.getConfigurations(); - return configurations.keySet().stream().filter(key -> !key.startsWith("default.")).collect(Collectors.toSet()); - } - - private static class AotContribution implements BeanRegistrationAotContribution { - - private final Map childContexts; - - AotContribution(Map childContexts) { - this.childContexts = childContexts.entrySet().stream().filter(entry -> entry.getValue() != null) - .map(entry -> Map.entry(entry.getKey(), entry.getValue())) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - } - - @Override - public void applyTo(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode) { - Map generatedInitializerClassNames = childContexts.entrySet().stream().map(entry -> { - String name = entry.getValue().getDisplayName(); - name = name.replaceAll("[-]", "_"); - GenerationContext childGenerationContext = generationContext.withName(name); - ClassName initializerClassName = new ApplicationContextAotGenerator() - .processAheadOfTime(entry.getValue(), childGenerationContext); - return Map.entry(entry.getKey(), initializerClassName); - }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - GeneratedMethod postProcessorMethod = beanRegistrationCode.getMethods() - .add("addFeignChildContextInitializer", method -> { - method.addJavadoc("Use AOT child context management initialization") - .addModifiers(Modifier.PRIVATE, Modifier.STATIC) - .addParameter(RegisteredBean.class, "registeredBean") - .addParameter(FeignClientFactory.class, "instance").returns(FeignClientFactory.class) - .addStatement("$T initializers = new $T<>()", Map.class, HashMap.class); - generatedInitializerClassNames.keySet() - .forEach(contextId -> method.addStatement("initializers.put($S, new $L())", contextId, - generatedInitializerClassNames.get(contextId))); - method.addStatement("return instance.withApplicationContextInitializers(initializers)"); - }); - beanRegistrationCode.addInstancePostProcessor(postProcessorMethod.toMethodReference()); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/aot/FeignClientBeanFactoryInitializationAotProcessor.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/aot/FeignClientBeanFactoryInitializationAotProcessor.java deleted file mode 100644 index ca8027415..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/aot/FeignClientBeanFactoryInitializationAotProcessor.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright 2022-2023 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.aot; - -import java.lang.reflect.Method; -import java.lang.reflect.Parameter; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - -import javax.lang.model.element.Modifier; - -import org.springframework.aot.generate.GenerationContext; -import org.springframework.aot.generate.MethodReference; -import org.springframework.aot.hint.BindingReflectionHintsRegistrar; -import org.springframework.aot.hint.ReflectionHints; -import org.springframework.aot.hint.RuntimeHints; -import org.springframework.beans.MutablePropertyValues; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution; -import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor; -import org.springframework.beans.factory.aot.BeanFactoryInitializationCode; -import org.springframework.beans.factory.aot.BeanRegistrationExcludeFilter; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.BeanDefinitionHolder; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.support.BeanDefinitionReaderUtils; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.factory.support.GenericBeanDefinition; -import org.springframework.beans.factory.support.RegisteredBean; -import org.springframework.cloud.openfeign.FeignClientFactory; -import org.springframework.cloud.openfeign.FeignClientFactoryBean; -import org.springframework.cloud.openfeign.FeignClientSpecification; -import org.springframework.context.support.GenericApplicationContext; -import org.springframework.core.MethodParameter; -import org.springframework.javapoet.MethodSpec; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; - -/** - * A {@link BeanFactoryInitializationAotProcessor} that creates an - * {@link BeanFactoryInitializationAotContribution} that registers bean definitions and - * proxy and reflection hints for Feign client beans. - * - * @author Olga Maciaszek-Sharma - * @since 4.0.0 - */ -public class FeignClientBeanFactoryInitializationAotProcessor - implements BeanRegistrationExcludeFilter, BeanFactoryInitializationAotProcessor { - - private final GenericApplicationContext context; - - private final Map feignClientBeanDefinitions; - - private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar(); - - public FeignClientBeanFactoryInitializationAotProcessor(GenericApplicationContext context, - FeignClientFactory feignClientFactory) { - this.context = context; - this.feignClientBeanDefinitions = getFeignClientBeanDefinitions(feignClientFactory); - } - - @Override - public boolean isExcludedFromAotProcessing(RegisteredBean registeredBean) { - return registeredBean.getBeanClass().equals(FeignClientFactoryBean.class) - || feignClientBeanDefinitions.containsKey(registeredBean.getBeanClass().getName()); - } - - private Map getFeignClientBeanDefinitions(FeignClientFactory feignClientFactory) { - Map configurations = feignClientFactory.getConfigurations(); - return configurations.values().stream().map(FeignClientSpecification::getClassName).filter(Objects::nonNull) - .filter(className -> !className.equals("default")) - .map(className -> Map.entry(className, context.getBeanDefinition(className))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - } - - @SuppressWarnings("NullableProblems") - @Override - public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) { - BeanFactory applicationBeanFactory = context.getBeanFactory(); - if (feignClientBeanDefinitions.isEmpty() || !beanFactory.equals(applicationBeanFactory)) { - return null; - } - return new AotContribution(feignClientBeanDefinitions); - } - - private void registerMethodHints(ReflectionHints hints, Class clazz) { - for (Method method : clazz.getDeclaredMethods()) { - registerMethodHints(hints, method); - } - } - - private void registerMethodHints(ReflectionHints hints, Method method) { - for (Parameter parameter : method.getParameters()) { - bindingRegistrar.registerReflectionHints(hints, - MethodParameter.forParameter(parameter).getGenericParameterType()); - } - MethodParameter returnTypeParameter = MethodParameter.forExecutable(method, -1); - if (!void.class.equals(returnTypeParameter.getParameterType())) { - bindingRegistrar.registerReflectionHints(hints, returnTypeParameter.getGenericParameterType()); - } - - } - - // Visible for tests - final class AotContribution implements BeanFactoryInitializationAotContribution { - - private final Map feignClientBeanDefinitions; - - private AotContribution(Map feignClientBeanDefinitions) { - this.feignClientBeanDefinitions = feignClientBeanDefinitions; - } - - @Override - public void applyTo(GenerationContext generationContext, - BeanFactoryInitializationCode beanFactoryInitializationCode) { - RuntimeHints hints = generationContext.getRuntimeHints(); - Set feignClientRegistrationMethods = feignClientBeanDefinitions.values().stream() - .map(beanDefinition -> { - Assert.notNull(beanDefinition, "beanDefinition cannot be null"); - Assert.isInstanceOf(GenericBeanDefinition.class, beanDefinition); - GenericBeanDefinition registeredBeanDefinition = (GenericBeanDefinition) beanDefinition; - MutablePropertyValues feignClientProperties = registeredBeanDefinition.getPropertyValues(); - String className = (String) feignClientProperties.get("type"); - Assert.notNull(className, "className cannot be null"); - Class clazz = ClassUtils.resolveClassName(className, null); - hints.proxies().registerJdkProxy(clazz); - registerMethodHints(hints.reflection(), clazz); - return beanFactoryInitializationCode.getMethods() - .add(buildMethodName(className), method -> generateFeignClientRegistrationMethod(method, - feignClientProperties, registeredBeanDefinition)) - .getName(); - }).collect(Collectors.toSet()); - MethodReference initializerMethod = beanFactoryInitializationCode.getMethods() - .add("initialize", method -> generateInitializerMethod(method, feignClientRegistrationMethods)) - .toMethodReference(); - beanFactoryInitializationCode.addInitializer(initializerMethod); - } - - private String buildMethodName(String clientName) { - return "register" + clientName + "FeignClient"; - } - - private void generateInitializerMethod(MethodSpec.Builder method, Set feignClientRegistrationMethods) { - method.addModifiers(Modifier.PUBLIC); - method.addParameter(DefaultListableBeanFactory.class, "registry"); - feignClientRegistrationMethods.forEach(feignClientRegistrationMethod -> method.addStatement("$N(registry)", - feignClientRegistrationMethod)); - } - - private void generateFeignClientRegistrationMethod(MethodSpec.Builder method, - MutablePropertyValues feignClientPropertyValues, GenericBeanDefinition registeredBeanDefinition) { - Object feignQualifiers = feignClientPropertyValues.get("qualifiers"); - Assert.notNull(feignQualifiers, "Feign qualifiers cannot be null"); - String qualifiers = "{\"" + String.join("\",\"", (String[]) feignQualifiers) + "\"}"; - method.addJavadoc("register Feign Client: $L", feignClientPropertyValues.get("type")) - .addModifiers(Modifier.PUBLIC, Modifier.STATIC) - .addParameter(BeanDefinitionRegistry.class, "registry") - .addStatement("Class clazz = $T.resolveClassName(\"$L\", null)", ClassUtils.class, - feignClientPropertyValues.get("type")) - .addStatement("$T definition = $T.genericBeanDefinition($T.class)", BeanDefinitionBuilder.class, - BeanDefinitionBuilder.class, FeignClientFactoryBean.class) - .addStatement("definition.addPropertyValue(\"name\",\"$L\")", feignClientPropertyValues.get("name")) - .addStatement("definition.addPropertyValue(\"contextId\", \"$L\")", - feignClientPropertyValues.get("contextId")) - .addStatement("definition.addPropertyValue(\"type\", clazz)") - .addStatement("definition.addPropertyValue(\"url\", \"$L\")", feignClientPropertyValues.get("url")) - .addStatement("definition.addPropertyValue(\"path\", \"$L\")", - feignClientPropertyValues.get("path")) - .addStatement("definition.addPropertyValue(\"dismiss404\", $L)", - feignClientPropertyValues.get("dismiss404")) - .addStatement("definition.addPropertyValue(\"fallback\", $T.class)", - feignClientPropertyValues.get("fallback")) - .addStatement("definition.addPropertyValue(\"fallbackFactory\", $T.class)", - feignClientPropertyValues.get("fallbackFactory")) - .addStatement("definition.setAutowireMode($L)", registeredBeanDefinition.getAutowireMode()) - .addStatement("definition.setLazyInit($L)", - registeredBeanDefinition.getLazyInit() != null ? registeredBeanDefinition.getLazyInit() - : false) - .addStatement("$T beanDefinition = definition.getBeanDefinition()", AbstractBeanDefinition.class) - .addStatement("beanDefinition.setAttribute(\"$L\", clazz)", FactoryBean.OBJECT_TYPE_ATTRIBUTE) - .addStatement("beanDefinition.setPrimary($L)", registeredBeanDefinition.isPrimary()) - .addStatement("$T holder = new $T(beanDefinition, \"$L\", new String[]$L)", - BeanDefinitionHolder.class, BeanDefinitionHolder.class, - feignClientPropertyValues.get("type"), qualifiers) - .addStatement("$T.registerBeanDefinition(holder, registry) ", BeanDefinitionReaderUtils.class); - } - - // Visible for tests - Map getFeignClientBeanDefinitions() { - return feignClientBeanDefinitions; - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/clientconfig/FeignClientConfigurer.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/clientconfig/FeignClientConfigurer.java deleted file mode 100644 index 2a56d3163..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/clientconfig/FeignClientConfigurer.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2013-2022 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.clientconfig; - -/** - * Additional Feign Client configuration that are not included in - * {@link org.springframework.cloud.openfeign.FeignClient}. - * - * @author Matt King - */ -public interface FeignClientConfigurer { - - /** - * @return whether to mark the feign proxy as a primary bean. Defaults to true. - */ - default boolean primary() { - return true; - } - - /** - * FALSE will only apply configurations from classes listed in - * configuration(). Will still use parent instance of - * {@link feign.codec.Decoder}, {@link feign.codec.Encoder}, and - * {@link feign.Contract} if none are provided. - * @return weather to inherit parent context for client configuration. - */ - default boolean inheritParentConfiguration() { - return true; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/clientconfig/Http2ClientFeignConfiguration.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/clientconfig/Http2ClientFeignConfiguration.java deleted file mode 100644 index f61063750..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/clientconfig/Http2ClientFeignConfiguration.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2013-2023 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.clientconfig; - -import java.net.http.HttpClient; -import java.time.Duration; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.cloud.openfeign.support.FeignHttpClientProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * Default configuration for {@link HttpClient}. - * - * @author changjin wei(魏昌进) - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnMissingBean(HttpClient.class) -public class Http2ClientFeignConfiguration { - - @Bean - public HttpClient httpClient(FeignHttpClientProperties httpClientProperties) { - return HttpClient.newBuilder() - .followRedirects(httpClientProperties.isFollowRedirects() ? HttpClient.Redirect.ALWAYS - : HttpClient.Redirect.NEVER) - .version(HttpClient.Version.valueOf(httpClientProperties.getHttp2().getVersion())) - .connectTimeout(Duration.ofMillis(httpClientProperties.getConnectionTimeout())).build(); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/clientconfig/HttpClient5FeignConfiguration.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/clientconfig/HttpClient5FeignConfiguration.java deleted file mode 100644 index 36ff6b1d1..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/clientconfig/HttpClient5FeignConfiguration.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2013-2022 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.clientconfig; - -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.cert.X509Certificate; -import java.util.concurrent.TimeUnit; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import jakarta.annotation.PreDestroy; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.hc.client5.http.config.RequestConfig; -import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; -import org.apache.hc.client5.http.impl.classic.HttpClients; -import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; -import org.apache.hc.client5.http.io.HttpClientConnectionManager; -import org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory; -import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; -import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder; -import org.apache.hc.core5.http.io.SocketConfig; -import org.apache.hc.core5.http.ssl.TLS; -import org.apache.hc.core5.io.CloseMode; -import org.apache.hc.core5.pool.PoolConcurrencyPolicy; -import org.apache.hc.core5.pool.PoolReusePolicy; -import org.apache.hc.core5.ssl.SSLContexts; -import org.apache.hc.core5.util.TimeValue; -import org.apache.hc.core5.util.Timeout; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.cloud.openfeign.support.FeignHttpClientProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * Default configuration for {@link CloseableHttpClient}. - * - * @author Nguyen Ky Thanh - * @author changjin wei(魏昌进) - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnMissingBean(CloseableHttpClient.class) -public class HttpClient5FeignConfiguration { - - private static final Log LOG = LogFactory.getLog(HttpClient5FeignConfiguration.class); - - private CloseableHttpClient httpClient5; - - @Bean - @ConditionalOnMissingBean(HttpClientConnectionManager.class) - public HttpClientConnectionManager hc5ConnectionManager(FeignHttpClientProperties httpClientProperties) { - return PoolingHttpClientConnectionManagerBuilder.create() - .setSSLSocketFactory(httpsSSLConnectionSocketFactory(httpClientProperties.isDisableSslValidation())) - .setMaxConnTotal(httpClientProperties.getMaxConnections()) - .setMaxConnPerRoute(httpClientProperties.getMaxConnectionsPerRoute()) - .setConnPoolPolicy(PoolReusePolicy.valueOf(httpClientProperties.getHc5().getPoolReusePolicy().name())) - .setPoolConcurrencyPolicy( - PoolConcurrencyPolicy.valueOf(httpClientProperties.getHc5().getPoolConcurrencyPolicy().name())) - .setConnectionTimeToLive( - TimeValue.of(httpClientProperties.getTimeToLive(), httpClientProperties.getTimeToLiveUnit())) - .setDefaultSocketConfig( - SocketConfig.custom().setSoTimeout(Timeout.of(httpClientProperties.getHc5().getSocketTimeout(), - httpClientProperties.getHc5().getSocketTimeoutUnit())).build()) - .build(); - } - - @Bean - public CloseableHttpClient httpClient5(HttpClientConnectionManager connectionManager, - FeignHttpClientProperties httpClientProperties) { - httpClient5 = HttpClients.custom().disableCookieManagement().useSystemProperties() - .setConnectionManager(connectionManager).evictExpiredConnections() - .setDefaultRequestConfig(RequestConfig.custom() - .setConnectTimeout( - Timeout.of(httpClientProperties.getConnectionTimeout(), TimeUnit.MILLISECONDS)) - .setRedirectsEnabled(httpClientProperties.isFollowRedirects()) - .setConnectionRequestTimeout( - Timeout.of(httpClientProperties.getHc5().getConnectionRequestTimeout(), - httpClientProperties.getHc5().getConnectionRequestTimeoutUnit())) - .build()) - .build(); - return httpClient5; - } - - @PreDestroy - public void destroy() { - if (httpClient5 != null) { - httpClient5.close(CloseMode.GRACEFUL); - } - } - - private LayeredConnectionSocketFactory httpsSSLConnectionSocketFactory(boolean isDisableSslValidation) { - final SSLConnectionSocketFactoryBuilder sslConnectionSocketFactoryBuilder = SSLConnectionSocketFactoryBuilder - .create().setTlsVersions(TLS.V_1_3, TLS.V_1_2); - - if (isDisableSslValidation) { - try { - final SSLContext sslContext = SSLContext.getInstance("SSL"); - sslContext.init(null, new TrustManager[] { new DisabledValidationTrustManager() }, new SecureRandom()); - sslConnectionSocketFactoryBuilder.setSslContext(sslContext); - sslConnectionSocketFactoryBuilder.setHostnameVerifier(NoopHostnameVerifier.INSTANCE); - } - catch (NoSuchAlgorithmException | KeyManagementException e) { - LOG.warn("Error creating SSLContext", e); - } - } - else { - sslConnectionSocketFactoryBuilder.setSslContext(SSLContexts.createSystemDefault()); - } - - return sslConnectionSocketFactoryBuilder.build(); - } - - static class DisabledValidationTrustManager implements X509TrustManager { - - DisabledValidationTrustManager() { - } - - public void checkClientTrusted(X509Certificate[] x509Certificates, String s) { - } - - public void checkServerTrusted(X509Certificate[] x509Certificates, String s) { - } - - public X509Certificate[] getAcceptedIssuers() { - return null; - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/BaseRequestInterceptor.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/BaseRequestInterceptor.java deleted file mode 100644 index 987336b84..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/BaseRequestInterceptor.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding; - -import feign.RequestInterceptor; -import feign.RequestTemplate; - -import org.springframework.util.Assert; - -/** - * The base request interceptor. - * - * @author Jakub Narloch - */ -public abstract class BaseRequestInterceptor implements RequestInterceptor { - - /** - * The encoding properties. - */ - private final FeignClientEncodingProperties properties; - - /** - * Creates new instance of {@link BaseRequestInterceptor}. - * @param properties the encoding properties - */ - protected BaseRequestInterceptor(FeignClientEncodingProperties properties) { - Assert.notNull(properties, "Properties can not be null"); - this.properties = properties; - } - - /** - * Adds the header if it wasn't yet specified. - * @param requestTemplate the request - * @param name the header name - * @param values the header values - */ - protected void addHeader(RequestTemplate requestTemplate, String name, String... values) { - - if (!requestTemplate.headers().containsKey(name)) { - requestTemplate.header(name, values); - } - } - - protected FeignClientEncodingProperties getProperties() { - return this.properties; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignAcceptGzipEncodingAutoConfiguration.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignAcceptGzipEncodingAutoConfiguration.java deleted file mode 100644 index 896bc85f1..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignAcceptGzipEncodingAutoConfiguration.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2013-2023 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.encoding; - -import feign.Client; -import feign.Feign; - -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.openfeign.FeignAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; - -/** - * Configures the Feign response compression. - * - * @author Jakub Narloch - * @author Olga Maciaszek-Sharma - * @see FeignAcceptGzipEncodingInterceptor - */ -@Configuration(proxyBeanMethods = false) -@EnableConfigurationProperties(FeignClientEncodingProperties.class) -@ConditionalOnClass(Feign.class) -@ConditionalOnBean(Client.class) -@ConditionalOnProperty("spring.cloud.openfeign.compression.response.enabled") -// The OK HTTP client uses "transparent" compression. -// If the accept-encoding header is present, it disables transparent compression. -@Conditional(OkHttpFeignClientBeanMissingCondition.class) -@AutoConfigureAfter(FeignAutoConfiguration.class) -public class FeignAcceptGzipEncodingAutoConfiguration { - - @Bean - public FeignAcceptGzipEncodingInterceptor feignAcceptGzipEncodingInterceptor( - FeignClientEncodingProperties properties) { - return new FeignAcceptGzipEncodingInterceptor(properties); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignAcceptGzipEncodingInterceptor.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignAcceptGzipEncodingInterceptor.java deleted file mode 100644 index 5b09a84c6..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignAcceptGzipEncodingInterceptor.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding; - -import feign.RequestTemplate; - -/** - * Enables the HTTP response payload compression by specifying the {@code Accept-Encoding} - * headers. Although this does not yet mean that the requests will be compressed, it - * requires the remote server to understand the header and be configured to compress - * responses. Still no all responses might be compressed based on the media type matching - * and other factors like the response content length. - * - * @author Jakub Narloch - */ -public class FeignAcceptGzipEncodingInterceptor extends BaseRequestInterceptor { - - /** - * Creates new instance of {@link FeignAcceptGzipEncodingInterceptor}. - * @param properties the encoding properties - */ - protected FeignAcceptGzipEncodingInterceptor(FeignClientEncodingProperties properties) { - super(properties); - } - - /** - * {@inheritDoc} - */ - @Override - public void apply(RequestTemplate template) { - - addHeader(template, HttpEncoding.ACCEPT_ENCODING_HEADER, HttpEncoding.GZIP_ENCODING, - HttpEncoding.DEFLATE_ENCODING); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignClientEncodingProperties.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignClientEncodingProperties.java deleted file mode 100644 index ece7bce79..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignClientEncodingProperties.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding; - -import java.util.Arrays; -import java.util.Objects; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * The Feign encoding properties. - * - * @author Jakub Narloch - */ -@ConfigurationProperties("spring.cloud.openfeign.compression.request") -public class FeignClientEncodingProperties { - - /** - * The list of supported mime types. - */ - private String[] mimeTypes = new String[] { "text/xml", "application/xml", "application/json" }; - - /** - * The minimum threshold content size. - */ - private int minRequestSize = 2048; - - public String[] getMimeTypes() { - return mimeTypes; - } - - public void setMimeTypes(String[] mimeTypes) { - this.mimeTypes = mimeTypes; - } - - public int getMinRequestSize() { - return minRequestSize; - } - - public void setMinRequestSize(int minRequestSize) { - this.minRequestSize = minRequestSize; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - FeignClientEncodingProperties that = (FeignClientEncodingProperties) o; - return Arrays.equals(mimeTypes, that.mimeTypes) && Objects.equals(minRequestSize, that.minRequestSize); - } - - @Override - public int hashCode() { - return Objects.hash(Arrays.hashCode(mimeTypes), minRequestSize); - } - - @Override - public String toString() { - return new StringBuilder("FeignClientEncodingProperties{").append("mimeTypes=") - .append(Arrays.toString(mimeTypes)).append(", ").append("minRequestSize=").append(minRequestSize) - .append("}").toString(); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignContentGzipEncodingAutoConfiguration.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignContentGzipEncodingAutoConfiguration.java deleted file mode 100644 index 0b2587b9b..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignContentGzipEncodingAutoConfiguration.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2013-2023 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.encoding; - -import feign.Feign; - -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.openfeign.FeignAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; - -/** - * Configures the Feign request compression. - * - * @author Jakub Narloch - * @author Olga Maciaszek-Sharma - * @see FeignContentGzipEncodingInterceptor - */ -@Configuration(proxyBeanMethods = false) -@EnableConfigurationProperties(FeignClientEncodingProperties.class) -@ConditionalOnClass(Feign.class) -// The OK HTTP client uses "transparent" compression. -// If the content-encoding header is present, it disables transparent compression. -@Conditional(OkHttpFeignClientBeanMissingCondition.class) -@ConditionalOnProperty("spring.cloud.openfeign.compression.request.enabled") -@AutoConfigureAfter(FeignAutoConfiguration.class) -public class FeignContentGzipEncodingAutoConfiguration { - - @Bean - public FeignContentGzipEncodingInterceptor feignContentGzipEncodingInterceptor( - FeignClientEncodingProperties properties) { - return new FeignContentGzipEncodingInterceptor(properties); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignContentGzipEncodingInterceptor.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignContentGzipEncodingInterceptor.java deleted file mode 100644 index e8cbe19c6..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/FeignContentGzipEncodingInterceptor.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding; - -import java.util.Collection; -import java.util.Map; - -import feign.RequestTemplate; - -/** - * Enables the HTTP request payload compression by specifying the {@code Content-Encoding} - * headers. - * - * @author Jakub Narloch - */ -public class FeignContentGzipEncodingInterceptor extends BaseRequestInterceptor { - - /** - * Creates new instance of {@link FeignContentGzipEncodingInterceptor}. - * @param properties the encoding properties - */ - protected FeignContentGzipEncodingInterceptor(FeignClientEncodingProperties properties) { - super(properties); - } - - /** - * {@inheritDoc} - */ - @Override - public void apply(RequestTemplate template) { - - if (requiresCompression(template)) { - addHeader(template, HttpEncoding.CONTENT_ENCODING_HEADER, HttpEncoding.GZIP_ENCODING, - HttpEncoding.DEFLATE_ENCODING); - } - } - - /** - * Returns whether the request requires GZIP compression. - * @param template the request template - * @return true if request requires compression, false otherwise - */ - private boolean requiresCompression(RequestTemplate template) { - - final Map> headers = template.headers(); - return matchesMimeType(headers.get(HttpEncoding.CONTENT_TYPE)) - && contentLengthExceedThreshold(headers.get(HttpEncoding.CONTENT_LENGTH)); - } - - /** - * Returns whether the request content length exceed configured minimum size. - * @param contentLength the content length header value - * @return true if length is grater than minimum size, false otherwise - */ - private boolean contentLengthExceedThreshold(Collection contentLength) { - - try { - if (contentLength == null || contentLength.size() != 1) { - return false; - } - - final String strLen = contentLength.iterator().next(); - final long length = Long.parseLong(strLen); - return length > getProperties().getMinRequestSize(); - } - catch (NumberFormatException ex) { - return false; - } - } - - /** - * Returns whether the content mime types matches the configured mime types. - * @param contentTypes the content types - * @return true if any specified content type matches the request content types - */ - private boolean matchesMimeType(Collection contentTypes) { - if (contentTypes == null || contentTypes.size() == 0) { - return false; - } - - if (getProperties().getMimeTypes() == null || getProperties().getMimeTypes().length == 0) { - // no specific mime types has been set - matching everything - return true; - } - - for (String mimeType : getProperties().getMimeTypes()) { - if (contentTypes.contains(mimeType)) { - return true; - } - } - - return false; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/HttpEncoding.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/HttpEncoding.java deleted file mode 100644 index cd13d217c..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/HttpEncoding.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding; - -/** - * Lists all constants used by Feign encoders. - * - * @author Jakub Narloch - */ -public interface HttpEncoding { - - /** - * The HTTP Content-Length header. - */ - String CONTENT_LENGTH = "Content-Length"; - - /** - * The HTTP Content-Type header. - */ - String CONTENT_TYPE = "Content-Type"; - - /** - * The HTTP Accept-Encoding header. - */ - String ACCEPT_ENCODING_HEADER = "Accept-Encoding"; - - /** - * The HTTP Content-Encoding header. - */ - String CONTENT_ENCODING_HEADER = "Content-Encoding"; - - /** - * The GZIP encoding. - */ - String GZIP_ENCODING = "gzip"; - - /** - * The Deflate encoding. - */ - String DEFLATE_ENCODING = "deflate"; - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/OkHttpFeignClientBeanMissingCondition.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/OkHttpFeignClientBeanMissingCondition.java deleted file mode 100644 index 1614700bf..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/encoding/OkHttpFeignClientBeanMissingCondition.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2013-2023 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.encoding; - -import feign.Client; -import feign.okhttp.OkHttpClient; - -import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Condition; - -/** - * A {@link Condition} that verifies whether the conditions for creating Feign - * {@link Client} beans that either are of type {@link OkHttpClient} or have a delegate of - * type {@link OkHttpClient} are not met. - * - * @author Olga Maciaszek-Sharma - * @since 4.0.2 - */ -public class OkHttpFeignClientBeanMissingCondition extends AnyNestedCondition { - - public OkHttpFeignClientBeanMissingCondition() { - super(ConfigurationPhase.REGISTER_BEAN); - } - - @ConditionalOnMissingClass("feign.okhttp.OkHttpClient") - static class FeignOkHttpClientPresent { - - } - - @ConditionalOnProperty(value = "spring.cloud.openfeign.okhttp.enabled", havingValue = "false") - static class FeignOkHttpClientEnabled { - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/hateoas/FeignHalAutoConfiguration.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/hateoas/FeignHalAutoConfiguration.java deleted file mode 100644 index c92f207ca..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/hateoas/FeignHalAutoConfiguration.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2016-2022 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.hateoas; - -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; -import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration; -import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.cloud.openfeign.support.HttpMessageConverterCustomizer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.hateoas.config.HateoasConfiguration; -import org.springframework.hateoas.config.WebConverters; - -/** - * @author Hector Espert - * @author Olga Maciaszek-Sharma - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnWebApplication -@ConditionalOnClass(WebConverters.class) -@AutoConfigureAfter({ JacksonAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, - RepositoryRestMvcAutoConfiguration.class, HateoasConfiguration.class }) -public class FeignHalAutoConfiguration { - - @Bean - @ConditionalOnBean(WebConverters.class) - HttpMessageConverterCustomizer webConvertersCustomizer(WebConverters webConverters) { - return new WebConvertersCustomizer(webConverters); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/hateoas/WebConvertersCustomizer.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/hateoas/WebConvertersCustomizer.java deleted file mode 100644 index e3fae6136..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/hateoas/WebConvertersCustomizer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2016-2022 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.hateoas; - -import java.util.List; - -import org.springframework.cloud.openfeign.support.HttpMessageConverterCustomizer; -import org.springframework.hateoas.config.WebConverters; -import org.springframework.http.converter.HttpMessageConverter; - -/** - * @author Olga Maciaszek-Sharma - */ -public class WebConvertersCustomizer implements HttpMessageConverterCustomizer { - - private final WebConverters webConverters; - - public WebConvertersCustomizer(WebConverters webConverters) { - this.webConverters = webConverters; - } - - @Override - public void accept(List> httpMessageConverters) { - webConverters.augmentClient(httpMessageConverters); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/DefaultFeignLoadBalancerConfiguration.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/DefaultFeignLoadBalancerConfiguration.java deleted file mode 100644 index e5a07edef..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/DefaultFeignLoadBalancerConfiguration.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2013-2022 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.loadbalancer; - -import java.util.List; - -import feign.Client; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory; -import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; -import org.springframework.cloud.client.loadbalancer.LoadBalancerClientsProperties; -import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; - -/** - * Configuration instantiating a {@link LoadBalancerClient}-based {@link Client} object - * that uses {@link Client.Default} under the hood. - * - * @author Olga Maciaszek-Sharma - * @author changjin wei(魏昌进) - * @since 2.2.0 - */ -@Configuration(proxyBeanMethods = false) -@EnableConfigurationProperties(LoadBalancerClientsProperties.class) -class DefaultFeignLoadBalancerConfiguration { - - @Bean - @ConditionalOnMissingBean - @Conditional(OnRetryNotEnabledCondition.class) - public Client feignClient(LoadBalancerClient loadBalancerClient, - LoadBalancerClientFactory loadBalancerClientFactory, - List transformers) { - return new FeignBlockingLoadBalancerClient(new Client.Default(null, null), loadBalancerClient, - loadBalancerClientFactory, transformers); - } - - @Bean - @ConditionalOnMissingBean - @ConditionalOnClass(name = "org.springframework.retry.support.RetryTemplate") - @ConditionalOnBean(LoadBalancedRetryFactory.class) - @ConditionalOnProperty(value = "spring.cloud.loadbalancer.retry.enabled", havingValue = "true", - matchIfMissing = true) - public Client feignRetryClient(LoadBalancerClient loadBalancerClient, - LoadBalancedRetryFactory loadBalancedRetryFactory, LoadBalancerClientFactory loadBalancerClientFactory, - List transformers) { - return new RetryableFeignBlockingLoadBalancerClient(new Client.Default(null, null), loadBalancerClient, - loadBalancedRetryFactory, loadBalancerClientFactory, transformers); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/FeignBlockingLoadBalancerClient.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/FeignBlockingLoadBalancerClient.java deleted file mode 100644 index e7f2d4468..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/FeignBlockingLoadBalancerClient.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2013-2022 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.loadbalancer; - -import java.io.IOException; -import java.net.URI; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import feign.Client; -import feign.Request; -import feign.Response; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.client.loadbalancer.CompletionContext; -import org.springframework.cloud.client.loadbalancer.DefaultRequest; -import org.springframework.cloud.client.loadbalancer.DefaultResponse; -import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; -import org.springframework.cloud.client.loadbalancer.LoadBalancerLifecycle; -import org.springframework.cloud.client.loadbalancer.LoadBalancerLifecycleValidator; -import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties; -import org.springframework.cloud.client.loadbalancer.RequestDataContext; -import org.springframework.cloud.client.loadbalancer.ResponseData; -import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; -import org.springframework.http.HttpStatus; -import org.springframework.util.Assert; - -import static org.springframework.cloud.openfeign.loadbalancer.LoadBalancerUtils.buildRequestData; -import static org.springframework.cloud.openfeign.loadbalancer.LoadBalancerUtils.executeWithLoadBalancerLifecycleProcessing; - -/** - * A {@link Client} implementation that uses {@link LoadBalancerClient} to select a - * {@link ServiceInstance} to use while resolving the request host. - * - * @author Olga Maciaszek-Sharma - * @author changjin wei(魏昌进) - * @since 2.2.0 - */ -@SuppressWarnings({ "unchecked", "rawtypes" }) -public class FeignBlockingLoadBalancerClient implements Client { - - private static final Log LOG = LogFactory.getLog(FeignBlockingLoadBalancerClient.class); - - private final Client delegate; - - private final LoadBalancerClient loadBalancerClient; - - private final LoadBalancerClientFactory loadBalancerClientFactory; - - private final List transformers; - - /** - * @deprecated in favour of - * {@link FeignBlockingLoadBalancerClient#FeignBlockingLoadBalancerClient(Client, LoadBalancerClient, LoadBalancerClientFactory, List)} - */ - @Deprecated - public FeignBlockingLoadBalancerClient(Client delegate, LoadBalancerClient loadBalancerClient, - LoadBalancerProperties properties, LoadBalancerClientFactory loadBalancerClientFactory) { - this.delegate = delegate; - this.loadBalancerClient = loadBalancerClient; - this.loadBalancerClientFactory = loadBalancerClientFactory; - this.transformers = Collections.emptyList(); - } - - /** - * @deprecated in favour of - * {@link FeignBlockingLoadBalancerClient#FeignBlockingLoadBalancerClient(Client, LoadBalancerClient, LoadBalancerClientFactory, List)} - */ - @Deprecated - public FeignBlockingLoadBalancerClient(Client delegate, LoadBalancerClient loadBalancerClient, - LoadBalancerClientFactory loadBalancerClientFactory) { - this.delegate = delegate; - this.loadBalancerClient = loadBalancerClient; - this.loadBalancerClientFactory = loadBalancerClientFactory; - this.transformers = Collections.emptyList(); - } - - public FeignBlockingLoadBalancerClient(Client delegate, LoadBalancerClient loadBalancerClient, - LoadBalancerClientFactory loadBalancerClientFactory, - List transformers) { - this.delegate = delegate; - this.loadBalancerClient = loadBalancerClient; - this.loadBalancerClientFactory = loadBalancerClientFactory; - this.transformers = transformers; - } - - @Override - public Response execute(Request request, Request.Options options) throws IOException { - final URI originalUri = URI.create(request.url()); - String serviceId = originalUri.getHost(); - Assert.state(serviceId != null, "Request URI does not contain a valid hostname: " + originalUri); - String hint = getHint(serviceId); - DefaultRequest lbRequest = new DefaultRequest<>( - new RequestDataContext(buildRequestData(request), hint)); - Set supportedLifecycleProcessors = LoadBalancerLifecycleValidator - .getSupportedLifecycleProcessors( - loadBalancerClientFactory.getInstances(serviceId, LoadBalancerLifecycle.class), - RequestDataContext.class, ResponseData.class, ServiceInstance.class); - supportedLifecycleProcessors.forEach(lifecycle -> lifecycle.onStart(lbRequest)); - ServiceInstance instance = loadBalancerClient.choose(serviceId, lbRequest); - org.springframework.cloud.client.loadbalancer.Response lbResponse = new DefaultResponse( - instance); - if (instance == null) { - String message = "Load balancer does not contain an instance for the service " + serviceId; - if (LOG.isWarnEnabled()) { - LOG.warn(message); - } - supportedLifecycleProcessors.forEach(lifecycle -> lifecycle - .onComplete(new CompletionContext( - CompletionContext.Status.DISCARD, lbRequest, lbResponse))); - return Response.builder().request(request).status(HttpStatus.SERVICE_UNAVAILABLE.value()) - .body(message, StandardCharsets.UTF_8).build(); - } - String reconstructedUrl = loadBalancerClient.reconstructURI(instance, originalUri).toString(); - Request newRequest = buildRequest(request, reconstructedUrl, instance); - return executeWithLoadBalancerLifecycleProcessing(delegate, options, newRequest, lbRequest, lbResponse, - supportedLifecycleProcessors); - } - - protected Request buildRequest(Request request, String reconstructedUrl) { - return Request.create(request.httpMethod(), reconstructedUrl, request.headers(), request.body(), - request.charset(), request.requestTemplate()); - } - - protected Request buildRequest(Request request, String reconstructedUrl, ServiceInstance instance) { - Request newRequest = buildRequest(request, reconstructedUrl); - if (transformers != null) { - for (LoadBalancerFeignRequestTransformer transformer : transformers) { - newRequest = transformer.transformRequest(newRequest, instance); - } - } - return newRequest; - } - - // Visible for Sleuth instrumentation - public Client getDelegate() { - return delegate; - } - - private String getHint(String serviceId) { - LoadBalancerProperties properties = loadBalancerClientFactory.getProperties(serviceId); - String defaultHint = properties.getHint().getOrDefault("default", "default"); - String hintPropertyValue = properties.getHint().get(serviceId); - return hintPropertyValue != null ? hintPropertyValue : defaultHint; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/FeignLoadBalancerAutoConfiguration.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/FeignLoadBalancerAutoConfiguration.java deleted file mode 100644 index d760a68f3..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/FeignLoadBalancerAutoConfiguration.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2013-2023 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.loadbalancer; - -import feign.Client; -import feign.Feign; - -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration; -import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; -import org.springframework.cloud.loadbalancer.config.BlockingLoadBalancerClientAutoConfiguration; -import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; -import org.springframework.cloud.openfeign.FeignAutoConfiguration; -import org.springframework.cloud.openfeign.support.FeignHttpClientProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; - -/** - * An autoconfiguration that instantiates {@link LoadBalancerClient}-based implementations - * of {@link Client}. - * - * @author Olga Maciaszek-Sharma - * @author Nguyen Ky Thanh - * @author changjin wei(魏昌进) - * @since 2.2.0 - */ -@ConditionalOnClass(Feign.class) -@ConditionalOnBean({ LoadBalancerClient.class, LoadBalancerClientFactory.class }) -@AutoConfigureBefore(FeignAutoConfiguration.class) -@AutoConfigureAfter({ BlockingLoadBalancerClientAutoConfiguration.class, LoadBalancerAutoConfiguration.class }) -@EnableConfigurationProperties(FeignHttpClientProperties.class) -@Configuration(proxyBeanMethods = false) -// Order is important here, last should be the default, first should be optional -// see -// https://github.com/spring-cloud/spring-cloud-netflix/issues/2086#issuecomment-316281653 -@Import({ OkHttpFeignLoadBalancerConfiguration.class, HttpClient5FeignLoadBalancerConfiguration.class, - Http2ClientFeignLoadBalancerConfiguration.class, DefaultFeignLoadBalancerConfiguration.class }) -public class FeignLoadBalancerAutoConfiguration { - - @Bean - @ConditionalOnBean(LoadBalancerClientFactory.class) - @ConditionalOnMissingBean(XForwardedHeadersTransformer.class) - public XForwardedHeadersTransformer xForwarderHeadersFeignTransformer(LoadBalancerClientFactory factory) { - return new XForwardedHeadersTransformer(factory); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/Http2ClientFeignLoadBalancerConfiguration.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/Http2ClientFeignLoadBalancerConfiguration.java deleted file mode 100644 index 92f68586e..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/Http2ClientFeignLoadBalancerConfiguration.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2013-2023 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.loadbalancer; - -import java.net.http.HttpClient; -import java.util.List; - -import feign.Client; -import feign.http2client.Http2Client; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory; -import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; -import org.springframework.cloud.client.loadbalancer.LoadBalancerClientsProperties; -import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; - -/** - * Configuration instantiating a {@link LoadBalancerClient}-based {@link Client} object - * that uses {@link Http2Client} under the hood. - * - * @author changjin wei(魏昌进) - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnClass({ Http2Client.class, HttpClient.class }) -@ConditionalOnBean({ LoadBalancerClient.class, LoadBalancerClientFactory.class }) -@ConditionalOnProperty("spring.cloud.openfeign.http2client.enabled") -@EnableConfigurationProperties(LoadBalancerClientsProperties.class) -class Http2ClientFeignLoadBalancerConfiguration { - - @Bean - @ConditionalOnMissingBean - @Conditional(OnRetryNotEnabledCondition.class) - public Client feignClient(LoadBalancerClient loadBalancerClient, HttpClient httpClient, - LoadBalancerClientFactory loadBalancerClientFactory, - List transformers) { - Client delegate = new Http2Client(httpClient); - return new FeignBlockingLoadBalancerClient(delegate, loadBalancerClient, loadBalancerClientFactory, - transformers); - } - - @Bean - @ConditionalOnMissingBean - @ConditionalOnClass(name = "org.springframework.retry.support.RetryTemplate") - @ConditionalOnBean(LoadBalancedRetryFactory.class) - @ConditionalOnProperty(value = "spring.cloud.loadbalancer.retry.enabled", havingValue = "true", - matchIfMissing = true) - public Client feignRetryClient(LoadBalancerClient loadBalancerClient, HttpClient httpClient, - LoadBalancedRetryFactory loadBalancedRetryFactory, LoadBalancerClientFactory loadBalancerClientFactory, - List transformers) { - Client delegate = new Http2Client(httpClient); - return new RetryableFeignBlockingLoadBalancerClient(delegate, loadBalancerClient, loadBalancedRetryFactory, - loadBalancerClientFactory, transformers); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/HttpClient5FeignLoadBalancerConfiguration.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/HttpClient5FeignLoadBalancerConfiguration.java deleted file mode 100644 index 305c8fbd5..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/HttpClient5FeignLoadBalancerConfiguration.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2013-2022 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.loadbalancer; - -import java.util.List; - -import feign.Client; -import feign.hc5.ApacheHttp5Client; -import org.apache.hc.client5.http.classic.HttpClient; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory; -import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; -import org.springframework.cloud.client.loadbalancer.LoadBalancerClientsProperties; -import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; -import org.springframework.cloud.openfeign.clientconfig.HttpClient5FeignConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; - -/** - * Configuration instantiating a {@link LoadBalancerClient}-based {@link Client} object - * that uses {@link ApacheHttp5Client} under the hood. - * - * @author Nguyen Ky Thanh - * @author changjin wei(魏昌进) - * @author Olga Maciaszek-Sharma - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnClass(ApacheHttp5Client.class) -@ConditionalOnBean({ LoadBalancerClient.class, LoadBalancerClientFactory.class }) -@ConditionalOnProperty(value = "spring.cloud.openfeign.httpclient.hc5.enabled", havingValue = "true", - matchIfMissing = true) -@Import(HttpClient5FeignConfiguration.class) -@EnableConfigurationProperties(LoadBalancerClientsProperties.class) -class HttpClient5FeignLoadBalancerConfiguration { - - @Bean - @ConditionalOnMissingBean - @Conditional(OnRetryNotEnabledCondition.class) - public Client feignClient(LoadBalancerClient loadBalancerClient, HttpClient httpClient5, - LoadBalancerClientFactory loadBalancerClientFactory, - List transformers) { - Client delegate = new ApacheHttp5Client(httpClient5); - return new FeignBlockingLoadBalancerClient(delegate, loadBalancerClient, loadBalancerClientFactory, - transformers); - } - - @Bean - @ConditionalOnMissingBean - @ConditionalOnClass(name = "org.springframework.retry.support.RetryTemplate") - @ConditionalOnBean(LoadBalancedRetryFactory.class) - @ConditionalOnProperty(value = "spring.cloud.loadbalancer.retry.enabled", havingValue = "true", - matchIfMissing = true) - public Client feignRetryClient(LoadBalancerClient loadBalancerClient, HttpClient httpClient5, - LoadBalancedRetryFactory loadBalancedRetryFactory, LoadBalancerClientFactory loadBalancerClientFactory, - List transformers) { - Client delegate = new ApacheHttp5Client(httpClient5); - return new RetryableFeignBlockingLoadBalancerClient(delegate, loadBalancerClient, loadBalancedRetryFactory, - loadBalancerClientFactory, transformers); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerFeignRequestTransformer.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerFeignRequestTransformer.java deleted file mode 100644 index bda313eda..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerFeignRequestTransformer.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2013-2022 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.loadbalancer; - -import feign.Request; - -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.core.annotation.Order; - -/** - * Allows applications to transform the load-balanced {@link Request} given the chosen - * {@link org.springframework.cloud.client.ServiceInstance}. - * - * @author changjin wei(魏昌进) - */ -@Order(LoadBalancerFeignRequestTransformer.DEFAULT_ORDER) -public interface LoadBalancerFeignRequestTransformer { - - /** - * Order for the {@link LoadBalancerFeignRequestTransformer}. - */ - int DEFAULT_ORDER = 0; - - /** - * Allows transforming load-balanced requests based on the provided - * {@link ServiceInstance}. - * @param request Original request. - * @param instance ServiceInstance returned from LoadBalancer. - * @return New request or original request - */ - Request transformRequest(Request request, ServiceInstance instance); - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerResponseStatusCodeException.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerResponseStatusCodeException.java deleted file mode 100644 index 5c22709cd..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerResponseStatusCodeException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013-2022 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.loadbalancer; - -import java.io.ByteArrayInputStream; -import java.net.URI; - -import feign.Response; - -import org.springframework.cloud.client.loadbalancer.RetryableStatusCodeException; - -/** - * A {@link RetryableStatusCodeException} for {@link Response}s. - * - * @author Ryan Baxter - */ -public class LoadBalancerResponseStatusCodeException extends RetryableStatusCodeException { - - private final Response response; - - public LoadBalancerResponseStatusCodeException(String serviceId, Response response, byte[] body, URI uri) { - super(serviceId, response.status(), response, uri); - this.response = Response.builder().body(new ByteArrayInputStream(body), body.length).headers(response.headers()) - .reason(response.reason()).status(response.status()).request(response.request()).build(); - } - - @Override - public Response getResponse() { - return this.response; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerUtils.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerUtils.java deleted file mode 100644 index 9432d05af..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/LoadBalancerUtils.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2013-2022 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.loadbalancer; - -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Set; - -import feign.Client; -import feign.Request; -import feign.Response; - -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.client.loadbalancer.CompletionContext; -import org.springframework.cloud.client.loadbalancer.LoadBalancerLifecycle; -import org.springframework.cloud.client.loadbalancer.RequestData; -import org.springframework.cloud.client.loadbalancer.ResponseData; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatusCode; - -/** - * @author Olga Maciaszek-Sharma - * - * A utility class for handling {@link LoadBalancerLifecycle} calls. - */ -@SuppressWarnings({ "unchecked", "rawtypes" }) -final class LoadBalancerUtils { - - private LoadBalancerUtils() { - throw new IllegalStateException("Can't instantiate a utility class"); - } - - static Response executeWithLoadBalancerLifecycleProcessing(Client feignClient, Request.Options options, - Request feignRequest, org.springframework.cloud.client.loadbalancer.Request lbRequest, - org.springframework.cloud.client.loadbalancer.Response lbResponse, - Set supportedLifecycleProcessors, boolean loadBalanced) throws IOException { - supportedLifecycleProcessors.forEach(lifecycle -> lifecycle.onStartRequest(lbRequest, lbResponse)); - try { - Response response = feignClient.execute(feignRequest, options); - if (loadBalanced) { - supportedLifecycleProcessors.forEach( - lifecycle -> lifecycle.onComplete(new CompletionContext<>(CompletionContext.Status.SUCCESS, - lbRequest, lbResponse, buildResponseData(response)))); - } - return response; - } - catch (Exception exception) { - if (loadBalanced) { - supportedLifecycleProcessors.forEach(lifecycle -> lifecycle.onComplete( - new CompletionContext<>(CompletionContext.Status.FAILED, exception, lbRequest, lbResponse))); - } - throw exception; - } - } - - static ResponseData buildResponseData(Response response) { - HttpHeaders responseHeaders = new HttpHeaders(); - response.headers().forEach((key, value) -> responseHeaders.put(key, new ArrayList<>(value))); - return new ResponseData(HttpStatusCode.valueOf(response.status()), responseHeaders, null, - buildRequestData(response.request())); - } - - static RequestData buildRequestData(Request request) { - HttpHeaders requestHeaders = new HttpHeaders(); - request.headers().forEach((key, value) -> requestHeaders.put(key, new ArrayList<>(value))); - return new RequestData(HttpMethod.valueOf(request.httpMethod().name()), URI.create(request.url()), - requestHeaders, null, new HashMap<>()); - } - - static Response executeWithLoadBalancerLifecycleProcessing(Client feignClient, Request.Options options, - Request feignRequest, org.springframework.cloud.client.loadbalancer.Request lbRequest, - org.springframework.cloud.client.loadbalancer.Response lbResponse, - Set supportedLifecycleProcessors) throws IOException { - return executeWithLoadBalancerLifecycleProcessing(feignClient, options, feignRequest, lbRequest, lbResponse, - supportedLifecycleProcessors, true); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/OkHttpFeignLoadBalancerConfiguration.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/OkHttpFeignLoadBalancerConfiguration.java deleted file mode 100644 index f450aef47..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/OkHttpFeignLoadBalancerConfiguration.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2013-2022 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.loadbalancer; - -import java.util.List; - -import feign.Client; -import feign.okhttp.OkHttpClient; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory; -import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; -import org.springframework.cloud.client.loadbalancer.LoadBalancerClientsProperties; -import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; - -/** - * Configuration instantiating a {@link LoadBalancerClient}-based {@link Client} object - * that uses {@link OkHttpClient} under the hood. - * - * @author Olga Maciaszek-Sharma - * @author changjin wei(魏昌进) - * @since 2.2.0 - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnClass(OkHttpClient.class) -@ConditionalOnProperty("spring.cloud.openfeign.okhttp.enabled") -@ConditionalOnBean({ LoadBalancerClient.class, LoadBalancerClientFactory.class }) -@EnableConfigurationProperties(LoadBalancerClientsProperties.class) -class OkHttpFeignLoadBalancerConfiguration { - - @Bean - @ConditionalOnMissingBean - @Conditional(OnRetryNotEnabledCondition.class) - public Client feignClient(okhttp3.OkHttpClient okHttpClient, LoadBalancerClient loadBalancerClient, - LoadBalancerClientFactory loadBalancerClientFactory, - List transformers) { - OkHttpClient delegate = new OkHttpClient(okHttpClient); - return new FeignBlockingLoadBalancerClient(delegate, loadBalancerClient, loadBalancerClientFactory, - transformers); - } - - @Bean - @ConditionalOnMissingBean - @ConditionalOnClass(name = "org.springframework.retry.support.RetryTemplate") - @ConditionalOnBean(LoadBalancedRetryFactory.class) - @ConditionalOnProperty(value = "spring.cloud.loadbalancer.retry.enabled", havingValue = "true", - matchIfMissing = true) - public Client feignRetryClient(LoadBalancerClient loadBalancerClient, okhttp3.OkHttpClient okHttpClient, - LoadBalancedRetryFactory loadBalancedRetryFactory, LoadBalancerClientFactory loadBalancerClientFactory, - List transformers) { - OkHttpClient delegate = new OkHttpClient(okHttpClient); - return new RetryableFeignBlockingLoadBalancerClient(delegate, loadBalancerClient, loadBalancedRetryFactory, - loadBalancerClientFactory, transformers); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/OnRetryNotEnabledCondition.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/OnRetryNotEnabledCondition.java deleted file mode 100644 index 3bdaf7305..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/OnRetryNotEnabledCondition.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2013-2022 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.loadbalancer; - -import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory; -import org.springframework.retry.support.RetryTemplate; - -/** - * A condition that verifies that {@link RetryTemplate} is on the classpath, a - * {@link LoadBalancedRetryFactory} bean is present and - * spring.cloud.loadbalancer.retry.enabled is not set to false. - * - * @author Olga Maciaszek-Sharma - * @since 2.2.6 - */ -public class OnRetryNotEnabledCondition extends AnyNestedCondition { - - public OnRetryNotEnabledCondition() { - super(ConfigurationPhase.REGISTER_BEAN); - } - - @ConditionalOnMissingClass("org.springframework.retry.support.RetryTemplate") - static class OnNoRetryTemplateCondition { - - } - - @ConditionalOnMissingBean(LoadBalancedRetryFactory.class) - static class OnRetryFactoryCondition { - - } - - @ConditionalOnProperty(value = "spring.cloud.loadbalancer.retry.enabled", havingValue = "false") - static class OnLoadBalancerRetryEnabledCondition { - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClient.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClient.java deleted file mode 100644 index 82b7b9627..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClient.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright 2013-2023 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.loadbalancer; - -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import feign.Client; -import feign.Request; -import feign.Response; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.client.loadbalancer.CompletionContext; -import org.springframework.cloud.client.loadbalancer.DefaultRequest; -import org.springframework.cloud.client.loadbalancer.DefaultResponse; -import org.springframework.cloud.client.loadbalancer.InterceptorRetryPolicy; -import org.springframework.cloud.client.loadbalancer.LoadBalancedRecoveryCallback; -import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryContext; -import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory; -import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryPolicy; -import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; -import org.springframework.cloud.client.loadbalancer.LoadBalancerLifecycle; -import org.springframework.cloud.client.loadbalancer.LoadBalancerLifecycleValidator; -import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties; -import org.springframework.cloud.client.loadbalancer.ResponseData; -import org.springframework.cloud.client.loadbalancer.RetryableRequestContext; -import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpRequest; -import org.springframework.retry.RetryListener; -import org.springframework.retry.backoff.BackOffPolicy; -import org.springframework.retry.backoff.NoBackOffPolicy; -import org.springframework.retry.policy.NeverRetryPolicy; -import org.springframework.retry.support.RetryTemplate; -import org.springframework.util.Assert; -import org.springframework.util.StreamUtils; - -import static org.springframework.cloud.openfeign.loadbalancer.LoadBalancerUtils.buildRequestData; - -/** - * A {@link Client} implementation that provides Spring Retry support for requests - * load-balanced with Spring Cloud LoadBalancer. - * - * @author Olga Maciaszek-Sharma - * @author changjin wei(魏昌进) - * @author Wonsik Cheung - * @author Andriy Pikozh - * @since 2.2.6 - */ -@SuppressWarnings({ "rawtypes", "unchecked" }) -public class RetryableFeignBlockingLoadBalancerClient implements Client { - - private static final Log LOG = LogFactory.getLog(RetryableFeignBlockingLoadBalancerClient.class); - - private final Client delegate; - - private final LoadBalancerClient loadBalancerClient; - - private final LoadBalancedRetryFactory loadBalancedRetryFactory; - - private final LoadBalancerClientFactory loadBalancerClientFactory; - - private final List transformers; - - /** - * @deprecated in favour of - * {@link RetryableFeignBlockingLoadBalancerClient#RetryableFeignBlockingLoadBalancerClient(Client, LoadBalancerClient, LoadBalancedRetryFactory, LoadBalancerClientFactory, List)} - */ - @Deprecated - public RetryableFeignBlockingLoadBalancerClient(Client delegate, LoadBalancerClient loadBalancerClient, - LoadBalancedRetryFactory loadBalancedRetryFactory, LoadBalancerProperties properties, - LoadBalancerClientFactory loadBalancerClientFactory) { - this.delegate = delegate; - this.loadBalancerClient = loadBalancerClient; - this.loadBalancedRetryFactory = loadBalancedRetryFactory; - this.loadBalancerClientFactory = loadBalancerClientFactory; - this.transformers = Collections.emptyList(); - } - - /** - * @deprecated in favour of - * {@link RetryableFeignBlockingLoadBalancerClient#RetryableFeignBlockingLoadBalancerClient(Client, LoadBalancerClient, LoadBalancedRetryFactory, LoadBalancerClientFactory, List)} - */ - @Deprecated - public RetryableFeignBlockingLoadBalancerClient(Client delegate, LoadBalancerClient loadBalancerClient, - LoadBalancedRetryFactory loadBalancedRetryFactory, LoadBalancerClientFactory loadBalancerClientFactory) { - this.delegate = delegate; - this.loadBalancerClient = loadBalancerClient; - this.loadBalancedRetryFactory = loadBalancedRetryFactory; - this.loadBalancerClientFactory = loadBalancerClientFactory; - this.transformers = Collections.emptyList(); - } - - public RetryableFeignBlockingLoadBalancerClient(Client delegate, LoadBalancerClient loadBalancerClient, - LoadBalancedRetryFactory loadBalancedRetryFactory, LoadBalancerClientFactory loadBalancerClientFactory, - List transformers) { - this.delegate = delegate; - this.loadBalancerClient = loadBalancerClient; - this.loadBalancedRetryFactory = loadBalancedRetryFactory; - this.loadBalancerClientFactory = loadBalancerClientFactory; - this.transformers = transformers; - } - - @Override - public Response execute(Request request, Request.Options options) throws IOException { - final URI originalUri = URI.create(request.url()); - String serviceId = originalUri.getHost(); - Assert.state(serviceId != null, "Request URI does not contain a valid hostname: " + originalUri); - final LoadBalancedRetryPolicy retryPolicy = loadBalancedRetryFactory.createRetryPolicy(serviceId, - loadBalancerClient); - RetryTemplate retryTemplate = buildRetryTemplate(serviceId, request, retryPolicy); - return retryTemplate.execute(context -> { - Request feignRequest = null; - ServiceInstance retrievedServiceInstance = null; - Set supportedLifecycleProcessors = LoadBalancerLifecycleValidator - .getSupportedLifecycleProcessors( - loadBalancerClientFactory.getInstances(serviceId, LoadBalancerLifecycle.class), - RetryableRequestContext.class, ResponseData.class, ServiceInstance.class); - String hint = getHint(serviceId); - DefaultRequest lbRequest = new DefaultRequest<>( - new RetryableRequestContext(null, buildRequestData(request), hint)); - // On retries the policy will choose the server and set it in the context - // and extract the server and update the request being made - if (context instanceof LoadBalancedRetryContext lbContext) { - retrievedServiceInstance = lbContext.getServiceInstance(); - if (retrievedServiceInstance == null) { - if (LOG.isDebugEnabled()) { - LOG.debug("Service instance retrieved from LoadBalancedRetryContext: was null. " - + "Reattempting service instance selection"); - } - ServiceInstance previousServiceInstance = lbContext.getPreviousServiceInstance(); - lbRequest.getContext().setPreviousServiceInstance(previousServiceInstance); - supportedLifecycleProcessors.forEach(lifecycle -> lifecycle.onStart(lbRequest)); - retrievedServiceInstance = loadBalancerClient.choose(serviceId, lbRequest); - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Selected service instance: %s", retrievedServiceInstance)); - } - lbContext.setServiceInstance(retrievedServiceInstance); - } - - if (retrievedServiceInstance == null) { - if (LOG.isWarnEnabled()) { - LOG.warn("Service instance was not resolved, executing the original request"); - } - org.springframework.cloud.client.loadbalancer.Response lbResponse = new DefaultResponse( - retrievedServiceInstance); - supportedLifecycleProcessors.forEach(lifecycle -> lifecycle - .onComplete(new CompletionContext( - CompletionContext.Status.DISCARD, lbRequest, lbResponse))); - feignRequest = request; - } - else { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Using service instance from LoadBalancedRetryContext: %s", - retrievedServiceInstance)); - } - String reconstructedUrl = loadBalancerClient.reconstructURI(retrievedServiceInstance, originalUri) - .toString(); - feignRequest = buildRequest(request, reconstructedUrl, retrievedServiceInstance); - } - } - org.springframework.cloud.client.loadbalancer.Response lbResponse = new DefaultResponse( - retrievedServiceInstance); - LoadBalancerProperties loadBalancerProperties = loadBalancerClientFactory.getProperties(serviceId); - Response response = LoadBalancerUtils.executeWithLoadBalancerLifecycleProcessing(delegate, options, - feignRequest, lbRequest, lbResponse, supportedLifecycleProcessors, - retrievedServiceInstance != null); - int responseStatus = response.status(); - if (retryPolicy != null && retryPolicy.retryableStatusCode(responseStatus)) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Retrying on status code: %d", responseStatus)); - } - byte[] byteArray = response.body() == null ? new byte[] {} - : StreamUtils.copyToByteArray(response.body().asInputStream()); - response.close(); - throw new LoadBalancerResponseStatusCodeException(serviceId, response, byteArray, - URI.create(request.url())); - } - return response; - }, new LoadBalancedRecoveryCallback() { - @Override - protected Response createResponse(Response response, URI uri) { - return response; - } - }); - } - - protected Request buildRequest(Request request, String reconstructedUrl) { - return Request.create(request.httpMethod(), reconstructedUrl, request.headers(), request.body(), - request.charset(), request.requestTemplate()); - } - - protected Request buildRequest(Request request, String reconstructedUrl, ServiceInstance instance) { - Request newRequest = buildRequest(request, reconstructedUrl); - if (transformers != null) { - for (LoadBalancerFeignRequestTransformer transformer : transformers) { - newRequest = transformer.transformRequest(newRequest, instance); - } - } - return newRequest; - } - - private RetryTemplate buildRetryTemplate(String serviceId, Request request, LoadBalancedRetryPolicy retryPolicy) { - RetryTemplate retryTemplate = new RetryTemplate(); - BackOffPolicy backOffPolicy = this.loadBalancedRetryFactory.createBackOffPolicy(serviceId); - retryTemplate.setBackOffPolicy(backOffPolicy == null ? new NoBackOffPolicy() : backOffPolicy); - RetryListener[] retryListeners = this.loadBalancedRetryFactory.createRetryListeners(serviceId); - if (retryListeners != null && retryListeners.length != 0) { - retryTemplate.setListeners(retryListeners); - } - - retryTemplate.setRetryPolicy( - !loadBalancerClientFactory.getProperties(serviceId).getRetry().isEnabled() || retryPolicy == null - ? new NeverRetryPolicy() : new InterceptorRetryPolicy(toHttpRequest(request), retryPolicy, - loadBalancerClient, serviceId)); - return retryTemplate; - } - - // Visible for Sleuth instrumentation - public Client getDelegate() { - return delegate; - } - - private HttpRequest toHttpRequest(Request request) { - return new HttpRequest() { - @Override - public HttpMethod getMethod() { - return HttpMethod.valueOf(request.httpMethod().name()); - } - - @Override - public URI getURI() { - return URI.create(request.url()); - } - - @Override - public HttpHeaders getHeaders() { - Map> headers = new HashMap<>(); - Map> feignHeaders = request.headers(); - for (String key : feignHeaders.keySet()) { - headers.put(key, new ArrayList<>(feignHeaders.get(key))); - } - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.putAll(headers); - return httpHeaders; - } - }; - } - - private String getHint(String serviceId) { - LoadBalancerProperties properties = loadBalancerClientFactory.getProperties(serviceId); - String defaultHint = properties.getHint().getOrDefault("default", "default"); - String hintPropertyValue = properties.getHint().get(serviceId); - return hintPropertyValue != null ? hintPropertyValue : defaultHint; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/XForwardedHeadersTransformer.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/XForwardedHeadersTransformer.java deleted file mode 100644 index e7533cbc9..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/XForwardedHeadersTransformer.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2013-2022 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.loadbalancer; - -import java.net.URI; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import feign.Request; - -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties; -import org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer; - -/** - * To add X-Forwarded-Host and X-Forwarded-Proto Headers. - * - * @author changjin wei(魏昌进) - */ -public class XForwardedHeadersTransformer implements LoadBalancerFeignRequestTransformer { - - private final ReactiveLoadBalancer.Factory factory; - - public XForwardedHeadersTransformer(ReactiveLoadBalancer.Factory factory) { - this.factory = factory; - } - - @Override - public Request transformRequest(Request request, ServiceInstance instance) { - if (instance == null) { - return request; - } - LoadBalancerProperties.XForwarded xForwarded = factory.getProperties(instance.getServiceId()).getXForwarded(); - if (xForwarded.isEnabled()) { - Map> headers = new HashMap<>(request.headers()); - URI uri = URI.create(request.url()); - String xForwardedHost = uri.getHost(); - String xForwardedProto = uri.getScheme(); - headers.put("X-Forwarded-Host", Collections.singleton(xForwardedHost)); - headers.put("X-Forwarded-Proto", Collections.singleton(xForwardedProto)); - request = Request.create(request.httpMethod(), request.url(), headers, request.body(), request.charset(), - request.requestTemplate()); - } - return request; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/security/OAuth2AccessTokenInterceptor.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/security/OAuth2AccessTokenInterceptor.java deleted file mode 100644 index 69aeb6198..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/security/OAuth2AccessTokenInterceptor.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2015-2022 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.security; - -import java.net.URI; -import java.util.Optional; - -import feign.RequestInterceptor; -import feign.RequestTemplate; -import feign.Target; - -import org.springframework.security.authentication.AnonymousAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.authority.AuthorityUtils; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.oauth2.client.OAuth2AuthorizeRequest; -import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; -import org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager; -import org.springframework.security.oauth2.core.OAuth2AccessToken; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; - -/** - * A {@link RequestInterceptor} for OAuth2 Feign Requests. By default, it uses the - * {@link OAuth2AuthorizedClientManager } to get {@link OAuth2AuthorizedClient } that - * holds an {@link OAuth2AccessToken }. If the user has specified an OAuth2 - * {@code clientRegistrationId} using the - * {@code spring.cloud.openfeign.oauth2.clientRegistrationId} property, it will be used to - * retrieve the token. If the token is not retrieved or the {@code clientRegistrationId} - * has not been specified, the {@code serviceId} retrieved from the {@code url} host - * segment will be used. This approach is convenient for load-balanced Feign clients. For - * non-load-balanced ones, the property-based {@code clientRegistrationId} is a suitable - * approach. - * - * @author Dangzhicairang(小水牛) - * @author Olga Maciaszek-Sharma - * @since 4.0.0 - */ -public class OAuth2AccessTokenInterceptor implements RequestInterceptor { - - /** - * The name of the token. - */ - public static final String BEARER = "Bearer"; - - /** - * The name of the header. - */ - public static final String AUTHORIZATION = "Authorization"; - - private final String tokenType; - - private final String header; - - private final String clientRegistrationId; - - private final OAuth2AuthorizedClientManager authorizedClientManager; - - private static final Authentication ANONYMOUS_AUTHENTICATION = new AnonymousAuthenticationToken("anonymous", - "anonymousUser", AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS")); - - public OAuth2AccessTokenInterceptor(OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager) { - this(null, oAuth2AuthorizedClientManager); - } - - public OAuth2AccessTokenInterceptor(String clientRegistrationId, - OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager) { - this(BEARER, AUTHORIZATION, clientRegistrationId, oAuth2AuthorizedClientManager); - } - - public OAuth2AccessTokenInterceptor(String tokenType, String header, String clientRegistrationId, - OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager) { - this.tokenType = tokenType; - this.header = header; - this.clientRegistrationId = clientRegistrationId; - this.authorizedClientManager = oAuth2AuthorizedClientManager; - } - - @Override - public void apply(RequestTemplate template) { - OAuth2AccessToken token = getToken(template); - String extractedToken = String.format("%s %s", tokenType, token.getTokenValue()); - template.header(header); - template.header(header, extractedToken); - } - - public OAuth2AccessToken getToken(RequestTemplate template) { - // If specified, try to use them to get token. - if (StringUtils.hasText(clientRegistrationId)) { - OAuth2AccessToken token = getToken(clientRegistrationId); - if (token != null) { - return token; - } - } - - // If not specified use host (synonymous with serviceId for load-balanced - // requests; non-load-balanced requests should use the method above). - OAuth2AccessToken token = getToken(getServiceId(template)); - if (token != null) { - return token; - } - throw new IllegalStateException("OAuth2 token has not been successfully acquired."); - } - - protected OAuth2AccessToken getToken(String clientRegistrationId) { - if (!StringUtils.hasText(clientRegistrationId)) { - return null; - } - - Authentication principal = SecurityContextHolder.getContext().getAuthentication(); - if (principal == null) { - principal = ANONYMOUS_AUTHENTICATION; - } - - OAuth2AuthorizeRequest authorizeRequest = OAuth2AuthorizeRequest.withClientRegistrationId(clientRegistrationId) - .principal(principal).build(); - OAuth2AuthorizedClient authorizedClient = authorizedClientManager.authorize(authorizeRequest); - return Optional.ofNullable(authorizedClient).map(OAuth2AuthorizedClient::getAccessToken).orElse(null); - } - - private static String getServiceId(RequestTemplate template) { - Target feignTarget = template.feignTarget(); - Assert.notNull(feignTarget, "FeignTarget may not be null."); - String url = feignTarget.url(); - Assert.hasLength(url, "Url may not be empty."); - final URI originalUri = URI.create(url); - return originalUri.getHost(); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/AbstractFormWriter.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/AbstractFormWriter.java deleted file mode 100644 index f93f50971..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/AbstractFormWriter.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.io.IOException; -import java.lang.reflect.Array; -import java.util.Iterator; -import java.util.function.Predicate; - -import feign.codec.EncodeException; -import feign.form.multipart.AbstractWriter; -import feign.form.multipart.Output; -import feign.form.util.PojoUtil; - -import org.springframework.http.MediaType; -import org.springframework.web.multipart.MultipartFile; - -import static feign.form.ContentProcessor.CRLF; - -/** - * @author Darren Foong - * @author Wu Daifu - */ -public abstract class AbstractFormWriter extends AbstractWriter { - - @Override - public boolean isApplicable(Object object) { - return !isTypeOrCollection(object, o -> o instanceof MultipartFile) - && isTypeOrCollection(object, PojoUtil::isUserPojo); - } - - @Override - public void write(Output output, String key, Object object) throws EncodeException { - try { - String string = new StringBuilder().append("Content-Disposition: form-data; name=\"").append(key) - .append('"').append(CRLF).append("Content-Type: ").append(getContentType()).append("; charset=") - .append(output.getCharset().name()).append(CRLF).append(CRLF).append(writeAsString(object)) - .toString(); - - output.write(string); - } - catch (IOException e) { - throw new EncodeException(e.getMessage()); - } - } - - protected abstract MediaType getContentType(); - - protected abstract String writeAsString(Object object) throws IOException; - - private boolean isTypeOrCollection(Object object, Predicate isType) { - if (object == null) { - return false; - } - if (object.getClass().isArray()) { - int len = Array.getLength(object); - if (len > 0) { - Object one = Array.get(object, 0); - return len > 1 && one != null && isType.test(one); - } - return false; - } - else if (object instanceof Iterable iterable) { - Iterator iterator = iterable.iterator(); - - return iterator.hasNext() && isType.test(iterator.next()); - } - else { - return isType.test(object); - } - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/EmptyObjectProvider.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/EmptyObjectProvider.java deleted file mode 100644 index afa4a0583..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/EmptyObjectProvider.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.util.function.Consumer; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.ObjectProvider; - -/** - * @author Olga Maciaszek-Sharma - */ -class EmptyObjectProvider implements ObjectProvider { - - @Override - public T getObject(Object... args) throws BeansException { - return null; - } - - @Override - public T getIfAvailable() throws BeansException { - return null; - } - - @Override - public T getIfUnique() throws BeansException { - return null; - } - - @Override - public T getObject() throws BeansException { - return null; - } - - @Override - public void forEach(Consumer action) { - // do nothing - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignEncoderProperties.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignEncoderProperties.java deleted file mode 100644 index 692002bca..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignEncoderProperties.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Properties for {@link SpringEncoder}. - * - * @author Olga Maciaszek-Sharma - * @since 2.2.8 - */ -@ConfigurationProperties("spring.cloud.openfeign.encoder") -public class FeignEncoderProperties { - - /** - * Indicates whether the charset should be derived from the {@code Content-Type} - * header. - */ - private boolean charsetFromContentType = false; - - public boolean isCharsetFromContentType() { - return charsetFromContentType; - } - - public void setCharsetFromContentType(boolean charsetFromContentType) { - this.charsetFromContentType = charsetFromContentType; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignHttpClientProperties.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignHttpClientProperties.java deleted file mode 100644 index ed8ef817d..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignHttpClientProperties.java +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright 2013-2023 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.support; - -import java.net.http.HttpClient; -import java.time.Duration; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import feign.http2client.Http2Client; -import feign.okhttp.OkHttpClient; -import okhttp3.Protocol; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * @author Ryan Baxter - * @author Nguyen Ky Thanh - * @author Olga Maciaszek-Sharma - * @author changjin wei(魏昌进) - */ -@ConfigurationProperties(prefix = "spring.cloud.openfeign.httpclient") -public class FeignHttpClientProperties { - - /** - * Default value for disabling SSL validation. - */ - public static final boolean DEFAULT_DISABLE_SSL_VALIDATION = false; - - /** - * Default value for max number od connections. - */ - public static final int DEFAULT_MAX_CONNECTIONS = 200; - - /** - * Default value for max number od connections per route. - */ - public static final int DEFAULT_MAX_CONNECTIONS_PER_ROUTE = 50; - - /** - * Default value for time to live. - */ - public static final long DEFAULT_TIME_TO_LIVE = 900L; - - /** - * Default time to live unit. - */ - public static final TimeUnit DEFAULT_TIME_TO_LIVE_UNIT = TimeUnit.SECONDS; - - /** - * Default value for following redirects. - */ - public static final boolean DEFAULT_FOLLOW_REDIRECTS = true; - - /** - * Default value for connection timeout. - */ - public static final int DEFAULT_CONNECTION_TIMEOUT = 2000; - - /** - * Default value for connection timer repeat. - */ - public static final int DEFAULT_CONNECTION_TIMER_REPEAT = 3000; - - private boolean disableSslValidation = DEFAULT_DISABLE_SSL_VALIDATION; - - private int maxConnections = DEFAULT_MAX_CONNECTIONS; - - private int maxConnectionsPerRoute = DEFAULT_MAX_CONNECTIONS_PER_ROUTE; - - private long timeToLive = DEFAULT_TIME_TO_LIVE; - - private TimeUnit timeToLiveUnit = DEFAULT_TIME_TO_LIVE_UNIT; - - private boolean followRedirects = DEFAULT_FOLLOW_REDIRECTS; - - private int connectionTimeout = DEFAULT_CONNECTION_TIMEOUT; - - private int connectionTimerRepeat = DEFAULT_CONNECTION_TIMER_REPEAT; - - /** - * Apache HttpClient5 additional properties. - */ - private Hc5Properties hc5 = new Hc5Properties(); - - /** - * Additional {@link OkHttpClient}-specific properties. - */ - private OkHttp okHttp = new OkHttp(); - - /** - * Additional {@link Http2Client}-specific properties. - */ - private Http2Properties http2 = new Http2Properties(); - - public int getConnectionTimerRepeat() { - return connectionTimerRepeat; - } - - public void setConnectionTimerRepeat(int connectionTimerRepeat) { - this.connectionTimerRepeat = connectionTimerRepeat; - } - - public boolean isDisableSslValidation() { - return disableSslValidation; - } - - public void setDisableSslValidation(boolean disableSslValidation) { - this.disableSslValidation = disableSslValidation; - } - - public int getMaxConnections() { - return maxConnections; - } - - public void setMaxConnections(int maxConnections) { - this.maxConnections = maxConnections; - } - - public int getMaxConnectionsPerRoute() { - return maxConnectionsPerRoute; - } - - public void setMaxConnectionsPerRoute(int maxConnectionsPerRoute) { - this.maxConnectionsPerRoute = maxConnectionsPerRoute; - } - - public long getTimeToLive() { - return timeToLive; - } - - public void setTimeToLive(long timeToLive) { - this.timeToLive = timeToLive; - } - - public TimeUnit getTimeToLiveUnit() { - return timeToLiveUnit; - } - - public void setTimeToLiveUnit(TimeUnit timeToLiveUnit) { - this.timeToLiveUnit = timeToLiveUnit; - } - - public boolean isFollowRedirects() { - return followRedirects; - } - - public void setFollowRedirects(boolean followRedirects) { - this.followRedirects = followRedirects; - } - - public int getConnectionTimeout() { - return connectionTimeout; - } - - public void setConnectionTimeout(int connectionTimeout) { - this.connectionTimeout = connectionTimeout; - } - - public Hc5Properties getHc5() { - return hc5; - } - - public void setHc5(Hc5Properties hc5) { - this.hc5 = hc5; - } - - public OkHttp getOkHttp() { - return okHttp; - } - - public void setOkHttp(OkHttp okHttp) { - this.okHttp = okHttp; - } - - public Http2Properties getHttp2() { - return http2; - } - - public void setHttp2(Http2Properties http2) { - this.http2 = http2; - } - - public static class Hc5Properties { - - /** - * Default value for pool concurrency policy. - */ - public static final PoolConcurrencyPolicy DEFAULT_POOL_CONCURRENCY_POLICY = PoolConcurrencyPolicy.STRICT; - - /** - * Default value for pool reuse policy. - */ - public static final PoolReusePolicy DEFAULT_POOL_REUSE_POLICY = PoolReusePolicy.FIFO; - - /** - * Default value for socket timeout. - */ - public static final int DEFAULT_SOCKET_TIMEOUT = 5; - - /** - * Default value for socket timeout unit. - */ - public static final TimeUnit DEFAULT_SOCKET_TIMEOUT_UNIT = TimeUnit.SECONDS; - - /** - * Default value for connection request timeout. - */ - public static final int DEFAULT_CONNECTION_REQUEST_TIMEOUT = 3; - - /** - * Default value for connection request timeout unit. - */ - public static final TimeUnit DEFAULT_CONNECTION_REQUEST_TIMEOUT_UNIT = TimeUnit.MINUTES; - - /** - * Pool concurrency policies. - */ - private PoolConcurrencyPolicy poolConcurrencyPolicy = DEFAULT_POOL_CONCURRENCY_POLICY; - - /** - * Pool connection re-use policies. - */ - private PoolReusePolicy poolReusePolicy = DEFAULT_POOL_REUSE_POLICY; - - /** - * Default value for socket timeout. - */ - private int socketTimeout = DEFAULT_SOCKET_TIMEOUT; - - /** - * Default value for socket timeout unit. - */ - private TimeUnit socketTimeoutUnit = DEFAULT_SOCKET_TIMEOUT_UNIT; - - /** - * Default value for connection request timeout. - */ - private int connectionRequestTimeout = DEFAULT_CONNECTION_REQUEST_TIMEOUT; - - /** - * Default value for connection request timeout unit. - */ - private TimeUnit connectionRequestTimeoutUnit = DEFAULT_CONNECTION_REQUEST_TIMEOUT_UNIT; - - public PoolConcurrencyPolicy getPoolConcurrencyPolicy() { - return poolConcurrencyPolicy; - } - - public void setPoolConcurrencyPolicy(PoolConcurrencyPolicy poolConcurrencyPolicy) { - this.poolConcurrencyPolicy = poolConcurrencyPolicy; - } - - public PoolReusePolicy getPoolReusePolicy() { - return poolReusePolicy; - } - - public void setPoolReusePolicy(PoolReusePolicy poolReusePolicy) { - this.poolReusePolicy = poolReusePolicy; - } - - public TimeUnit getSocketTimeoutUnit() { - return socketTimeoutUnit; - } - - public void setSocketTimeoutUnit(TimeUnit socketTimeoutUnit) { - this.socketTimeoutUnit = socketTimeoutUnit; - } - - public int getSocketTimeout() { - return socketTimeout; - } - - public void setSocketTimeout(int socketTimeout) { - this.socketTimeout = socketTimeout; - } - - public int getConnectionRequestTimeout() { - return connectionRequestTimeout; - } - - public void setConnectionRequestTimeout(int connectionRequestTimeout) { - this.connectionRequestTimeout = connectionRequestTimeout; - } - - public TimeUnit getConnectionRequestTimeoutUnit() { - return connectionRequestTimeoutUnit; - } - - public void setConnectionRequestTimeoutUnit(TimeUnit connectionRequestTimeoutUnit) { - this.connectionRequestTimeoutUnit = connectionRequestTimeoutUnit; - } - - /** - * Enumeration of pool concurrency policies. - */ - public enum PoolConcurrencyPolicy { - - /** - * Higher concurrency but with lax connection max limit guarantees. - */ - LAX, - - /** - * Strict connection max limit guarantees. - */ - STRICT - - } - - /** - * Enumeration of pooled connection re-use policies. - */ - public enum PoolReusePolicy { - - /** - * Re-use as few connections as possible making it possible for connections to - * become idle and expire. - */ - LIFO, - - /** - * Re-use all connections equally preventing them from becoming idle and - * expiring. - */ - FIFO - - } - - } - - /** - * {@link OkHttpClient}-specific properties. - */ - public static class OkHttp { - - /** - * {@link OkHttpClient} read timeout; defaults to 60 seconds. - */ - private Duration readTimeout = Duration.ofSeconds(60); - - /** - * Configure the protocols used by this client to communicate with remote servers. - * Uses {@link String} values of {@link Protocol}. - */ - private List protocols = List.of("HTTP_2", "HTTP_1_1"); - - public Duration getReadTimeout() { - return readTimeout; - } - - public void setReadTimeout(Duration readTimeout) { - this.readTimeout = readTimeout; - } - - public List getProtocols() { - return protocols; - } - - public void setProtocols(List protocols) { - this.protocols = protocols; - } - - } - - /** - * {@link Http2Client}-specific properties. - */ - public static class Http2Properties { - - /** - * Configure the protocols used by this client to communicate with remote servers. - * Uses {@link String} value of {@link HttpClient.Version}. - */ - private String version = "HTTP_2"; - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - } - -} 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 deleted file mode 100644 index e0862e7a7..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignUtils.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - -import org.springframework.http.HttpHeaders; - -import static java.util.Optional.ofNullable; - -/** - * @author Spencer Gibb - * @author Olga Maciaszek-Sharma - */ -public final class FeignUtils { - - private FeignUtils() { - throw new IllegalStateException("Can't instantiate a utility class"); - } - - static HttpHeaders getHttpHeaders(Map> headers) { - HttpHeaders httpHeaders = new HttpHeaders(); - for (Map.Entry> entry : headers.entrySet()) { - httpHeaders.put(entry.getKey(), new ArrayList<>(entry.getValue())); - } - return httpHeaders; - } - - static Collection addTemplateParameter(Collection possiblyNull, String paramName) { - Collection params = ofNullable(possiblyNull).map(ArrayList::new).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/HttpMessageConverterCustomizer.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/HttpMessageConverterCustomizer.java deleted file mode 100644 index e27444e65..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/HttpMessageConverterCustomizer.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2016-2022 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.support; - -import java.util.List; -import java.util.function.Consumer; - -import org.springframework.http.converter.HttpMessageConverter; - -/** - * Allows customising {@link HttpMessageConverter} objects passed via {@link Consumer} - * parameter. - * - * @author Olga Maciaszek-Sharma - * @since 3.1.0 - */ -public interface HttpMessageConverterCustomizer extends Consumer>> { - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/JsonFormWriter.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/JsonFormWriter.java deleted file mode 100644 index 10166a2d4..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/JsonFormWriter.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.io.IOException; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; - -/** - * @author Darren Foong - */ -@Component -public class JsonFormWriter extends AbstractFormWriter { - - @Autowired - private ObjectMapper objectMapper; - - @Override - protected MediaType getContentType() { - return MediaType.APPLICATION_JSON; - } - - @Override - protected String writeAsString(Object object) throws IOException { - return objectMapper.writeValueAsString(object); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageJacksonModule.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageJacksonModule.java deleted file mode 100644 index 23068bf65..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageJacksonModule.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.util.Iterator; -import java.util.List; -import java.util.function.Function; - -import com.fasterxml.jackson.annotation.JsonAlias; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.Version; -import com.fasterxml.jackson.databind.Module; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; - -/** - * This Jackson module provides support to deserialize Spring {@link Page} objects. - * - * @author Pascal Büttiker - * @author Olga Maciaszek-Sharma - * @author Pedro Mendes - * @author Nikita Konev - */ -public class PageJacksonModule extends Module { - - @Override - public String getModuleName() { - return "PageJacksonModule"; - } - - @Override - public Version version() { - return new Version(0, 1, 0, "", null, null); - } - - @Override - public void setupModule(SetupContext context) { - context.setMixInAnnotations(Page.class, PageMixIn.class); - } - - @JsonDeserialize(as = SimplePageImpl.class) - @JsonIgnoreProperties(ignoreUnknown = true) - private interface PageMixIn { - - } - - static class SimplePageImpl implements Page { - - private final Page delegate; - - SimplePageImpl(@JsonProperty("content") List content, @JsonProperty("number") int number, - @JsonProperty("size") int size, @JsonProperty("totalElements") @JsonAlias({ "total-elements", - "total_elements", "totalelements", "TotalElements" }) long totalElements, - @JsonProperty("sort") Sort sort) { - if (size > 0) { - PageRequest pageRequest; - if (sort != null) { - pageRequest = PageRequest.of(number, size, sort); - } - else { - pageRequest = PageRequest.of(number, size); - } - delegate = new PageImpl<>(content, pageRequest, totalElements); - } - else { - delegate = new PageImpl<>(content); - } - } - - @JsonProperty - @Override - public int getTotalPages() { - return delegate.getTotalPages(); - } - - @JsonProperty - @Override - public long getTotalElements() { - return delegate.getTotalElements(); - } - - @JsonProperty - @Override - public int getNumber() { - return delegate.getNumber(); - } - - @JsonProperty - @Override - public int getSize() { - return delegate.getSize(); - } - - @JsonProperty - @Override - public int getNumberOfElements() { - return delegate.getNumberOfElements(); - } - - @JsonProperty - @Override - public List getContent() { - return delegate.getContent(); - } - - @JsonProperty - @Override - public boolean hasContent() { - return delegate.hasContent(); - } - - @JsonIgnore - @Override - public Sort getSort() { - return delegate.getSort(); - } - - @JsonProperty - @Override - public boolean isFirst() { - return delegate.isFirst(); - } - - @JsonProperty - @Override - public boolean isLast() { - return delegate.isLast(); - } - - @JsonIgnore - @Override - public boolean hasNext() { - return delegate.hasNext(); - } - - @JsonIgnore - @Override - public boolean hasPrevious() { - return delegate.hasPrevious(); - } - - @JsonIgnore - @Override - public Pageable nextPageable() { - return delegate.nextPageable(); - } - - @JsonIgnore - @Override - public Pageable previousPageable() { - return delegate.previousPageable(); - } - - @JsonIgnore - @Override - public Page map(Function converter) { - return delegate.map(converter); - } - - @JsonIgnore - @Override - public Iterator iterator() { - return delegate.iterator(); - } - - @JsonIgnore - @Override - public Pageable getPageable() { - return delegate.getPageable(); - } - - @JsonIgnore - @Override - public boolean isEmpty() { - return delegate.isEmpty(); - } - - @Override - public int hashCode() { - return delegate.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return delegate.equals(obj); - } - - @Override - public String toString() { - return delegate.toString(); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageableSpringEncoder.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageableSpringEncoder.java deleted file mode 100644 index 49f69ec69..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageableSpringEncoder.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import feign.RequestTemplate; -import feign.codec.EncodeException; -import feign.codec.Encoder; - -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; - -/** - * Provides support for encoding spring Pageable via composition. - * - * @author Pascal Büttiker - * @author Yanming Zhou - */ -public class PageableSpringEncoder implements Encoder { - - private final Encoder delegate; - - /** - * Page index parameter name. - */ - private String pageParameter = "page"; - - /** - * Page size parameter name. - */ - private String sizeParameter = "size"; - - /** - * Sort parameter name. - */ - private String sortParameter = "sort"; - - /** - * Creates a new PageableSpringEncoder with the given delegate for fallback. If no - * delegate is provided and this encoder cant handle the request, an EncodeException - * is thrown. - * @param delegate The optional delegate. - */ - public PageableSpringEncoder(Encoder delegate) { - this.delegate = delegate; - } - - public void setPageParameter(String pageParameter) { - this.pageParameter = pageParameter; - } - - public void setSizeParameter(String sizeParameter) { - this.sizeParameter = sizeParameter; - } - - public void setSortParameter(String sortParameter) { - this.sortParameter = sortParameter; - } - - @Override - public void encode(Object object, Type bodyType, RequestTemplate template) throws EncodeException { - - if (supports(object)) { - if (object instanceof Pageable pageable) { - - if (pageable.isPaged()) { - template.query(pageParameter, String.valueOf(pageable.getPageNumber())); - template.query(sizeParameter, String.valueOf(pageable.getPageSize())); - } - - if (pageable.getSort() != null) { - applySort(template, pageable.getSort()); - } - } - else if (object instanceof Sort sort) { - applySort(template, sort); - } - } - else { - if (delegate != null) { - delegate.encode(object, bodyType, template); - } - else { - throw new EncodeException("PageableSpringEncoder does not support the given object " + object.getClass() - + " and no delegate was provided for fallback!"); - } - } - } - - private void applySort(RequestTemplate template, Sort sort) { - Collection existingSorts = template.queries().get("sort"); - List sortQueries = existingSorts != null ? new ArrayList<>(existingSorts) : new ArrayList<>(); - if (!sortParameter.equals("sort")) { - existingSorts = template.queries().get(sortParameter); - if (existingSorts != null) { - sortQueries.addAll(existingSorts); - } - } - for (Sort.Order order : sort) { - sortQueries.add(order.getProperty() + "%2C" + order.getDirection()); - } - if (!sortQueries.isEmpty()) { - template.query(sortParameter, sortQueries); - } - } - - protected boolean supports(Object object) { - return object instanceof Pageable || object instanceof Sort; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageableSpringQueryMapEncoder.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageableSpringQueryMapEncoder.java deleted file mode 100644 index a7c853a12..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/PageableSpringQueryMapEncoder.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import feign.querymap.BeanQueryMapEncoder; - -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; - -/** - * Provides support for encoding Pageable annotated as - * {@link org.springframework.cloud.openfeign.SpringQueryMap}. - * - * @author Hyeonmin Park - * @author Yanming Zhou - * @since 2.2.8 - */ -public class PageableSpringQueryMapEncoder extends BeanQueryMapEncoder { - - /** - * Page index parameter name. - */ - private String pageParameter = "page"; - - /** - * Page size parameter name. - */ - private String sizeParameter = "size"; - - /** - * Sort parameter name. - */ - private String sortParameter = "sort"; - - public void setPageParameter(String pageParameter) { - this.pageParameter = pageParameter; - } - - public void setSizeParameter(String sizeParameter) { - this.sizeParameter = sizeParameter; - } - - public void setSortParameter(String sortParameter) { - this.sortParameter = sortParameter; - } - - @Override - public Map encode(Object object) { - if (supports(object)) { - Map queryMap = new HashMap<>(); - - if (object instanceof Pageable pageable) { - - if (pageable.isPaged()) { - queryMap.put(pageParameter, pageable.getPageNumber()); - queryMap.put(sizeParameter, pageable.getPageSize()); - } - - if (pageable.getSort() != null) { - applySort(queryMap, pageable.getSort()); - } - } - else if (object instanceof Sort sort) { - applySort(queryMap, sort); - } - return queryMap; - } - else { - return super.encode(object); - } - } - - private void applySort(Map queryMap, Sort sort) { - List sortQueries = new ArrayList<>(); - for (Sort.Order order : sort) { - sortQueries.add(order.getProperty() + "%2C" + order.getDirection()); - } - if (!sortQueries.isEmpty()) { - queryMap.put(sortParameter, sortQueries); - } - } - - protected boolean supports(Object object) { - return object instanceof Pageable || object instanceof Sort; - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/ResponseEntityDecoder.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/ResponseEntityDecoder.java deleted file mode 100644 index c1fdee9d0..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/ResponseEntityDecoder.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.io.IOException; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.LinkedList; - -import feign.FeignException; -import feign.Response; -import feign.codec.Decoder; - -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; - -/** - * Decoder adds compatibility for Spring MVC's ResponseEntity to any other decoder via - * composition. - * - * @author chad jaros - * @author Olga Maciaszek-Sharma - */ -public class ResponseEntityDecoder implements Decoder { - - private final Decoder decoder; - - public ResponseEntityDecoder(Decoder decoder) { - this.decoder = decoder; - } - - @Override - public Object decode(final Response response, Type type) throws IOException, FeignException { - - if (isParameterizeHttpEntity(type)) { - type = ((ParameterizedType) type).getActualTypeArguments()[0]; - Object decodedObject = this.decoder.decode(response, type); - - return createResponse(decodedObject, response); - } - else if (isHttpEntity(type)) { - return createResponse(null, response); - } - else { - return this.decoder.decode(response, type); - } - } - - private boolean isParameterizeHttpEntity(Type type) { - if (type instanceof ParameterizedType) { - return isHttpEntity(((ParameterizedType) type).getRawType()); - } - return false; - } - - private boolean isHttpEntity(Type type) { - if (type instanceof Class c) { - return HttpEntity.class.isAssignableFrom(c); - } - return false; - } - - @SuppressWarnings("unchecked") - private ResponseEntity createResponse(Object instance, Response response) { - - HttpHeaders headers = new HttpHeaders(); - for (String key : response.headers().keySet()) { - headers.put(key, new LinkedList<>(response.headers().get(key))); - } - - return new ResponseEntity<>((T) instance, headers, HttpStatus.valueOf(response.status())); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SortJacksonModule.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SortJacksonModule.java deleted file mode 100644 index 90ad67c1c..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SortJacksonModule.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import com.fasterxml.jackson.core.Version; -import com.fasterxml.jackson.databind.Module; -import com.fasterxml.jackson.databind.module.SimpleDeserializers; -import com.fasterxml.jackson.databind.module.SimpleSerializers; - -import org.springframework.data.domain.Sort; - -/** - * This Jackson module provides support for serializing and deserializing for Spring - * {@link Sort} object. - * - * @author Can Bezmen - */ -public class SortJacksonModule extends Module { - - @Override - public String getModuleName() { - return "SortModule"; - } - - @Override - public Version version() { - return new Version(0, 1, 0, "", null, null); - } - - @Override - public void setupModule(SetupContext context) { - SimpleSerializers serializers = new SimpleSerializers(); - serializers.addSerializer(Sort.class, new SortJsonComponent.SortSerializer()); - context.addSerializers(serializers); - - SimpleDeserializers deserializers = new SimpleDeserializers(); - deserializers.addDeserializer(Sort.class, new SortJsonComponent.SortDeserializer()); - context.addDeserializers(deserializers); - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SortJsonComponent.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SortJsonComponent.java deleted file mode 100644 index 44aa30d68..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SortJsonComponent.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.TreeNode; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.node.ArrayNode; -import feign.codec.EncodeException; - -import org.springframework.data.domain.Sort; - -/** - * This class provides provides support for serializing and deserializing for Spring - * {@link Sort} object. - * - * @author Can Bezmen - */ -public class SortJsonComponent { - - public static class SortSerializer extends JsonSerializer { - - @Override - public void serialize(Sort value, JsonGenerator gen, SerializerProvider serializers) throws IOException { - gen.writeStartArray(); - value.iterator().forEachRemaining(v -> { - try { - gen.writeObject(v); - } - catch (IOException e) { - throw new EncodeException("Couldn't serialize object " + v); - } - }); - gen.writeEndArray(); - } - - @Override - public Class handledType() { - return Sort.class; - } - - } - - public static class SortDeserializer extends JsonDeserializer { - - @Override - public Sort deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) - throws IOException { - TreeNode treeNode = jsonParser.getCodec().readTree(jsonParser); - if (treeNode.isArray()) { - ArrayNode arrayNode = (ArrayNode) treeNode; - List orders = new ArrayList<>(); - for (JsonNode jsonNode : arrayNode) { - Sort.Order order = new Sort.Order(Sort.Direction.valueOf(jsonNode.get("direction").textValue()), - jsonNode.get("property").textValue()); - orders.add(order); - } - return Sort.by(orders); - } - return null; - } - - @Override - public Class handledType() { - return Sort.class; - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringDecoder.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringDecoder.java deleted file mode 100644 index c3a29c2e0..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringDecoder.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.lang.reflect.WildcardType; -import java.util.List; - -import feign.FeignException; -import feign.Response; -import feign.codec.DecodeException; -import feign.codec.Decoder; - -import org.springframework.beans.factory.ObjectFactory; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.boot.autoconfigure.http.HttpMessageConverters; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.client.ClientHttpResponse; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.web.client.HttpMessageConverterExtractor; - -import static org.springframework.cloud.openfeign.support.FeignUtils.getHttpHeaders; - -/** - * @author Spencer Gibb - * @author Olga Maciaszek-Sharma - */ -public class SpringDecoder implements Decoder { - - private final ObjectFactory messageConverters; - - private final ObjectProvider customizers; - - /** - * @deprecated in favour of - * {@link SpringDecoder#SpringDecoder(ObjectFactory, ObjectProvider)} - */ - @Deprecated - public SpringDecoder(ObjectFactory messageConverters) { - this(messageConverters, new EmptyObjectProvider<>()); - } - - public SpringDecoder(ObjectFactory messageConverters, - ObjectProvider customizers) { - this.messageConverters = messageConverters; - this.customizers = customizers; - } - - @Override - public Object decode(final Response response, Type type) throws IOException, FeignException { - if (type instanceof Class || type instanceof ParameterizedType || type instanceof WildcardType) { - List> converters = messageConverters.getObject().getConverters(); - customizers.forEach(customizer -> customizer.accept(converters)); - @SuppressWarnings({ "unchecked", "rawtypes" }) - HttpMessageConverterExtractor extractor = new HttpMessageConverterExtractor(type, converters); - - return extractor.extractData(new FeignResponseAdapter(response)); - } - throw new DecodeException(response.status(), "type is not an instance of Class or ParameterizedType: " + type, - response.request()); - } - - private final class FeignResponseAdapter implements ClientHttpResponse { - - private final Response response; - - private FeignResponseAdapter(Response response) { - this.response = response; - } - - @Override - public HttpStatus getStatusCode() { - return HttpStatus.valueOf(response.status()); - } - - @Override - public int getRawStatusCode() { - return response.status(); - } - - @Override - public String getStatusText() { - return response.reason(); - } - - @Override - public void close() { - try { - response.body().close(); - } - catch (IOException ex) { - // Ignore exception on close... - } - } - - @Override - public InputStream getBody() throws IOException { - return response.body().asInputStream(); - } - - @Override - public HttpHeaders getHeaders() { - return getHttpHeaders(response.headers()); - } - - } - -} 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 deleted file mode 100644 index 941857988..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringEncoder.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.lang.reflect.Type; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; - -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.beans.factory.ObjectProvider; -import org.springframework.boot.autoconfigure.http.HttpMessageConverters; -import org.springframework.cloud.openfeign.encoding.HttpEncoding; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpOutputMessage; -import org.springframework.http.MediaType; -import org.springframework.http.converter.ByteArrayHttpMessageConverter; -import org.springframework.http.converter.GenericHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConversionException; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter; -import org.springframework.web.multipart.MultipartFile; - -import static org.springframework.cloud.openfeign.support.FeignUtils.getHttpHeaders; -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED; -import static org.springframework.http.MediaType.MULTIPART_FORM_DATA; -import static org.springframework.http.MediaType.MULTIPART_MIXED; -import static org.springframework.http.MediaType.MULTIPART_RELATED; - -/** - * @author Spencer Gibb - * @author Scien Jus - * @author Ahmad Mozafarnia - * @author Aaron Whiteside - * @author Darren Foong - * @author Olga Maciaszek-Sharma - * @author Can Bezmen - */ -@SuppressWarnings("rawtypes") -public class SpringEncoder implements Encoder { - - private static final Log log = LogFactory.getLog(SpringEncoder.class); - - private final SpringFormEncoder springFormEncoder; - - private final ObjectFactory messageConverters; - - private final FeignEncoderProperties encoderProperties; - - private final ObjectProvider customizers; - - public SpringEncoder(ObjectFactory messageConverters) { - this(new SpringFormEncoder(), messageConverters, new FeignEncoderProperties(), new EmptyObjectProvider<>()); - } - - public SpringEncoder(SpringFormEncoder springFormEncoder, ObjectFactory messageConverters, - FeignEncoderProperties encoderProperties, ObjectProvider customizers) { - this.springFormEncoder = springFormEncoder; - this.messageConverters = messageConverters; - this.encoderProperties = encoderProperties; - this.customizers = customizers; - } - - @Override - public void encode(Object requestBody, Type bodyType, RequestTemplate request) throws EncodeException { - // template.body(conversionService.convert(object, String.class)); - if (requestBody != null) { - Collection contentTypes = request.headers().get(HttpEncoding.CONTENT_TYPE); - - MediaType requestContentType = null; - if (contentTypes != null && !contentTypes.isEmpty()) { - String type = contentTypes.iterator().next(); - requestContentType = MediaType.valueOf(type); - } - - if (isFormRelatedContentType(requestContentType)) { - springFormEncoder.encode(requestBody, bodyType, request); - return; - } - else { - if (bodyType == MultipartFile.class) { - log.warn("For MultipartFile to be handled correctly, the 'consumes' parameter of @RequestMapping " - + "should be specified as MediaType.MULTIPART_FORM_DATA_VALUE"); - } - } - encodeWithMessageConverter(requestBody, bodyType, request, requestContentType); - } - } - - private void encodeWithMessageConverter(Object requestBody, Type bodyType, RequestTemplate request, - MediaType requestContentType) { - List> converters = messageConverters.getObject().getConverters(); - customizers.forEach(customizer -> customizer.accept(converters)); - for (HttpMessageConverter messageConverter : converters) { - FeignOutputMessage outputMessage; - try { - if (messageConverter instanceof GenericHttpMessageConverter) { - outputMessage = checkAndWrite(requestBody, bodyType, requestContentType, - (GenericHttpMessageConverter) messageConverter, request); - } - else { - outputMessage = checkAndWrite(requestBody, requestContentType, messageConverter, request); - } - } - catch (IOException | HttpMessageConversionException ex) { - throw new EncodeException("Error converting request body", ex); - } - if (outputMessage != null) { - // clear headers - request.headers(null); - // converters can modify headers, so update the request - // with the modified headers - request.headers(new LinkedHashMap<>(outputMessage.getHeaders())); - - // do not use charset for binary data and protobuf - Charset charset; - - MediaType contentType = outputMessage.getHeaders().getContentType(); - Charset charsetFromContentType = contentType != null ? contentType.getCharset() : null; - - if (encoderProperties != null && encoderProperties.isCharsetFromContentType() - && charsetFromContentType != null) { - charset = charsetFromContentType; - } - else if (shouldHaveNullCharset(messageConverter, outputMessage)) { - charset = null; - } - else { - charset = StandardCharsets.UTF_8; - } - request.body(outputMessage.getOutputStream().toByteArray(), charset); - return; - } - } - String message = "Could not write request: no suitable HttpMessageConverter " + "found for request type [" - + requestBody.getClass().getName() + "]"; - if (requestContentType != null) { - message += " and content type [" + requestContentType + "]"; - } - throw new EncodeException(message); - } - - private boolean shouldHaveNullCharset(HttpMessageConverter messageConverter, FeignOutputMessage outputMessage) { - return binaryContentType(outputMessage) || messageConverter instanceof ByteArrayHttpMessageConverter - || messageConverter instanceof ProtobufHttpMessageConverter && ProtobufHttpMessageConverter.PROTOBUF - .isCompatibleWith(outputMessage.getHeaders().getContentType()); - } - - @SuppressWarnings("unchecked") - private FeignOutputMessage checkAndWrite(Object body, MediaType contentType, HttpMessageConverter converter, - RequestTemplate request) throws IOException { - if (converter.canWrite(body.getClass(), contentType)) { - logBeforeWrite(body, contentType, converter); - FeignOutputMessage outputMessage = new FeignOutputMessage(request); - converter.write(body, contentType, outputMessage); - return outputMessage; - } - else { - return null; - } - } - - @SuppressWarnings("unchecked") - private FeignOutputMessage checkAndWrite(Object body, Type genericType, MediaType contentType, - GenericHttpMessageConverter converter, RequestTemplate request) throws IOException { - if (converter.canWrite(genericType, body.getClass(), contentType)) { - logBeforeWrite(body, contentType, converter); - FeignOutputMessage outputMessage = new FeignOutputMessage(request); - converter.write(body, genericType, contentType, outputMessage); - return outputMessage; - } - else { - return null; - } - } - - private void logBeforeWrite(Object requestBody, MediaType requestContentType, - HttpMessageConverter messageConverter) { - if (log.isDebugEnabled()) { - if (requestContentType != null) { - log.debug("Writing [" + requestBody + "] as \"" + requestContentType + "\" using [" + messageConverter - + "]"); - } - else { - log.debug("Writing [" + requestBody + "] using [" + messageConverter + "]"); - } - } - } - - private boolean isFormRelatedContentType(MediaType requestContentType) { - return isMultipartType(requestContentType) || isFormUrlEncoded(requestContentType); - } - - private boolean isMultipartType(MediaType requestContentType) { - return Arrays.asList(MULTIPART_FORM_DATA, MULTIPART_MIXED, MULTIPART_RELATED).contains(requestContentType); - } - - private boolean isFormUrlEncoded(MediaType requestContentType) { - return Objects.equals(APPLICATION_FORM_URLENCODED, requestContentType); - } - - protected boolean binaryContentType(FeignOutputMessage outputMessage) { - MediaType contentType = outputMessage.getHeaders().getContentType(); - return contentType == null || Stream - .of(MediaType.APPLICATION_CBOR, MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_PDF, - MediaType.IMAGE_GIF, MediaType.IMAGE_JPEG, MediaType.IMAGE_PNG) - .anyMatch(mediaType -> mediaType.includes(contentType)); - } - - protected final class FeignOutputMessage implements HttpOutputMessage { - - private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - - private final HttpHeaders httpHeaders; - - private FeignOutputMessage(RequestTemplate request) { - httpHeaders = getHttpHeaders(request.headers()); - } - - @Override - public OutputStream getBody() { - return outputStream; - } - - @Override - public HttpHeaders getHeaders() { - return httpHeaders; - } - - public ByteArrayOutputStream getOutputStream() { - return outputStream; - } - - } - -} 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 deleted file mode 100644 index f4e445342..000000000 --- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Copyright 2013-2023 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.support; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.lang.reflect.Parameter; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import feign.Contract; -import feign.Feign; -import feign.MethodMetadata; -import feign.Param; -import feign.QueryMap; -import feign.Request; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.cloud.openfeign.AnnotatedParameterProcessor; -import org.springframework.cloud.openfeign.CollectionFormat; -import org.springframework.cloud.openfeign.SpringQueryMap; -import org.springframework.cloud.openfeign.annotation.CookieValueParameterProcessor; -import org.springframework.cloud.openfeign.annotation.MatrixVariableParameterProcessor; -import org.springframework.cloud.openfeign.annotation.PathVariableParameterProcessor; -import org.springframework.cloud.openfeign.annotation.QueryMapParameterProcessor; -import org.springframework.cloud.openfeign.annotation.RequestHeaderParameterProcessor; -import org.springframework.cloud.openfeign.annotation.RequestParamParameterProcessor; -import org.springframework.cloud.openfeign.annotation.RequestPartParameterProcessor; -import org.springframework.cloud.openfeign.encoding.HttpEncoding; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.ResourceLoaderAware; -import org.springframework.core.DefaultParameterNameDiscoverer; -import org.springframework.core.MethodParameter; -import org.springframework.core.ParameterNameDiscoverer; -import org.springframework.core.ResolvableType; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.core.convert.ConversionService; -import org.springframework.core.convert.TypeDescriptor; -import org.springframework.core.convert.support.DefaultConversionService; -import org.springframework.core.io.DefaultResourceLoader; -import org.springframework.core.io.ResourceLoader; -import org.springframework.data.domain.Pageable; -import org.springframework.http.InvalidMediaTypeException; -import org.springframework.http.MediaType; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; - -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; - -/** - * @author Spencer Gibb - * @author Abhijit Sarkar - * @author Halvdan Hoem Grelland - * @author Aram Peres - * @author Olga Maciaszek-Sharma - * @author Aaron Whiteside - * @author Artyom Romanenko - * @author Darren Foong - * @author Ram Anaswara - * @author Sam Kruglov - */ -public class SpringMvcContract extends Contract.BaseContract implements ResourceLoaderAware { - - private static final Log LOG = LogFactory.getLog(SpringMvcContract.class); - - private static final String ACCEPT = "Accept"; - - private static final String CONTENT_TYPE = "Content-Type"; - - private static final TypeDescriptor STRING_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(String.class); - - private static final TypeDescriptor ITERABLE_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Iterable.class); - - private static final ParameterNameDiscoverer PARAMETER_NAME_DISCOVERER = new DefaultParameterNameDiscoverer(); - - private final Map, AnnotatedParameterProcessor> annotatedArgumentProcessors; - - private final Map processedMethods = new HashMap<>(); - - private final ConversionService conversionService; - - private final ConvertingExpanderFactory convertingExpanderFactory; - - private ResourceLoader resourceLoader = new DefaultResourceLoader(); - - private final boolean decodeSlash; - - public SpringMvcContract() { - this(Collections.emptyList()); - } - - public SpringMvcContract(List annotatedParameterProcessors) { - this(annotatedParameterProcessors, new DefaultConversionService()); - } - - public SpringMvcContract(List annotatedParameterProcessors, - ConversionService conversionService) { - this(annotatedParameterProcessors, conversionService, true); - } - - public SpringMvcContract(List annotatedParameterProcessors, - ConversionService conversionService, boolean decodeSlash) { - Assert.notNull(annotatedParameterProcessors, "Parameter processors can not be null."); - Assert.notNull(conversionService, "ConversionService can not be null."); - - List processors = getDefaultAnnotatedArgumentsProcessors(); - processors.addAll(annotatedParameterProcessors); - - annotatedArgumentProcessors = toAnnotatedArgumentProcessorMap(processors); - this.conversionService = conversionService; - convertingExpanderFactory = new ConvertingExpanderFactory(conversionService); - this.decodeSlash = decodeSlash; - } - - private static TypeDescriptor createTypeDescriptor(Method method, int paramIndex) { - Parameter parameter = method.getParameters()[paramIndex]; - MethodParameter methodParameter = MethodParameter.forParameter(parameter); - TypeDescriptor typeDescriptor = new TypeDescriptor(methodParameter); - - // Feign applies the Param.Expander to each element of an Iterable, so in those - // cases we need to provide a TypeDescriptor of the element. - if (typeDescriptor.isAssignableTo(ITERABLE_TYPE_DESCRIPTOR)) { - TypeDescriptor elementTypeDescriptor = getElementTypeDescriptor(typeDescriptor); - - checkState(elementTypeDescriptor != null, - "Could not resolve element type of Iterable type %s. Not declared?", typeDescriptor); - - typeDescriptor = elementTypeDescriptor; - } - return typeDescriptor; - } - - private static TypeDescriptor getElementTypeDescriptor(TypeDescriptor typeDescriptor) { - TypeDescriptor elementTypeDescriptor = typeDescriptor.getElementTypeDescriptor(); - // that means it's not a collection, but it is iterable, gh-135 - if (elementTypeDescriptor == null && Iterable.class.isAssignableFrom(typeDescriptor.getType())) { - ResolvableType type = typeDescriptor.getResolvableType().as(Iterable.class).getGeneric(0); - if (type.resolve() == null) { - return null; - } - return new TypeDescriptor(type, null, typeDescriptor.getAnnotations()); - } - return elementTypeDescriptor; - } - - @Override - public void setResourceLoader(ResourceLoader resourceLoader) { - this.resourceLoader = resourceLoader; - } - - @Override - protected void processAnnotationOnClass(MethodMetadata data, Class clz) { - RequestMapping classAnnotation = findMergedAnnotation(clz, RequestMapping.class); - if (classAnnotation != null) { - LOG.error("Cannot process class: " + clz.getName() - + ". @RequestMapping annotation is not allowed on @FeignClient interfaces."); - throw new IllegalArgumentException("@RequestMapping annotation not allowed on @FeignClient interfaces"); - } - CollectionFormat collectionFormat = findMergedAnnotation(clz, CollectionFormat.class); - if (collectionFormat != null) { - data.template().collectionFormat(collectionFormat.value()); - } - } - - @Override - public MethodMetadata parseAndValidateMetadata(Class targetType, Method method) { - processedMethods.put(Feign.configKey(targetType, method), method); - return super.parseAndValidateMetadata(targetType, method); - } - - @Override - protected void processAnnotationOnMethod(MethodMetadata data, Annotation methodAnnotation, Method method) { - if (methodAnnotation instanceof CollectionFormat) { - CollectionFormat collectionFormat = findMergedAnnotation(method, CollectionFormat.class); - data.template().collectionFormat(collectionFormat.value()); - } - - if (!(methodAnnotation instanceof RequestMapping) - && !methodAnnotation.annotationType().isAnnotationPresent(RequestMapping.class)) { - return; - } - - RequestMapping methodMapping = findMergedAnnotation(method, RequestMapping.class); - // HTTP Method - RequestMethod[] methods = methodMapping.method(); - if (methods.length == 0) { - methods = new RequestMethod[] { RequestMethod.GET }; - } - checkOne(method, methods, "method"); - data.template().method(Request.HttpMethod.valueOf(methods[0].name())); - - // path - checkAtMostOne(method, methodMapping.value(), "value"); - if (methodMapping.value().length > 0) { - String pathValue = emptyToNull(methodMapping.value()[0]); - if (pathValue != null) { - pathValue = resolve(pathValue); - // Append path from @RequestMapping if value is present on method - if (!pathValue.startsWith("/") && !data.template().path().endsWith("/")) { - pathValue = "/" + pathValue; - } - data.template().uri(pathValue, true); - if (data.template().decodeSlash() != decodeSlash) { - data.template().decodeSlash(decodeSlash); - } - } - } - - // produces - parseProduces(data, method, methodMapping); - - // consumes - parseConsumes(data, method, methodMapping); - - // headers - parseHeaders(data, method, methodMapping); - - data.indexToExpander(new LinkedHashMap<>()); - } - - private String resolve(String value) { - if (StringUtils.hasText(value) && resourceLoader instanceof ConfigurableApplicationContext) { - return ((ConfigurableApplicationContext) resourceLoader).getEnvironment().resolvePlaceholders(value); - } - return value; - } - - private void checkAtMostOne(Method method, Object[] values, String fieldName) { - checkState(values != null && (values.length == 0 || values.length == 1), - "Method %s can only contain at most 1 %s field. Found: %s", method.getName(), fieldName, - values == null ? null : Arrays.asList(values)); - } - - private void checkOne(Method method, Object[] values, String fieldName) { - checkState(values != null && values.length == 1, "Method %s can only contain 1 %s field. Found: %s", - method.getName(), fieldName, values == null ? null : Arrays.asList(values)); - } - - @Override - protected boolean processAnnotationsOnParameter(MethodMetadata data, Annotation[] annotations, int paramIndex) { - boolean isHttpAnnotation = false; - - try { - if (Pageable.class.isAssignableFrom(data.method().getParameterTypes()[paramIndex])) { - // do not set a Pageable as QueryMap if there's an actual QueryMap param - // present - if (!queryMapParamPresent(data)) { - data.queryMapIndex(paramIndex); - return false; - } - } - } - catch (NoClassDefFoundError ignored) { - // Do nothing; added to avoid exceptions if optional dependency not present - } - - AnnotatedParameterProcessor.AnnotatedParameterContext context = new SimpleAnnotatedParameterContext(data, - paramIndex); - Method method = processedMethods.get(data.configKey()); - for (Annotation parameterAnnotation : annotations) { - AnnotatedParameterProcessor processor = annotatedArgumentProcessors - .get(parameterAnnotation.annotationType()); - if (processor != null) { - Annotation processParameterAnnotation; - // synthesize, handling @AliasFor, while falling back to parameter name on - // missing String #value(): - processParameterAnnotation = synthesizeWithMethodParameterNameAsFallbackValue(parameterAnnotation, - method, paramIndex); - isHttpAnnotation |= processor.processArgument(context, processParameterAnnotation, method); - } - } - - if (!isMultipartFormData(data) && isHttpAnnotation && data.indexToExpander().get(paramIndex) == null) { - TypeDescriptor typeDescriptor = createTypeDescriptor(method, paramIndex); - if (conversionService.canConvert(typeDescriptor, STRING_TYPE_DESCRIPTOR)) { - Param.Expander expander = convertingExpanderFactory.getExpander(typeDescriptor); - if (expander != null) { - data.indexToExpander().put(paramIndex, expander); - } - } - } - return isHttpAnnotation; - } - - private boolean queryMapParamPresent(MethodMetadata data) { - Annotation[][] paramsAnnotations = data.method().getParameterAnnotations(); - for (int i = 0; i < paramsAnnotations.length; i++) { - Annotation[] paramAnnotations = paramsAnnotations[i]; - Class parameterType = data.method().getParameterTypes()[i]; - if (Arrays.stream(paramAnnotations).anyMatch( - annotation -> Map.class.isAssignableFrom(parameterType) && annotation instanceof RequestParam - || annotation instanceof SpringQueryMap || annotation instanceof QueryMap)) { - return true; - } - } - return false; - } - - private void parseProduces(MethodMetadata md, Method method, RequestMapping annotation) { - String[] serverProduces = annotation.produces(); - String clientAccepts = serverProduces.length == 0 ? null : emptyToNull(serverProduces[0]); - if (clientAccepts != null) { - md.template().header(ACCEPT, clientAccepts); - } - } - - private void parseConsumes(MethodMetadata md, Method method, RequestMapping annotation) { - String[] serverConsumes = annotation.consumes(); - String clientProduces = serverConsumes.length == 0 ? null : emptyToNull(serverConsumes[0]); - if (clientProduces != null) { - md.template().header(CONTENT_TYPE, clientProduces); - } - } - - private void parseHeaders(MethodMetadata md, Method method, RequestMapping annotation) { - // TODO: only supports one header value per key - if (annotation.headers() != null && annotation.headers().length > 0) { - for (String header : annotation.headers()) { - int index = header.indexOf('='); - if (!header.contains("!=") && index >= 0) { - md.template().header(resolve(header.substring(0, index)), - resolve(header.substring(index + 1).trim())); - } - } - } - } - - private Map, AnnotatedParameterProcessor> toAnnotatedArgumentProcessorMap( - List processors) { - Map, AnnotatedParameterProcessor> result = new HashMap<>(); - for (AnnotatedParameterProcessor processor : processors) { - result.put(processor.getAnnotationType(), processor); - } - return result; - } - - private List getDefaultAnnotatedArgumentsProcessors() { - - List annotatedArgumentResolvers = new ArrayList<>(); - - annotatedArgumentResolvers.add(new MatrixVariableParameterProcessor()); - annotatedArgumentResolvers.add(new PathVariableParameterProcessor()); - annotatedArgumentResolvers.add(new RequestParamParameterProcessor()); - annotatedArgumentResolvers.add(new RequestHeaderParameterProcessor()); - annotatedArgumentResolvers.add(new QueryMapParameterProcessor()); - annotatedArgumentResolvers.add(new RequestPartParameterProcessor()); - annotatedArgumentResolvers.add(new CookieValueParameterProcessor()); - - return annotatedArgumentResolvers; - } - - private Annotation synthesizeWithMethodParameterNameAsFallbackValue(Annotation parameterAnnotation, Method method, - int parameterIndex) { - Map annotationAttributes = AnnotationUtils.getAnnotationAttributes(parameterAnnotation); - Object defaultValue = AnnotationUtils.getDefaultValue(parameterAnnotation); - if (defaultValue instanceof String && defaultValue.equals(annotationAttributes.get(AnnotationUtils.VALUE))) { - Type[] parameterTypes = method.getGenericParameterTypes(); - String[] parameterNames = PARAMETER_NAME_DISCOVERER.getParameterNames(method); - if (shouldAddParameterName(parameterIndex, parameterTypes, parameterNames)) { - annotationAttributes.put(AnnotationUtils.VALUE, parameterNames[parameterIndex]); - } - } - return AnnotationUtils.synthesizeAnnotation(annotationAttributes, parameterAnnotation.annotationType(), null); - } - - private boolean shouldAddParameterName(int parameterIndex, Type[] parameterTypes, String[] parameterNames) { - // has a parameter name - return parameterNames != null && parameterNames.length > parameterIndex - // has a type - && parameterTypes != null && parameterTypes.length > parameterIndex; - } - - private boolean isMultipartFormData(MethodMetadata data) { - Collection contentTypes = data.template().headers().get(HttpEncoding.CONTENT_TYPE); - - if (contentTypes != null && !contentTypes.isEmpty()) { - String type = contentTypes.iterator().next(); - try { - return Objects.equals(MediaType.valueOf(type), MediaType.MULTIPART_FORM_DATA); - } - catch (InvalidMediaTypeException ignored) { - return false; - } - } - - return false; - } - - private static class ConvertingExpanderFactory { - - private final ConversionService conversionService; - - ConvertingExpanderFactory(ConversionService conversionService) { - this.conversionService = conversionService; - } - - Param.Expander getExpander(TypeDescriptor typeDescriptor) { - return value -> { - Object converted = conversionService.convert(value, typeDescriptor, STRING_TYPE_DESCRIPTOR); - return (String) converted; - }; - } - - } - - private class SimpleAnnotatedParameterContext implements AnnotatedParameterProcessor.AnnotatedParameterContext { - - private final MethodMetadata methodMetadata; - - private final int parameterIndex; - - SimpleAnnotatedParameterContext(MethodMetadata methodMetadata, int parameterIndex) { - this.methodMetadata = methodMetadata; - this.parameterIndex = parameterIndex; - } - - @Override - public MethodMetadata getMethodMetadata() { - return methodMetadata; - } - - @Override - public int getParameterIndex() { - return parameterIndex; - } - - @Override - public void setParameterName(String name) { - nameParam(methodMetadata, name, parameterIndex); - } - - @Override - public Collection setTemplateParameter(String name, Collection rest) { - return addTemplateParameter(rest, name); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-cloud-openfeign-core/src/main/resources/META-INF/additional-spring-configuration-metadata.json deleted file mode 100644 index 4da8f3a61..000000000 --- a/spring-cloud-openfeign-core/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "groups": [ - ], - "properties": [ - { - "name": "spring.cloud.openfeign.autoconfiguration.jackson.enabled", - "type": "java.lang.Boolean", - "description": "If true, PageJacksonModule and SortJacksonModule bean will be provided for Jackson page decoding.", - "defaultValue": "true" - }, - { - "name": "spring.cloud.openfeign.circuitbreaker.enabled", - "type": "java.lang.Boolean", - "description": "If true, an OpenFeign client will be wrapped with a Spring Cloud CircuitBreaker circuit breaker.", - "defaultValue": "false" - }, - { - "name": "spring.cloud.openfeign.circuitbreaker.group.enabled", - "type": "java.lang.Boolean", - "description": "If true, an OpenFeign client will be wrapped with a Spring Cloud CircuitBreaker circuit breaker with with group.", - "defaultValue": "false" - }, - { - "name": "spring.cloud.openfeign.circuitbreaker.alphanumeric-ids.enabled", - "type": "java.lang.Boolean", - "description": "If true, Circuit Breaker ids will only contain alphanumeric characters to allow for configuration via configuration properties.", - "defaultValue": "false" - }, - { - "name": "spring.cloud.openfeign.httpclient.enabled", - "type": "java.lang.Boolean", - "description": "Enables the use of the Apache HTTP Client by Feign.", - "defaultValue": "true" - }, - { - "name": "spring.cloud.openfeign.httpclient.hc5.enabled", - "type": "java.lang.Boolean", - "description": "Enables the use of the Apache HTTP Client 5 by Feign.", - "defaultValue": "false" - }, - { - "name": "spring.cloud.openfeign.okhttp.enabled", - "type": "java.lang.Boolean", - "description": "Enables the use of the OK HTTP Client by Feign.", - "defaultValue": "false" - }, - { - "name": "spring.cloud.openfeign.http2client.enabled", - "type": "java.lang.Boolean", - "description": "Enables the use of the Java11 HTTP 2 Client by Feign.", - "defaultValue": "false" - }, - { - "name": "spring.cloud.openfeign.compression.response.enabled", - "type": "java.lang.Boolean", - "description": "Enables the response from Feign to be compressed.", - "defaultValue": "false" - }, - { - "name": "spring.cloud.openfeign.compression.request.enabled", - "type": "java.lang.Boolean", - "description": "Enables the request sent by Feign to be compressed.", - "defaultValue": "false" - }, - { - "name": "spring.cloud.openfeign.micrometer.enabled", - "type": "java.lang.Boolean", - "description": "Enables Micrometer capabilities for Feign.", - "defaultValue": "true" - }, - { - "name": "spring.cloud.openfeign.client.refresh-enabled", - "type": "java.lang.Boolean", - "description": "Enables options value refresh capability for Feign.", - "defaultValue": "false" - }, - { - "name": "spring.cloud.openfeign.oauth2.enabled", - "type": "java.lang.Boolean", - "description": "Enables feign interceptor for managing oauth2 access token.", - "defaultValue": "false" - }, - { - "name": "spring.cloud.openfeign.oauth2.clientRegistrationId", - "type": "java.lang.String", - "description": "Provides a clientId to be used with OAuth2.", - "defaultValue": "" - }, - { - "name": "spring.cloud.openfeign.lazy-attributes-resolution", - "type": "java.lang.Boolean", - "description": "Switches @FeignClient attributes resolution mode to lazy.", - "defaultValue": "false" - } - ] -} diff --git a/spring-cloud-openfeign-core/src/main/resources/META-INF/spring/aot.factories b/spring-cloud-openfeign-core/src/main/resources/META-INF/spring/aot.factories deleted file mode 100644 index 9662b382f..000000000 --- a/spring-cloud-openfeign-core/src/main/resources/META-INF/spring/aot.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.aot.hint.RuntimeHintsRegistrar=\ -org.springframework.cloud.openfeign.FeignHints diff --git a/spring-cloud-openfeign-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-cloud-openfeign-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 497eb2f6f..000000000 --- a/spring-cloud-openfeign-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,5 +0,0 @@ -org.springframework.cloud.openfeign.hateoas.FeignHalAutoConfiguration -org.springframework.cloud.openfeign.FeignAutoConfiguration -org.springframework.cloud.openfeign.encoding.FeignAcceptGzipEncodingAutoConfiguration -org.springframework.cloud.openfeign.encoding.FeignContentGzipEncodingAutoConfiguration -org.springframework.cloud.openfeign.loadbalancer.FeignLoadBalancerAutoConfiguration diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/EagerInitFeignClientUsingConfigurerTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/EagerInitFeignClientUsingConfigurerTests.java deleted file mode 100644 index 845381088..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/EagerInitFeignClientUsingConfigurerTests.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.reflect.Field; -import java.util.List; - -import feign.Capability; -import feign.Feign; -import feign.Logger; -import feign.RequestInterceptor; -import feign.micrometer.MicrometerObservationCapability; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.openfeign.clientconfig.FeignClientConfigurer; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.util.ReflectionUtils; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author matt king - * @author Jonatan Ivanov - * @author Olga Maciaszek-Sharma - */ -@DirtiesContext -@SpringBootTest(classes = EagerInitFeignClientUsingConfigurerTests.Application.class, value = { - "spring.cloud.openfeign.client.config.default.loggerLevel=full", - "spring.cloud.openfeign.client.config.default.requestInterceptors[0]=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.FooRequestInterceptor", - "spring.cloud.openfeign.client.config.default.requestInterceptors[1]=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.BarRequestInterceptor" }) -class EagerInitFeignClientUsingConfigurerTests { - - @Autowired - private ApplicationContext applicationContext; - - @Autowired - private FeignClientFactory context; - - private static final String BEAN_NAME_PREFIX = "&org.springframework.cloud.openfeign.EagerInitFeignClientUsingConfigurerTests$"; - - @Test - public void testFeignClient() { - FeignClientFactoryBean factoryBean = (FeignClientFactoryBean) applicationContext - .getBean(BEAN_NAME_PREFIX + "TestFeignClient"); - Feign.Builder builder = factoryBean.feign(context); - - List interceptors = (List) getBuilderValue(builder, "requestInterceptors"); - assertThat(interceptors.size()).as("interceptors not set").isEqualTo(3); - assertThat(getBuilderValue(builder, "logLevel")).as("log level not set").isEqualTo(Logger.Level.FULL); - - List capabilities = (List) getBuilderValue(builder, "capabilities"); - assertThat(capabilities).hasSize(2).hasAtLeastOneElementOfType(NoOpCapability.class) - .hasAtLeastOneElementOfType(MicrometerObservationCapability.class); - } - - private Object getBuilderValue(Feign.Builder builder, String member) { - Field builderField = ReflectionUtils.findField(Feign.Builder.class, member); - ReflectionUtils.makeAccessible(builderField); - - return ReflectionUtils.getField(builderField, builder); - } - - @Test - public void testNoInheritFeignClient() { - FeignClientFactoryBean factoryBean = (FeignClientFactoryBean) applicationContext - .getBean(BEAN_NAME_PREFIX + "NoInheritFeignClient"); - Feign.Builder builder = factoryBean.feign(context); - - List interceptors = (List) getBuilderValue(builder, "requestInterceptors"); - assertThat(interceptors).as("interceptors not set").isEmpty(); - assertThat(factoryBean.isInheritParentContext()).as("is inheriting from parent configuration").isFalse(); - - List capabilities = (List) getBuilderValue(builder, "capabilities"); - assertThat(capabilities).hasSize(2).hasAtLeastOneElementOfType(NoOpCapability.class) - .hasAtLeastOneElementOfType(MicrometerObservationCapability.class); - } - - @Test - public void testNoInheritFeignClient_ignoreProperties() { - FeignClientFactoryBean factoryBean = (FeignClientFactoryBean) applicationContext - .getBean(BEAN_NAME_PREFIX + "NoInheritFeignClient"); - Feign.Builder builder = factoryBean.feign(context); - - assertThat(getBuilderValue(builder, "logLevel")).as("log level not set").isEqualTo(Logger.Level.HEADERS); - - List capabilities = (List) getBuilderValue(builder, "capabilities"); - assertThat(capabilities).hasSize(2).hasAtLeastOneElementOfType(NoOpCapability.class) - .hasAtLeastOneElementOfType(MicrometerObservationCapability.class); - } - - @EnableAutoConfiguration - @Configuration(proxyBeanMethods = false) - @EnableFeignClients(clients = { TestFeignClient.class, NoInheritFeignClient.class }) - protected static class Application { - - @Bean - public RequestInterceptor requestInterceptor() { - return requestTemplate -> { - }; - } - - @Bean - public NoOpCapability noOpCapability() { - return new NoOpCapability(); - } - - } - - public static class NoInheritConfiguration { - - @Bean - public Logger.Level logLevel() { - return Logger.Level.HEADERS; - } - - @Bean - public NoOpCapability noOpCapability() { - return new NoOpCapability(); - } - - @Bean - public FeignClientConfigurer feignClientConfigurer() { - return new FeignClientConfigurer() { - - @Override - public boolean inheritParentConfiguration() { - return false; - } - }; - - } - - } - - @FeignClient("testFeignClient") - interface TestFeignClient { - - } - - @FeignClient(name = "noInheritFeignClient", configuration = NoInheritConfiguration.class) - interface NoInheritFeignClient { - - } - - private static class NoOpCapability implements Capability { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/EnableFeignClientsSpringDataTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/EnableFeignClientsSpringDataTests.java deleted file mode 100644 index 2cc69bcac..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/EnableFeignClientsSpringDataTests.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import feign.codec.Encoder; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.openfeign.support.PageableSpringEncoder; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.annotation.DirtiesContext; - -/** - * @author Spencer Gibb - */ -@SpringBootTest(classes = EnableFeignClientsSpringDataTests.PlainConfiguration.class) -@DirtiesContext -class EnableFeignClientsSpringDataTests { - - @Autowired - private FeignClientFactory feignClientFactory; - - @Test - void encoderDefaultCorrect() { - PageableSpringEncoder.class.cast(this.feignClientFactory.getInstance("foo", Encoder.class)); - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - protected static class PlainConfiguration { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/EnableFeignClientsTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/EnableFeignClientsTests.java deleted file mode 100644 index 77f7fa50b..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/EnableFeignClientsTests.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import feign.Contract; -import feign.Feign; -import feign.Logger; -import feign.codec.Decoder; -import feign.codec.Encoder; -import feign.optionals.OptionalDecoder; -import feign.slf4j.Slf4jLogger; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cloud.openfeign.support.SpringEncoder; -import org.springframework.cloud.openfeign.support.SpringMvcContract; -import org.springframework.cloud.test.ClassPathExclusions; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; - -/** - * @author Spencer Gibb - */ -@ClassPathExclusions({ "spring-data-commons-*.jar" }) -class EnableFeignClientsTests { - - private ConfigurableApplicationContext context; - - @BeforeEach - void setUp() { - context = new SpringApplicationBuilder().web(WebApplicationType.NONE) - .properties("debug=true", "spring.cloud.openfeign.httpclient.hc5.enabled=false") - .sources(EnableFeignClientsTests.PlainConfiguration.class).run(); - } - - @AfterEach - void tearDown() { - if (context != null) { - context.close(); - } - } - - @Test - void decoderDefaultCorrect() { - OptionalDecoder.class.cast(this.context.getBeansOfType(Decoder.class).get(0)); - } - - @Test - void encoderDefaultCorrect() { - SpringEncoder.class.cast(this.context.getBeansOfType(Encoder.class).get(0)); - } - - @Test - void loggerDefaultCorrect() { - Slf4jLogger.class.cast(this.context.getBeansOfType(Logger.class).get(0)); - } - - @Test - void contractDefaultCorrect() { - SpringMvcContract.class.cast(this.context.getBeansOfType(Contract.class).get(0)); - } - - @Test - void builderDefaultCorrect() { - Feign.Builder.class.cast(this.context.getBeansOfType(Feign.Builder.class).get(0)); - } - - @Configuration(proxyBeanMethods = false) - @Import({ FeignAutoConfiguration.class }) - protected static class PlainConfiguration { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignAutoConfigurationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignAutoConfigurationTests.java deleted file mode 100644 index d0e0e771d..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignAutoConfigurationTests.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.reflect.Method; - -import feign.Target; -import org.assertj.core.api.Condition; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.context.assertj.AssertableApplicationContext; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; -import org.springframework.cloud.openfeign.FeignAutoConfiguration.CircuitBreakerPresentFeignTargeterConfiguration.AlphanumericCircuitBreakerNameResolver; -import org.springframework.cloud.openfeign.security.OAuth2AccessTokenInterceptor; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService; -import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -/** - * @author Tim Peeters - * @author Olga Maciaszek-Sharma - * @author Andrii Bohutskyi - * @author Kwangyong Kim - * @author Wojciech Mąka - * @author Dangzhicairang(小水牛) - */ -class FeignAutoConfigurationTests { - - private final ApplicationContextRunner runner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(FeignAutoConfiguration.class)) - .withPropertyValues("spring.cloud.openfeign.httpclient.hc5.enabled=false"); - - @Test - void shouldInstantiateDefaultTargeterWhenFeignCircuitBreakerIsDisabled() { - runner.withPropertyValues("spring.cloud.openfeign.circuitbreaker.enabled=false") - .run(ctx -> assertOnlyOneTargeterPresent(ctx, DefaultTargeter.class)); - } - - @Test - void shouldInstantiateFeignCircuitBreakerTargeterWhenEnabled() { - runner.withBean(CircuitBreakerFactory.class, () -> mock(CircuitBreakerFactory.class)) - .withPropertyValues("spring.cloud.openfeign.circuitbreaker.enabled=true").run(ctx -> { - assertOnlyOneTargeterPresent(ctx, FeignCircuitBreakerTargeter.class); - assertThatFeignCircuitBreakerTargeterHasGroupEnabledPropertyWithValue(ctx, false); - assertThatFeignCircuitBreakerTargeterHasSameCircuitBreakerNameResolver(ctx, - AlphanumericCircuitBreakerNameResolver.class); - }); - } - - @Test - void shouldInstantiateFeignCircuitBreakerTargeterWithEnabledGroup() { - runner.withBean(CircuitBreakerFactory.class, () -> mock(CircuitBreakerFactory.class)) - .withPropertyValues("spring.cloud.openfeign.circuitbreaker.enabled=true") - .withPropertyValues("spring.cloud.openfeign.circuitbreaker.group.enabled=true").run(ctx -> { - assertOnlyOneTargeterPresent(ctx, FeignCircuitBreakerTargeter.class); - assertThatFeignCircuitBreakerTargeterHasGroupEnabledPropertyWithValue(ctx, true); - }); - } - - @Test - void shouldInstantiateFeignCircuitBreakerTargeterWhenEnabledWithCustomCircuitBreakerNameResolver() { - runner.withBean(CircuitBreakerFactory.class, () -> mock(CircuitBreakerFactory.class)) - .withBean(CircuitBreakerNameResolver.class, CustomCircuitBreakerNameResolver::new) - .withPropertyValues("spring.cloud.openfeign.circuitbreaker.enabled=true").run(ctx -> { - assertOnlyOneTargeterPresent(ctx, FeignCircuitBreakerTargeter.class); - assertThatFeignCircuitBreakerTargeterHasSameCircuitBreakerNameResolver(ctx, - CustomCircuitBreakerNameResolver.class); - }); - } - - @Test - void shouldInstantiateFeignOAuth2FeignRequestInterceptorWithoutInterceptors() { - runner.withPropertyValues("spring.cloud.openfeign.oauth2.enabled=true", - "spring.cloud.openfeign.oauth2.clientRegistrationId=feign-client") - .withBean(OAuth2AuthorizedClientService.class, () -> mock(OAuth2AuthorizedClientService.class)) - .withBean(ClientRegistrationRepository.class, () -> mock(ClientRegistrationRepository.class)) - .run(ctx -> { - assertOauth2AccessTokenInterceptorExists(ctx); - assertThatOauth2AccessTokenInterceptorHasSpecifiedIdsPropertyWithValue(ctx, "feign-client"); - }); - } - - private void assertOauth2AccessTokenInterceptorExists(ConfigurableApplicationContext ctx) { - AssertableApplicationContext context = AssertableApplicationContext.get(() -> ctx); - assertThat(context).hasSingleBean(OAuth2AccessTokenInterceptor.class); - } - - private void assertThatOauth2AccessTokenInterceptorHasSpecifiedIdsPropertyWithValue( - ConfigurableApplicationContext ctx, String expectedValue) { - final OAuth2AccessTokenInterceptor bean = ctx.getBean(OAuth2AccessTokenInterceptor.class); - assertThat(bean).hasFieldOrPropertyWithValue("clientRegistrationId", expectedValue); - } - - private void assertOnlyOneTargeterPresent(ConfigurableApplicationContext ctx, Class beanClass) { - assertThat(ctx.getBeansOfType(Targeter.class)).hasSize(1).hasValueSatisfying(new Condition<>( - beanClass::isInstance, String.format("Targeter should be an instance of %s", beanClass))); - - } - - private void assertThatFeignCircuitBreakerTargeterHasGroupEnabledPropertyWithValue( - ConfigurableApplicationContext ctx, boolean expectedValue) { - final FeignCircuitBreakerTargeter bean = ctx.getBean(FeignCircuitBreakerTargeter.class); - assertThat(bean).hasFieldOrPropertyWithValue("circuitBreakerGroupEnabled", expectedValue); - } - - private void assertThatFeignCircuitBreakerTargeterHasSameCircuitBreakerNameResolver( - ConfigurableApplicationContext ctx, Class beanClass) { - final CircuitBreakerNameResolver bean = ctx.getBean(CircuitBreakerNameResolver.class); - assertThat(bean).isExactlyInstanceOf(beanClass); - } - - static class CustomCircuitBreakerNameResolver implements CircuitBreakerNameResolver { - - @Override - public String resolveCircuitBreakerName(String feignClientName, Target target, Method method) { - return feignClientName + "_" + method.getName(); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignBuilderCustomizerTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignBuilderCustomizerTests.java deleted file mode 100644 index 4b728d58c..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignBuilderCustomizerTests.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.reflect.Field; -import java.util.stream.Stream; - -import feign.Client; -import feign.Feign; -import feign.Logger; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.ArgumentCaptor; - -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Primary; -import org.springframework.core.annotation.Order; -import org.springframework.util.ReflectionUtils; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doCallRealMethod; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; - -/** - * @author Matt King - * @author Sam Kruglov - * @author Felix Dittrich - * @author Olga Maciaszek-Sharma - */ -class FeignBuilderCustomizerTests { - - private static final Targeter targeterSpy = spy(DefaultTargeter.class); - - private static final Client defaultClient = mock(Client.class); - - @Test - void testBuilderCustomizer() { - ArgumentCaptor feignBuilderCaptor = ArgumentCaptor.forClass(Feign.Builder.class); - doCallRealMethod().when(targeterSpy).target(any(), feignBuilderCaptor.capture(), any(), any()); - - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( - FeignBuilderCustomizerTests.SampleConfiguration2.class); - - FeignClientFactoryBean clientFactoryBean = context.getBean(FeignClientFactoryBean.class); - clientFactoryBean.getTarget(); - - Assertions.assertNotNull(feignBuilderCaptor.getValue()); - Feign.Builder builder = feignBuilderCaptor.getValue(); - assertFeignBuilderField(builder, "logLevel", Logger.Level.HEADERS); - assertFeignBuilderField(builder, "dismiss404", true); - - context.close(); - } - - private void assertFeignBuilderField(Feign.Builder builder, String fieldName, Object expectedValue) { - Field builderField = ReflectionUtils.findField(Feign.Builder.class, fieldName); - ReflectionUtils.makeAccessible(builderField); - - Object value = ReflectionUtils.getField(builderField, builder); - assertThat(value).as("Expected value for the field '" + fieldName + "':").isEqualTo(expectedValue); - } - - @Test - void testBuildCustomizerOrdered() { - ArgumentCaptor feignBuilderCaptor = ArgumentCaptor.forClass(Feign.Builder.class); - doCallRealMethod().when(targeterSpy).target(any(), feignBuilderCaptor.capture(), any(), any()); - - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( - FeignBuilderCustomizerTests.SampleConfiguration3.class); - - FeignClientFactoryBean clientFactoryBean = context.getBean(FeignClientFactoryBean.class); - clientFactoryBean.getTarget(); - - Assertions.assertNotNull(feignBuilderCaptor.getValue()); - Feign.Builder builder = feignBuilderCaptor.getValue(); - assertFeignBuilderField(builder, "logLevel", Logger.Level.FULL); - assertFeignBuilderField(builder, "dismiss404", true); - - context.close(); - } - - @Test - void testBuildCustomizerOrderedWithAdditional() { - ArgumentCaptor feignBuilderCaptor = ArgumentCaptor.forClass(Feign.Builder.class); - doCallRealMethod().when(targeterSpy).target(any(), feignBuilderCaptor.capture(), any(), any()); - - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( - FeignBuilderCustomizerTests.SampleConfiguration3.class); - - FeignClientFactoryBean clientFactoryBean = context.getBean(FeignClientFactoryBean.class); - clientFactoryBean.addCustomizer(builder -> builder.logLevel(Logger.Level.BASIC)); - clientFactoryBean.addCustomizer(Feign.Builder::doNotCloseAfterDecode); - clientFactoryBean.getTarget(); - - Assertions.assertNotNull(feignBuilderCaptor.getValue()); - Feign.Builder builder = feignBuilderCaptor.getValue(); - assertFeignBuilderField(builder, "logLevel", Logger.Level.BASIC); - assertFeignBuilderField(builder, "dismiss404", true); - assertFeignBuilderField(builder, "closeAfterDecode", false); - - context.close(); - } - - @ParameterizedTest(name = "should use custom HttpClient with config: {0}") - @MethodSource("testConfiguration") - void testBuildCustomizerWithCustomHttpClient(Class configClass) { - ArgumentCaptor feignBuilderCaptor = ArgumentCaptor.forClass(Feign.Builder.class); - doCallRealMethod().when(targeterSpy).target(any(), feignBuilderCaptor.capture(), any(), any()); - Client customClientMock = mock(Client.class); - - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(configClass); - FeignClientFactoryBean clientFactoryBean = context.getBean(FeignClientFactoryBean.class); - clientFactoryBean.addCustomizer(builder -> builder.client(customClientMock)); - clientFactoryBean.getTarget(); - - Assertions.assertNotNull(feignBuilderCaptor.getValue()); - Feign.Builder builder = feignBuilderCaptor.getValue(); - assertFeignBuilderField(builder, "client", customClientMock); - - context.close(); - } - - private static FeignClientFactoryBean defaultFeignClientFactoryBean(String url) { - FeignClientFactoryBean feignClientFactoryBean = new FeignClientFactoryBean(); - feignClientFactoryBean.setContextId("test"); - feignClientFactoryBean.setName("test"); - feignClientFactoryBean.setType(FeignClientFactoryTests.TestType.class); - feignClientFactoryBean.setPath(""); - if (url != null) { - feignClientFactoryBean.setUrl(url); - } - return feignClientFactoryBean; - } - - private static Stream testConfiguration() { - return Stream.of(SampleConfiguration3.class, LoadBalancedSampleConfiguration.class); - } - - @Configuration(proxyBeanMethods = false) - @Import(FeignClientsConfiguration.class) - protected static class SampleConfiguration2 { - - @Bean - FeignClientFactory feignContext() { - return new FeignClientFactory(); - } - - @Bean - FeignClientProperties feignClientProperties() { - return new FeignClientProperties(); - } - - @Bean - FeignBuilderCustomizer feignBuilderCustomizer() { - return builder -> builder.logLevel(Logger.Level.HEADERS); - } - - @Bean - FeignBuilderCustomizer feignBuilderCustomizer2() { - return Feign.Builder::dismiss404; - } - - @Bean - FeignClientFactoryBean feignClientFactoryBean() { - return defaultFeignClientFactoryBean("http://some.absolute.url"); - } - - @Bean - Targeter targeter() { - return targeterSpy; - } - - } - - @Configuration(proxyBeanMethods = false) - @Import(FeignClientsConfiguration.class) - protected static class SampleConfiguration3 { - - @Bean - FeignClientFactory feignContext() { - return new FeignClientFactory(); - } - - @Bean - FeignClientProperties feignClientProperties() { - return new FeignClientProperties(); - } - - @Bean - @Order(1) - FeignBuilderCustomizer feignBuilderCustomizer() { - return builder -> builder.logLevel(Logger.Level.HEADERS); - } - - @Bean - @Order(2) - FeignBuilderCustomizer feignBuilderCustomizer1() { - return builder -> builder.logLevel(Logger.Level.FULL); - } - - @Bean - FeignBuilderCustomizer feignBuilderCustomizer2() { - return Feign.Builder::dismiss404; - } - - @Bean - FeignClientFactoryBean feignClientFactoryBean() { - return defaultFeignClientFactoryBean("http://some.absolute.url"); - } - - @Bean - Targeter targeter() { - return targeterSpy; - } - - @Bean - Client client() { - return defaultClient; - } - - } - - @Configuration(proxyBeanMethods = false) - @Import(SampleConfiguration3.class) - protected static class LoadBalancedSampleConfiguration { - - @Primary - @Bean - FeignClientFactoryBean feignClientFactoryBean() { - return defaultFeignClientFactoryBean(null); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientBuilderTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientBuilderTests.java deleted file mode 100644 index 9a212a5a5..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientBuilderTests.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.nio.file.ClosedFileSystemException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import feign.Feign; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; - -import org.springframework.cloud.openfeign.testclients.TestClient; -import org.springframework.context.ApplicationContext; -import org.springframework.util.ReflectionUtils; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * @author Sven Döring - * @author Sam Kruglov - * @author Szymon Linowski - */ -class FeignClientBuilderTests { - - private FeignClientBuilder feignClientBuilder; - - private ApplicationContext applicationContext; - - private static Object getDefaultValueFromFeignClientAnnotation(final String methodName) { - final Method method = ReflectionUtils.findMethod(FeignClient.class, methodName); - return method.getDefaultValue(); - } - - private static void assertFactoryBeanField(final FeignClientBuilder.Builder builder, final String fieldName, - final Object expectedValue) { - final Object value = getFactoryBeanField(builder, fieldName); - assertThat(value).as("Expected value for the field '" + fieldName + "':").isEqualTo(expectedValue); - } - - @SuppressWarnings("unchecked") - private static T getFactoryBeanField(final FeignClientBuilder.Builder builder, final String fieldName) { - final Field factoryBeanField = ReflectionUtils.findField(FeignClientBuilder.Builder.class, - "feignClientFactoryBean"); - ReflectionUtils.makeAccessible(factoryBeanField); - final FeignClientFactoryBean factoryBean = (FeignClientFactoryBean) ReflectionUtils.getField(factoryBeanField, - builder); - - final Field field = ReflectionUtils.findField(FeignClientFactoryBean.class, fieldName); - ReflectionUtils.makeAccessible(field); - return (T) ReflectionUtils.getField(field, factoryBean); - } - - @BeforeEach - void setUp() { - this.applicationContext = Mockito.mock(ApplicationContext.class); - this.feignClientBuilder = new FeignClientBuilder(this.applicationContext); - } - - @Test - void safetyCheckForNewFieldsOnTheFeignClientAnnotation() { - final List methodNames = new ArrayList<>(); - for (final Method method : FeignClient.class.getMethods()) { - methodNames.add(method.getName()); - } - methodNames.removeAll(Arrays.asList("annotationType", "value", "serviceId", "qualifier", "qualifiers", - "configuration", "primary", "equals", "hashCode", "toString")); - Collections.sort(methodNames); - // If this safety check fails the Builder has to be updated. - // (1) Either a field was removed from the FeignClient annotation and so it has to - // be removed - // on this builder class. - // (2) Or a new field was added and the builder class has to be extended with this - // new field. - assertThat(methodNames).containsExactly("contextId", "dismiss404", "fallback", "fallbackFactory", "name", - "path", "url"); - } - - @Test - void forType_preinitializedBuilder() { - // when: - final FeignClientBuilder.Builder builder = this.feignClientBuilder.forType(TestFeignClient.class, "TestClient"); - - // then: - assertFactoryBeanField(builder, "applicationContext", this.applicationContext); - assertFactoryBeanField(builder, "type", TestFeignClient.class); - assertFactoryBeanField(builder, "name", "TestClient"); - assertFactoryBeanField(builder, "contextId", "TestClient"); - - // and: - assertFactoryBeanField(builder, "url", getDefaultValueFromFeignClientAnnotation("url")); - assertFactoryBeanField(builder, "path", getDefaultValueFromFeignClientAnnotation("path")); - assertFactoryBeanField(builder, "dismiss404", getDefaultValueFromFeignClientAnnotation("dismiss404")); - assertFactoryBeanField(builder, "fallback", getDefaultValueFromFeignClientAnnotation("fallback")); - assertFactoryBeanField(builder, "fallbackFactory", getDefaultValueFromFeignClientAnnotation("fallbackFactory")); - } - - @Test - void forType_allFieldsSetOnBuilder() { - // when: - final FeignClientBuilder.Builder builder = this.feignClientBuilder.forType(TestFeignClient.class, "TestClient") - .dismiss404(true).url("Url/").path("/Path").contextId("TestContext"); - - // then: - assertFactoryBeanField(builder, "applicationContext", this.applicationContext); - assertFactoryBeanField(builder, "type", TestFeignClient.class); - assertFactoryBeanField(builder, "name", "TestClient"); - assertFactoryBeanField(builder, "contextId", "TestContext"); - - // and: - assertFactoryBeanField(builder, "url", "http://Url/"); - assertFactoryBeanField(builder, "path", "/Path"); - assertFactoryBeanField(builder, "dismiss404", true); - - } - - @Test - void forType_clientFactoryBeanProvided() { - // when: - final FeignClientBuilder.Builder builder = this.feignClientBuilder - .forType(TestFeignClient.class, new FeignClientFactoryBean(), "TestClient").dismiss404(true) - .path("Path/").url("Url/").contextId("TestContext").customize(Feign.Builder::doNotCloseAfterDecode); - - // then: - assertFactoryBeanField(builder, "applicationContext", this.applicationContext); - assertFactoryBeanField(builder, "type", TestFeignClient.class); - assertFactoryBeanField(builder, "name", "TestClient"); - assertFactoryBeanField(builder, "contextId", "TestContext"); - - // and: - assertFactoryBeanField(builder, "url", "http://Url/"); - assertFactoryBeanField(builder, "path", "/Path"); - assertFactoryBeanField(builder, "dismiss404", true); - List additionalCustomizers = getFactoryBeanField(builder, "additionalCustomizers"); - assertThat(additionalCustomizers).hasSize(1); - } - - @Test - void forType_build() { - // given: - Mockito.when(this.applicationContext.getBean(FeignClientFactory.class)) - .thenThrow(new ClosedFileSystemException()); // throw - // an - // unusual - // exception - // in - // the - // FeignClientFactoryBean - final FeignClientBuilder.Builder builder = this.feignClientBuilder.forType(TestClient.class, "TestClient"); - // expect: 'the build will fail right after calling build() with the mocked - // unusual exception' - assertThatExceptionOfType(ClosedFileSystemException.class).isThrownBy(builder::build); - } - - private interface TestFeignClient { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientCacheTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientCacheTests.java deleted file mode 100644 index 289bbc891..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientCacheTests.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2020-2022 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; - -import java.net.UnknownHostException; - -import feign.Contract; -import feign.RequestLine; -import feign.RetryableException; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cache.CacheManager; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.cache.annotation.EnableCaching; -import org.springframework.cache.interceptor.SimpleKey; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.annotation.DirtiesContext; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * @author Sam Kruglov - * @author Dominique Villard - */ -@SpringBootTest(classes = FeignClientCacheTests.TestConfiguration.class) -@DirtiesContext -public class FeignClientCacheTests { - - private static final String CACHE_NAME = "foo-cache"; - - @Autowired - private FooClient foo; - - @Test - void cacheExists(@Autowired CacheManager cacheManager) { - assertThat(cacheManager.getCache(CACHE_NAME)).isNotNull(); - } - - @Test - void interceptedCallsReal() { - assertThatExceptionOfType(RetryableException.class).isThrownBy(foo::getWithCache) - .withRootCauseInstanceOf(UnknownHostException.class); - } - - @Test - void nonInterceptedCallsReal() { - assertThatExceptionOfType(RetryableException.class).isThrownBy(foo::getWithoutCache) - .withRootCauseInstanceOf(UnknownHostException.class); - } - - @Nested - class givenCached { - - String cachedValue = "cached"; - - @BeforeEach - void setUp(@Autowired CacheManager cacheManager) { - cacheManager.getCache(CACHE_NAME).put(SimpleKey.EMPTY, cachedValue); - } - - @Test - void interceptedReturnsCached() { - assertThat(foo.getWithCache()).isSameAs(cachedValue); - } - - @Test - void nonInterceptedCallsReal() { - assertThatExceptionOfType(RetryableException.class).isThrownBy(foo::getWithoutCache) - .withRootCauseInstanceOf(UnknownHostException.class); - } - - } - - @Configuration(proxyBeanMethods = false) - @EnableFeignClients(clients = FooClient.class) - @EnableAutoConfiguration - @EnableCaching - protected static class TestConfiguration { - - } - - @FeignClient(name = "foo", url = "http://foo", configuration = FooConfiguration.class) - interface FooClient { - - @RequestLine("GET /with-cache") - @Cacheable(cacheNames = CACHE_NAME) - String getWithCache(); - - @RequestLine("GET /without-cache") - String getWithoutCache(); - - } - - public static class FooConfiguration { - - @Bean - Contract feignContract() { - return new Contract.Default(); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientConfigurationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientConfigurationTests.java deleted file mode 100644 index 5e9875a96..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientConfigurationTests.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2021-2022 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; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import feign.Capability; -import feign.Contract; -import feign.ExceptionPropagationPolicy; -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.assertj.core.util.Lists; -import org.assertj.core.util.Maps; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsAndHashCodeConsistency; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsConsistency; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsReflexivity; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsSymmetricity; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsTransitivity; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertHashCodeConsistency; - -/** - * @author Jonatan Ivanov - * @author Hyeonmin Park - * @author Olga Maciaszek-Sharma - */ -class FeignClientConfigurationTests { - - @Test - void shouldDefaultToValuesWhenFieldsNotSet() { - FeignClientProperties.FeignClientConfiguration config = new FeignClientProperties.FeignClientConfiguration(); - - assertThat(config.getLoggerLevel()).isNull(); - assertThat(config.getConnectTimeout()).isNull(); - assertThat(config.getReadTimeout()).isNull(); - assertThat(config.getRetryer()).isNull(); - assertThat(config.getErrorDecoder()).isNull(); - assertThat(config.getRequestInterceptors()).isNull(); - assertThat(config.getResponseInterceptor()).isNull(); - assertThat(config.getDefaultRequestHeaders()).isNull(); - assertThat(config.getDefaultQueryParameters()).isNull(); - assertThat(config.getDismiss404()).isNull(); - assertThat(config.getDecoder()).isNull(); - assertThat(config.getEncoder()).isNull(); - assertThat(config.getContract()).isNull(); - assertThat(config.getExceptionPropagationPolicy()).isNull(); - assertThat(config.getCapabilities()).isNull(); - assertThat(config.getQueryMapEncoder()).isNull(); - assertThat(config.getMicrometer()).isNull(); - } - - @Test - void shouldReturnValuesWhenSet() { - FeignClientProperties.FeignClientConfiguration config = new FeignClientProperties.FeignClientConfiguration(); - config.setLoggerLevel(Logger.Level.FULL); - config.setConnectTimeout(21); - config.setReadTimeout(42); - config.setRetryer(Retryer.class); - config.setErrorDecoder(ErrorDecoder.class); - List> requestInterceptors = Lists.list(RequestInterceptor.class); - config.setRequestInterceptors(requestInterceptors); - Class responseInterceptor = ResponseInterceptor.class; - config.setResponseInterceptor(responseInterceptor); - Map> defaultRequestHeaders = Maps.newHashMap("default", Collections.emptyList()); - config.setDefaultRequestHeaders(defaultRequestHeaders); - Map> defaultQueryParameters = Maps.newHashMap("default", Collections.emptyList()); - config.setDefaultQueryParameters(defaultQueryParameters); - config.setDismiss404(true); - config.setDecoder(Decoder.class); - config.setEncoder(Encoder.class); - config.setContract(Contract.class); - config.setExceptionPropagationPolicy(ExceptionPropagationPolicy.UNWRAP); - List> capabilities = Lists.list(Capability.class); - config.setCapabilities(capabilities); - config.setQueryMapEncoder(QueryMapEncoder.class); - FeignClientProperties.MicrometerProperties micrometer = new FeignClientProperties.MicrometerProperties(); - config.setMicrometer(micrometer); - - assertThat(config.getLoggerLevel()).isSameAs(Logger.Level.FULL); - assertThat(config.getConnectTimeout()).isEqualTo(21); - assertThat(config.getReadTimeout()).isEqualTo(42); - assertThat(config.getRetryer()).isSameAs(Retryer.class); - assertThat(config.getErrorDecoder()).isSameAs(ErrorDecoder.class); - assertThat(config.getRequestInterceptors()).isSameAs(requestInterceptors); - assertThat(config.getResponseInterceptor()).isSameAs(responseInterceptor); - assertThat(config.getDefaultRequestHeaders()).isSameAs(defaultRequestHeaders); - assertThat(config.getDefaultQueryParameters()).isSameAs(defaultQueryParameters); - assertThat(config.getDismiss404()).isTrue(); - assertThat(config.getDecoder()).isSameAs(Decoder.class); - assertThat(config.getEncoder()).isSameAs(Encoder.class); - assertThat(config.getContract()).isSameAs(Contract.class); - assertThat(config.getExceptionPropagationPolicy()).isSameAs(ExceptionPropagationPolicy.UNWRAP); - assertThat(config.getCapabilities()).isSameAs(capabilities); - assertThat(config.getQueryMapEncoder()).isSameAs(QueryMapEncoder.class); - assertThat(config.getMicrometer()).isSameAs(micrometer); - } - - /** - * Sanity-checks equals and hashCode contracts but does not check every variation of - * the fields. - */ - @Test - void shouldHaveSomewhatValidEqualsAndHashCode() { - FeignClientProperties.FeignClientConfiguration configOne = new FeignClientProperties.FeignClientConfiguration(); - FeignClientProperties.FeignClientConfiguration configTwo = new FeignClientProperties.FeignClientConfiguration(); - FeignClientProperties.FeignClientConfiguration configThree = new FeignClientProperties.FeignClientConfiguration(); - FeignClientProperties.FeignClientConfiguration differentConfig = new FeignClientProperties.FeignClientConfiguration(); - differentConfig.setDismiss404(true); - - assertEqualsReflexivity(configOne); - - assertEqualsSymmetricity(configOne, configTwo); - assertEqualsSymmetricity(configOne, differentConfig); - assertEqualsSymmetricity(configOne, 42); - - assertEqualsTransitivity(configOne, configTwo, configThree); - - assertEqualsConsistency(configOne, configTwo); - assertEqualsConsistency(configOne, differentConfig); - assertEqualsConsistency(configOne, 42); - assertEqualsConsistency(configOne, null); - - assertHashCodeConsistency(configOne); - assertEqualsAndHashCodeConsistency(configOne, configTwo); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledClientLevelFeaturesTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledClientLevelFeaturesTests.java deleted file mode 100644 index 114538f12..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledClientLevelFeaturesTests.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2021-2022 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; - -import java.util.Map; - -import feign.Capability; -import feign.Contract; -import feign.RequestLine; -import feign.micrometer.MicrometerCapability; -import feign.micrometer.MicrometerObservationCapability; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Jonatan Ivanov - */ -@DirtiesContext -@ActiveProfiles("no-foo-micrometer") -@SpringBootTest(classes = FeignClientDisabledClientLevelFeaturesTests.TestConfiguration.class) -class FeignClientDisabledClientLevelFeaturesTests { - - @Autowired - private FeignClientFactory context; - - @Autowired - private FooClient foo; - - @Autowired - private BarClient bar; - - @Test - void clientsAvailable() { - assertThat(foo).isNotNull(); - assertThat(bar).isNotNull(); - } - - @Test - void capabilitiesShouldNotBeAvailableWhenDisabled() { - assertThat(context.getInstance("foo", MicrometerCapability.class)).isNull(); - assertThat(context.getInstance("foo", MicrometerObservationCapability.class)).isNull(); - assertThat(context.getInstances("foo", Capability.class)).isEmpty(); - - assertThat(context.getInstance("bar", MicrometerCapability.class)).isNull(); - assertThat(context.getInstance("bar", MicrometerObservationCapability.class)).isNotNull(); - Map barCapabilities = context.getInstances("bar", Capability.class); - assertThat(barCapabilities).hasSize(2); - assertThat(barCapabilities.get("micrometerObservationCapability")) - .isExactlyInstanceOf(MicrometerObservationCapability.class); - assertThat(barCapabilities.get("noOpCapability")).isExactlyInstanceOf(NoOpCapability.class); - } - - @FeignClient(name = "foo", url = "https://foo", configuration = FooConfiguration.class) - interface FooClient { - - @RequestLine("GET /") - String get(); - - } - - @FeignClient(name = "bar", url = "https://bar", configuration = BarConfiguration.class) - interface BarClient { - - @GetMapping("/") - String get(); - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @EnableConfigurationProperties(FeignClientProperties.class) - @EnableFeignClients(clients = { FooClient.class, BarClient.class }) - protected static class TestConfiguration { - - } - - public static class FooConfiguration { - - @Bean // if the feign configuration empty, the context is not able to start - public Contract feignContract() { - return new Contract.Default(); - } - - } - - public static class BarConfiguration { - - @Bean - public Capability noOpCapability() { - return new NoOpCapability(); - } - - } - - private static class NoOpCapability implements Capability { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledFeaturesTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledFeaturesTests.java deleted file mode 100644 index 00d256ab5..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientDisabledFeaturesTests.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2021-2022 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; - -import java.util.Map; - -import feign.Capability; -import feign.Contract; -import feign.RequestLine; -import feign.micrometer.MicrometerCapability; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Jonatan Ivanov - */ -@DirtiesContext -@ActiveProfiles("no-micrometer") -@SpringBootTest(classes = FeignClientDisabledFeaturesTests.TestConfiguration.class) -class FeignClientDisabledFeaturesTests { - - @Autowired - private FeignClientFactory context; - - @Autowired - private FooClient foo; - - @Autowired - private BarClient bar; - - @Test - void clientsAvailable() { - assertThat(foo).isNotNull(); - assertThat(bar).isNotNull(); - } - - @Test - void capabilitiesShouldNotBeAvailable() { - assertThat(context.getInstance("foo", MicrometerCapability.class)).isNull(); - assertThat(context.getInstances("foo", Capability.class)).isEmpty(); - - assertThat(context.getInstance("bar", MicrometerCapability.class)).isNull(); - Map barCapabilities = context.getInstances("bar", Capability.class); - assertThat(barCapabilities).hasSize(1); - assertThat(barCapabilities.get("noOpCapability")).isExactlyInstanceOf(NoOpCapability.class); - } - - @FeignClient(name = "foo", url = "https://foo", configuration = FooConfiguration.class) - interface FooClient { - - @RequestLine("GET /") - String get(); - - } - - @FeignClient(name = "bar", url = "https://bar", configuration = BarConfiguration.class) - interface BarClient { - - @GetMapping("/") - String get(); - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @EnableConfigurationProperties(FeignClientProperties.class) - @EnableFeignClients(clients = { FooClient.class, BarClient.class }) - protected static class TestConfiguration { - - } - - public static class FooConfiguration { - - @Bean // if the feign configuration empty, the context is not able to start - public Contract feignContract() { - return new Contract.Default(); - } - - } - - public static class BarConfiguration { - - @Bean - public Capability noOpCapability() { - return new NoOpCapability(); - } - - } - - private static class NoOpCapability implements Capability { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientErrorDecoderTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientErrorDecoderTests.java deleted file mode 100644 index 1c7282113..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientErrorDecoderTests.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2020-2022 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; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Map; - -import feign.Contract; -import feign.InvocationHandlerFactory; -import feign.RequestLine; -import feign.Response; -import feign.codec.ErrorDecoder; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledForJreRange; -import org.junit.jupiter.api.condition.JRE; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -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.util.ReflectionTestUtils; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Michael Cramer - * @author Jonatan Ivanov - */ -@SpringBootTest(classes = FeignClientErrorDecoderTests.TestConfiguration.class) -@DirtiesContext -public class FeignClientErrorDecoderTests { - - @Autowired - private FeignClientFactory context; - - @Autowired - private FooClient foo; - - @Autowired - private BarClient bar; - - @Test - public void clientsAvailable() { - assertThat(this.foo).isNotNull(); - assertThat(this.bar).isNotNull(); - } - - @Test - public void errorDecoderInConfiguration() { - assertThat(this.context.getInstance("foo", ErrorDecoder.class)).isInstanceOf(ErrorDecoder.Default.class); - assertThat(this.context.getInstance("bar", ErrorDecoder.class)).isNull(); - } - - @Test - @DisabledForJreRange(min = JRE.JAVA_16) - public void useConfiguredErrorDecoderWhenAlsoErrorDecoderFactoryIsAvailable() { - Object errorDecoder = getErrorDecoderFromClient(this.foo); - assertThat(errorDecoder).isInstanceOf(ErrorDecoder.Default.class); - } - - @Test - @DisabledForJreRange(min = JRE.JAVA_16) - public void useErrorDecoderFromErrorDecoderFactory() { - Object errorDecoder = getErrorDecoderFromClient(this.bar); - assertThat(errorDecoder).isInstanceOf(ErrorDecoderImpl.class); - } - - @SuppressWarnings({ "unchecked", "ConstantConditions" }) - private Object getErrorDecoderFromClient(final Object client) { - Object invocationHandlerLambda = ReflectionTestUtils.getField(client, "h"); - Object invocationHandler = ReflectionTestUtils.getField(invocationHandlerLambda, "arg$2"); - Map dispatch = (Map) ReflectionTestUtils - .getField(invocationHandler, "dispatch"); - Method key = new ArrayList<>(dispatch.keySet()).get(0); - return ReflectionTestUtils.getField(ReflectionTestUtils.getField(dispatch.get(key), "asyncResponseHandler"), - "errorDecoder"); - } - - @Configuration(proxyBeanMethods = false) - @EnableFeignClients(clients = { FooClient.class, BarClient.class }) - @EnableAutoConfiguration - protected static class TestConfiguration { - - } - - @FeignClient(name = "foo", url = "http://foo", configuration = FooConfiguration.class) - interface FooClient { - - @RequestLine("GET /") - String get(); - - } - - public static class FooConfiguration { - - @Bean - Contract feignContract() { - return new Contract.Default(); - } - - @Bean - FeignErrorDecoderFactory errorDecoderFactory() { - return new FeignErrorDecoderFactoryImpl(); - } - - @Bean - ErrorDecoder feignErrorDecoder() { - return new ErrorDecoder.Default(); - } - - } - - @FeignClient(name = "bar", url = "http://bar", configuration = BarConfiguration.class) - interface BarClient { - - @GetMapping("/") - String get(); - - } - - public static class BarConfiguration { - - @Bean - Contract feignContract() { - return new SpringMvcContract(); - } - - @Bean - FeignErrorDecoderFactory errorDecoderFactory() { - return new FeignErrorDecoderFactoryImpl(); - } - - } - - public static class FeignErrorDecoderFactoryImpl implements FeignErrorDecoderFactory { - - @Override - public ErrorDecoder create(final Class type) { - return new ErrorDecoderImpl(); - } - - } - - public static class ErrorDecoderImpl implements ErrorDecoder { - - @Override - public Exception decode(final String methodKey, final Response response) { - return null; - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientFactoryTest.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientFactoryTest.java deleted file mode 100644 index d4ed2f051..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientFactoryTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.Collection; - -import feign.Logger; -import feign.RequestInterceptor; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.Test; - -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; - -import static org.assertj.core.api.Assertions.assertThat; - -class FeignClientFactoryTest { - - @Test - void getInstanceWithoutAncestors_verifyNullForMissing() { - AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext(); - parent.refresh(); - - FeignClientFactory feignClientFactory = new FeignClientFactory(); - feignClientFactory.setApplicationContext(parent); - feignClientFactory.setConfigurations(Lists.newArrayList(getSpec("empty", null, EmptyConfiguration.class))); - - Logger.Level level = feignClientFactory.getInstanceWithoutAncestors("empty", Logger.Level.class); - - assertThat(level).as("Logger was not null").isNull(); - } - - private FeignClientSpecification getSpec(String name, String className, Class configClass) { - return new FeignClientSpecification(name, className, new Class[] { configClass }); - } - - @Test - void getInstancesWithoutAncestors_verifyEmptyForMissing() { - AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext(); - parent.refresh(); - - FeignClientFactory feignClientFactory = new FeignClientFactory(); - feignClientFactory.setApplicationContext(parent); - feignClientFactory.setConfigurations(Lists.newArrayList(getSpec("empty", null, EmptyConfiguration.class))); - - Collection interceptors = feignClientFactory - .getInstancesWithoutAncestors("empty", RequestInterceptor.class).values(); - - assertThat(interceptors).as("Interceptors is not empty").isEmpty(); - } - - @Test - void getInstanceWithoutAncestors() { - AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext(); - parent.refresh(); - - FeignClientFactory feignClientFactory = new FeignClientFactory(); - feignClientFactory.setApplicationContext(parent); - feignClientFactory.setConfigurations(Lists.newArrayList(getSpec("demo", null, DemoConfiguration.class))); - - Logger.Level level = feignClientFactory.getInstanceWithoutAncestors("demo", Logger.Level.class); - - assertThat(level).isEqualTo(Logger.Level.FULL); - } - - @Test - void getInstancesWithoutAncestors() { - AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext(); - parent.refresh(); - - FeignClientFactory feignClientFactory = new FeignClientFactory(); - feignClientFactory.setApplicationContext(parent); - feignClientFactory.setConfigurations(Lists.newArrayList(getSpec("demo", null, DemoConfiguration.class))); - - Collection interceptors = feignClientFactory - .getInstancesWithoutAncestors("demo", RequestInterceptor.class).values(); - - assertThat(interceptors.size()).isEqualTo(1); - } - - @Configuration(proxyBeanMethods = false) - @Import(FeignClientsConfiguration.class) - protected static class EmptyConfiguration { - - } - - @Configuration(proxyBeanMethods = false) - @Import(FeignClientsConfiguration.class) - protected static class DemoConfiguration { - - @Bean - public Logger.Level loggerLevel() { - return Logger.Level.FULL; - } - - @Bean - public RequestInterceptor requestInterceptor() { - return (requestTemplate) -> { - }; - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientFactoryTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientFactoryTests.java deleted file mode 100644 index 6f01b928b..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientFactoryTests.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Map; - -import feign.Client; -import feign.InvocationHandlerFactory; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledForJreRange; -import org.junit.jupiter.api.condition.JRE; - -import org.springframework.boot.test.context.assertj.AssertableApplicationContext; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.cloud.client.loadbalancer.LoadBalancerClientsProperties; -import org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient; -import org.springframework.cloud.loadbalancer.config.LoadBalancerAutoConfiguration; -import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.util.ReflectionTestUtils; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Spencer Gibb - */ -public class FeignClientFactoryTests { - - @Test - public void testChildContexts() { - AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext(); - parent.refresh(); - FeignClientFactory context = new FeignClientFactory(); - context.setApplicationContext(parent); - context.setConfigurations( - Arrays.asList(getSpec("foo", null, FooConfig.class), getSpec("bar", null, BarConfig.class))); - - Foo foo = context.getInstance("foo", Foo.class); - assertThat(foo).as("foo was null").isNotNull(); - - Bar bar = context.getInstance("bar", Bar.class); - assertThat(bar).as("bar was null").isNotNull(); - - Bar foobar = context.getInstance("foo", Bar.class); - assertThat(foobar).as("bar was not null").isNull(); - } - - @Test - @DisabledForJreRange(min = JRE.JAVA_16) - public void shouldRedirectToDelegateWhenUrlSet() { - new ApplicationContextRunner().withUserConfiguration(TestConfig.class).run(this::defaultClientUsed); - } - - @SuppressWarnings({ "unchecked", "ConstantConditions" }) - private void defaultClientUsed(AssertableApplicationContext context) { - Proxy target = context.getBean(FeignClientFactoryBean.class).getTarget(); - Object invocationHandler = ReflectionTestUtils.getField(target, "h"); - Map dispatch = (Map) ReflectionTestUtils - .getField(invocationHandler, "dispatch"); - Method key = new ArrayList<>(dispatch.keySet()).get(0); - Object client = ReflectionTestUtils.getField(dispatch.get(key), "client"); - assertThat(client).isInstanceOf(Client.Default.class); - } - - private FeignClientSpecification getSpec(String name, String className, Class configClass) { - return new FeignClientSpecification(name, className, new Class[] { configClass }); - } - - interface TestType { - - @GetMapping("/") - String hello(); - - } - - @Configuration - static class TestConfig { - - @Bean - BlockingLoadBalancerClient loadBalancerClient() { - return new BlockingLoadBalancerClient(new LoadBalancerClientFactory(new LoadBalancerClientsProperties())); - } - - @Bean - FeignClientFactory feignContext() { - FeignClientFactory feignClientFactory = new FeignClientFactory(); - feignClientFactory.setConfigurations(Collections.singletonList( - new FeignClientSpecification("test", null, new Class[] { LoadBalancerAutoConfiguration.class }))); - return feignClientFactory; - } - - @Bean - FeignClientProperties feignClientProperties() { - return new FeignClientProperties(); - } - - @Bean - Targeter targeter() { - return new DefaultTargeter(); - } - - @Bean - FeignClientFactoryBean feignClientFactoryBean() { - FeignClientFactoryBean feignClientFactoryBean = new FeignClientFactoryBean(); - feignClientFactoryBean.setContextId("test"); - feignClientFactoryBean.setName("test"); - feignClientFactoryBean.setType(TestType.class); - feignClientFactoryBean.setPath(""); - feignClientFactoryBean.setUrl("http://some.absolute.url"); - return feignClientFactoryBean; - } - - } - - static class FooConfig { - - @Bean - Foo foo() { - return new Foo(); - } - - } - - static class Foo { - - } - - static class BarConfig { - - @Bean - Bar bar() { - return new Bar(); - } - - } - - static class Bar { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientMicrometerEnabledConditionTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientMicrometerEnabledConditionTests.java deleted file mode 100644 index 47d30009a..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientMicrometerEnabledConditionTests.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright 2021-2022 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; - -import java.util.HashMap; - -import org.assertj.core.util.Maps; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.context.annotation.ConditionContext; -import org.springframework.core.env.Environment; -import org.springframework.core.type.AnnotatedTypeMetadata; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * @author Jonatan Ivanov - */ -@ExtendWith({ MockitoExtension.class }) -class FeignClientMicrometerEnabledConditionTests { - - @Mock - private ConditionContext context; - - @Mock - private AnnotatedTypeMetadata metadata; - - @Mock - private ConfigurableListableBeanFactory beanFactory; - - @Mock - private ObjectProvider beanProvider; - - @Mock - private Environment environment; - - private final FeignClientMicrometerEnabledCondition condition = new FeignClientMicrometerEnabledCondition(); - - @BeforeEach - void setUp() { - when(context.getBeanFactory()).thenReturn(beanFactory); - when(beanFactory.getBeanProvider(FeignClientProperties.class)).thenReturn(beanProvider); - } - - @AfterEach - void tearDown() { - verify(context).getBeanFactory(); - verify(beanFactory).getBeanProvider(FeignClientProperties.class); - verify(beanProvider).getIfAvailable(); - } - - @Test - void shouldMatchWhenFeignClientPropertiesBeanIsMissing() { - when(beanProvider.getIfAvailable()).thenReturn(null); - - assertThat(condition.matches(context, metadata)).isTrue(); - verify(environment, never()).getProperty("spring.cloud.openfeign.client.name"); - } - - @Test - void shouldMatchWhenConfigMapIsMissing() { - FeignClientProperties feignClientProperties = mock(FeignClientProperties.class); - when(beanProvider.getIfAvailable()).thenReturn(feignClientProperties); - when(feignClientProperties.getConfig()).thenReturn(null); - - assertThat(condition.matches(context, metadata)).isTrue(); - verify(environment, never()).getProperty("spring.cloud.openfeign.client.name"); - } - - @Test - void shouldMatchWhenConfigMapDoesNotContainTheConfig() { - FeignClientProperties feignClientProperties = mock(FeignClientProperties.class); - when(beanProvider.getIfAvailable()).thenReturn(feignClientProperties); - when(context.getEnvironment()).thenReturn(environment); - when(environment.getProperty("spring.cloud.openfeign.client.name")).thenReturn("foo"); - when(feignClientProperties.getConfig()).thenReturn(new HashMap<>()); - - assertThat(condition.matches(context, metadata)).isTrue(); - verify(environment).getProperty("spring.cloud.openfeign.client.name"); - } - - @Test - void shouldMatchWhenClientNameIsNull() { - FeignClientProperties feignClientProperties = mock(FeignClientProperties.class); - when(beanProvider.getIfAvailable()).thenReturn(feignClientProperties); - when(context.getEnvironment()).thenReturn(environment); - when(environment.getProperty("spring.cloud.openfeign.client.name")).thenReturn(null); - when(feignClientProperties.getConfig()).thenReturn(new HashMap<>()); - - assertThat(condition.matches(context, metadata)).isTrue(); - verify(environment).getProperty("spring.cloud.openfeign.client.name"); - } - - @Test - void shouldMatchWhenClientNameIsEmpty() { - FeignClientProperties feignClientProperties = mock(FeignClientProperties.class); - when(beanProvider.getIfAvailable()).thenReturn(feignClientProperties); - when(context.getEnvironment()).thenReturn(environment); - when(environment.getProperty("spring.cloud.openfeign.client.name")).thenReturn(""); - when(feignClientProperties.getConfig()).thenReturn(new HashMap<>()); - - assertThat(condition.matches(context, metadata)).isTrue(); - - verify(environment).getProperty("spring.cloud.openfeign.client.name"); - } - - @Test - void shouldMatchWhenConfigMapContainsNullConfig() { - FeignClientProperties feignClientProperties = mock(FeignClientProperties.class); - when(beanProvider.getIfAvailable()).thenReturn(feignClientProperties); - when(context.getEnvironment()).thenReturn(environment); - when(environment.getProperty("spring.cloud.openfeign.client.name")).thenReturn("foo"); - when(feignClientProperties.getConfig()).thenReturn(Maps.newHashMap("foo", null)); - - assertThat(condition.matches(context, metadata)).isTrue(); - verify(environment).getProperty("spring.cloud.openfeign.client.name"); - } - - @Test - void shouldMatchWhenMicrometerConfigurationIsMissing() { - FeignClientProperties feignClientProperties = mock(FeignClientProperties.class); - FeignClientProperties.FeignClientConfiguration feignClientConfig = mock( - FeignClientProperties.FeignClientConfiguration.class); - when(beanProvider.getIfAvailable()).thenReturn(feignClientProperties); - when(context.getEnvironment()).thenReturn(environment); - when(environment.getProperty("spring.cloud.openfeign.client.name")).thenReturn("foo"); - when(feignClientProperties.getConfig()).thenReturn(Maps.newHashMap("foo", feignClientConfig)); - when(feignClientConfig.getMicrometer()).thenReturn(null); - - assertThat(condition.matches(context, metadata)).isTrue(); - verify(environment).getProperty("spring.cloud.openfeign.client.name"); - } - - @Test - void shouldMatchWhenEnabledFlagIsNotSet() { - FeignClientProperties feignClientProperties = mock(FeignClientProperties.class); - FeignClientProperties.FeignClientConfiguration feignClientConfig = mock( - FeignClientProperties.FeignClientConfiguration.class); - when(beanProvider.getIfAvailable()).thenReturn(feignClientProperties); - when(context.getEnvironment()).thenReturn(environment); - when(environment.getProperty("spring.cloud.openfeign.client.name")).thenReturn("foo"); - when(feignClientProperties.getConfig()).thenReturn(Maps.newHashMap("foo", feignClientConfig)); - when(feignClientConfig.getMicrometer()).thenReturn(new FeignClientProperties.MicrometerProperties()); - - assertThat(condition.matches(context, metadata)).isTrue(); - verify(environment).getProperty("spring.cloud.openfeign.client.name"); - } - - @Test - void shouldMatchWhenEnabledFlagIsNull() { - FeignClientProperties feignClientProperties = mock(FeignClientProperties.class); - FeignClientProperties.FeignClientConfiguration feignClientConfig = mock( - FeignClientProperties.FeignClientConfiguration.class); - when(beanProvider.getIfAvailable()).thenReturn(feignClientProperties); - when(context.getEnvironment()).thenReturn(environment); - when(environment.getProperty("spring.cloud.openfeign.client.name")).thenReturn("foo"); - when(feignClientProperties.getConfig()).thenReturn(Maps.newHashMap("foo", feignClientConfig)); - FeignClientProperties.MicrometerProperties micrometer = new FeignClientProperties.MicrometerProperties(); - micrometer.setEnabled(null); - when(feignClientConfig.getMicrometer()).thenReturn(micrometer); - - assertThat(condition.matches(context, metadata)).isTrue(); - verify(environment).getProperty("spring.cloud.openfeign.client.name"); - } - - @Test - void shouldMatchWhenMicrometerConfigurationIsEnabled() { - FeignClientProperties feignClientProperties = mock(FeignClientProperties.class); - FeignClientProperties.FeignClientConfiguration feignClientConfig = mock( - FeignClientProperties.FeignClientConfiguration.class); - when(beanProvider.getIfAvailable()).thenReturn(feignClientProperties); - when(context.getEnvironment()).thenReturn(environment); - when(environment.getProperty("spring.cloud.openfeign.client.name")).thenReturn("foo"); - when(feignClientProperties.getConfig()).thenReturn(Maps.newHashMap("foo", feignClientConfig)); - FeignClientProperties.MicrometerProperties micrometer = new FeignClientProperties.MicrometerProperties(); - micrometer.setEnabled(true); - when(feignClientConfig.getMicrometer()).thenReturn(micrometer); - - assertThat(condition.matches(context, metadata)).isTrue(); - verify(environment).getProperty("spring.cloud.openfeign.client.name"); - } - - @Test - void shouldNotMatchWhenMicrometerConfigurationIsEnabled() { - FeignClientProperties feignClientProperties = mock(FeignClientProperties.class); - FeignClientProperties.FeignClientConfiguration feignClientConfig = mock( - FeignClientProperties.FeignClientConfiguration.class); - when(beanProvider.getIfAvailable()).thenReturn(feignClientProperties); - when(context.getEnvironment()).thenReturn(environment); - when(environment.getProperty("spring.cloud.openfeign.client.name")).thenReturn("foo"); - when(feignClientProperties.getConfig()).thenReturn(Maps.newHashMap("foo", feignClientConfig)); - FeignClientProperties.MicrometerProperties micrometer = new FeignClientProperties.MicrometerProperties(); - micrometer.setEnabled(false); - when(feignClientConfig.getMicrometer()).thenReturn(micrometer); - - assertThat(condition.matches(context, metadata)).isFalse(); - verify(environment).getProperty("spring.cloud.openfeign.client.name"); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientOverrideDefaultsTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientOverrideDefaultsTests.java deleted file mode 100644 index 477392fed..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientOverrideDefaultsTests.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import feign.Capability; -import feign.Contract; -import feign.ExceptionPropagationPolicy; -import feign.Logger; -import feign.QueryMapEncoder; -import feign.Request; -import feign.RequestInterceptor; -import feign.RequestLine; -import feign.Retryer; -import feign.auth.BasicAuthRequestInterceptor; -import feign.codec.Decoder; -import feign.codec.Encoder; -import feign.codec.ErrorDecoder; -import feign.micrometer.MicrometerCapability; -import feign.micrometer.MicrometerObservationCapability; -import feign.optionals.OptionalDecoder; -import feign.querymap.BeanQueryMapEncoder; -import feign.querymap.FieldQueryMapEncoder; -import feign.slf4j.Slf4jLogger; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.openfeign.support.PageableSpringEncoder; -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.web.bind.annotation.GetMapping; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatCode; - -/** - * @author Spencer Gibb - * @author Jonatan Ivanov - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(classes = FeignClientOverrideDefaultsTests.TestConfiguration.class) -@DirtiesContext -class FeignClientOverrideDefaultsTests { - - @Autowired - private FeignClientFactory context; - - @Autowired - private FooClient foo; - - @Autowired - private BarClient bar; - - @Test - void clientsAvailable() { - assertThat(foo).isNotNull(); - assertThat(bar).isNotNull(); - } - - @Test - void overrideDecoder() { - Decoder.Default.class.cast(context.getInstance("foo", Decoder.class)); - OptionalDecoder.class.cast(context.getInstance("bar", Decoder.class)); - } - - @Test - void overrideEncoder() { - Encoder.Default.class.cast(context.getInstance("foo", Encoder.class)); - PageableSpringEncoder.class.cast(context.getInstance("bar", Encoder.class)); - } - - @Test - void overrideLogger() { - Logger.JavaLogger.class.cast(context.getInstance("foo", Logger.class)); - Slf4jLogger.class.cast(context.getInstance("bar", Logger.class)); - } - - @Test - void overrideContract() { - Contract.Default.class.cast(context.getInstance("foo", Contract.class)); - SpringMvcContract.class.cast(context.getInstance("bar", Contract.class)); - } - - @Test - void overrideLoggerLevel() { - assertThat(context.getInstance("foo", Logger.Level.class)).isNull(); - assertThat(context.getInstance("bar", Logger.Level.class)).isEqualTo(Logger.Level.HEADERS); - } - - @Test - void overrideRetryer() { - assertThat(context.getInstance("foo", Retryer.class)).isEqualTo(Retryer.NEVER_RETRY); - Retryer.Default.class.cast(context.getInstance("bar", Retryer.class)); - } - - @Test - void overrideErrorDecoder() { - assertThat(context.getInstance("foo", ErrorDecoder.class)).isNull(); - ErrorDecoder.Default.class.cast(context.getInstance("bar", ErrorDecoder.class)); - } - - @Test - 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); - assertThat(options.isFollowRedirects()).isFalse(); - } - - @Test - void overrideQueryMapEncoder() { - assertThatCode(() -> { - FieldQueryMapEncoder.class.cast(context.getInstance("foo", QueryMapEncoder.class)); - BeanQueryMapEncoder.class.cast(context.getInstance("bar", QueryMapEncoder.class)); - }).doesNotThrowAnyException(); - } - - @Test - void addRequestInterceptor() { - assertThat(context.getInstances("foo", RequestInterceptor.class).size()).isEqualTo(1); - assertThat(context.getInstances("bar", RequestInterceptor.class).size()).isEqualTo(2); - } - - @Test - void exceptionPropagationPolicy() { - assertThat(context.getInstances("foo", ExceptionPropagationPolicy.class)).isEmpty(); - assertThat(context.getInstances("bar", ExceptionPropagationPolicy.class)) - .containsValues(ExceptionPropagationPolicy.UNWRAP); - } - - @Test - void shouldOverrideMicrometerCapabilities() { - // override micrometerCapability - assertThat(context.getInstance("foo", MicrometerCapability.class)) - .isExactlyInstanceOf(TestMicrometerCapability.class); - assertThat(context.getInstance("foo", MicrometerObservationCapability.class)) - .isExactlyInstanceOf(MicrometerObservationCapability.class); - Map fooCapabilities = context.getInstances("foo", Capability.class); - assertThat(fooCapabilities).hasSize(2); - assertThat(fooCapabilities.get("micrometerCapability")).isExactlyInstanceOf(TestMicrometerCapability.class); - assertThat(fooCapabilities.get("micrometerObservationCapability")) - .isExactlyInstanceOf(MicrometerObservationCapability.class); - - // override micrometerObservationCapability - assertThat(context.getInstance("bar", MicrometerObservationCapability.class)) - .isExactlyInstanceOf(TestMicrometerObservationCapability.class); - Map barCapabilities = context.getInstances("bar", Capability.class); - assertThat(barCapabilities).hasSize(1); - assertThat(barCapabilities.get("micrometerCapability")).isNull(); - assertThat(barCapabilities.get("micrometerObservationCapability")) - .isExactlyInstanceOf(TestMicrometerObservationCapability.class); - - // override both + an extra capability - assertThat(context.getInstance("baz", MicrometerCapability.class)) - .isExactlyInstanceOf(TestMicrometerCapability.class); - assertThat(context.getInstance("baz", MicrometerObservationCapability.class)) - .isExactlyInstanceOf(TestMicrometerObservationCapability.class); - Map bazCapabilities = context.getInstances("baz", Capability.class); - assertThat(bazCapabilities).hasSize(3); - assertThat(bazCapabilities.get("micrometerCapability")).isExactlyInstanceOf(TestMicrometerCapability.class); - assertThat(bazCapabilities.get("micrometerObservationCapability")) - .isExactlyInstanceOf(TestMicrometerObservationCapability.class); - assertThat(bazCapabilities.get("noOpCapability")).isExactlyInstanceOf(NoOpCapability.class); - } - - @FeignClient(name = "foo", url = "https://foo", configuration = FooConfiguration.class) - interface FooClient { - - @RequestLine("GET /") - String get(); - - } - - @FeignClient(name = "bar", url = "https://bar", configuration = BarConfiguration.class) - interface BarClient { - - @GetMapping("/") - String get(); - - } - - @FeignClient(name = "baz", url = "https://baz", configuration = BazConfiguration.class) - interface BazClient { - - @GetMapping("/baz") - String get(); - - } - - @Configuration(proxyBeanMethods = false) - @EnableFeignClients(clients = { FooClient.class, BarClient.class, BazClient.class }) - @EnableAutoConfiguration - protected static class TestConfiguration { - - @Bean - RequestInterceptor defaultRequestInterceptor() { - return template -> { - }; - } - - } - - static class FooConfiguration { - - @Bean - Decoder feignDecoder() { - return new Decoder.Default(); - } - - @Bean - Encoder feignEncoder() { - return new Encoder.Default(); - } - - @Bean - Logger feignLogger() { - return new Logger.JavaLogger(FooConfiguration.class); - } - - @Bean - Contract feignContract() { - return new Contract.Default(); - } - - @Bean - QueryMapEncoder queryMapEncoder() { - return new FieldQueryMapEncoder(); - } - - @Bean - MicrometerCapability micrometerCapability() { - return new TestMicrometerCapability(); - } - - } - - static class BarConfiguration { - - @Bean - Logger.Level feignLevel() { - return Logger.Level.HEADERS; - } - - @Bean - Retryer feignRetryer() { - return new Retryer.Default(); - } - - @Bean - ErrorDecoder feignErrorDecoder() { - return new ErrorDecoder.Default(); - } - - @Bean - Request.Options feignRequestOptions() { - return new Request.Options(1, TimeUnit.MILLISECONDS, 1, TimeUnit.MILLISECONDS, false); - } - - @Bean - RequestInterceptor feignRequestInterceptor() { - return new BasicAuthRequestInterceptor("user", "pass"); - } - - @Bean - QueryMapEncoder queryMapEncoder() { - return new BeanQueryMapEncoder(); - } - - @Bean - ExceptionPropagationPolicy exceptionPropagationPolicy() { - return ExceptionPropagationPolicy.UNWRAP; - } - - @Bean - MicrometerObservationCapability micrometerObservationCapability() { - return new TestMicrometerObservationCapability(); - } - - } - - static class BazConfiguration { - - @Bean - MicrometerObservationCapability micrometerObservationCapability() { - return new TestMicrometerObservationCapability(); - } - - @Bean - MicrometerCapability micrometerCapability() { - return new TestMicrometerCapability(); - } - - @Bean - Capability noOpCapability() { - return new NoOpCapability(); - } - - } - - private static class TestMicrometerObservationCapability extends feign.micrometer.MicrometerObservationCapability { - - TestMicrometerObservationCapability() { - super(null); - } - - } - - private static class TestMicrometerCapability extends feign.micrometer.MicrometerCapability { - - } - - private static class NoOpCapability implements Capability { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientPropertiesTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientPropertiesTests.java deleted file mode 100644 index 84c42e8c9..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientPropertiesTests.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2021-2022 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; - -import java.util.Map; - -import org.assertj.core.util.Maps; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsAndHashCodeConsistency; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsConsistency; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsReflexivity; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsSymmetricity; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsTransitivity; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertHashCodeConsistency; - -/** - * @author Jonatan Ivanov - */ -class FeignClientPropertiesTests { - - @Test - void shouldDefaultToValuesWhenFieldsNotSet() { - FeignClientProperties properties = new FeignClientProperties(); - assertThat(properties.isDefaultToProperties()).isTrue(); - assertThat(properties.getDefaultConfig()).isEqualTo("default"); - assertThat(properties.getConfig()).isEmpty(); - assertThat(properties.isDecodeSlash()).isTrue(); - } - - @Test - void shouldReturnValuesWhenSet() { - FeignClientProperties properties = new FeignClientProperties(); - properties.setDefaultToProperties(false); - properties.setDefaultConfig("custom"); - Map configMap = Maps.newHashMap("foo", null); - properties.setConfig(configMap); - properties.setDecodeSlash(false); - - assertThat(properties.isDefaultToProperties()).isFalse(); - assertThat(properties.getDefaultConfig()).isEqualTo("custom"); - assertThat(properties.getConfig()).isSameAs(configMap); - assertThat(properties.isDecodeSlash()).isFalse(); - } - - /** - * Sanity-checks equals and hashCode contracts but does not check every variation of - * the fields. - */ - @Test - void shouldHaveSomewhatValidEqualsAndHashCode() { - FeignClientProperties propsOne = new FeignClientProperties(); - FeignClientProperties propsTwo = new FeignClientProperties(); - FeignClientProperties propsThree = new FeignClientProperties(); - FeignClientProperties differentProps = new FeignClientProperties(); - differentProps.setDecodeSlash(false); - - assertEqualsReflexivity(propsOne); - - assertEqualsSymmetricity(propsOne, propsTwo); - assertEqualsSymmetricity(propsOne, differentProps); - assertEqualsSymmetricity(propsOne, 42); - - assertEqualsTransitivity(propsOne, propsTwo, propsThree); - - assertEqualsConsistency(propsOne, propsTwo); - assertEqualsConsistency(propsOne, differentProps); - assertEqualsConsistency(propsOne, 42); - assertEqualsConsistency(propsOne, null); - - assertHashCodeConsistency(propsOne); - assertEqualsAndHashCodeConsistency(propsOne, propsTwo); - } - -} 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 deleted file mode 100644 index c26472a09..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingPropertiesTests.java +++ /dev/null @@ -1,488 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.io.IOException; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.lang.reflect.Type; -import java.net.SocketTimeoutException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import feign.Capability; -import feign.Feign; -import feign.InvocationContext; -import feign.InvocationHandlerFactory; -import feign.QueryMapEncoder; -import feign.Request; -import feign.RequestInterceptor; -import feign.RequestTemplate; -import feign.ResponseInterceptor; -import feign.RetryableException; -import feign.Retryer; -import feign.codec.EncodeException; -import feign.codec.Encoder; -import feign.codec.ErrorDecoder; -import feign.micrometer.MicrometerObservationCapability; -import jakarta.servlet.http.HttpServletRequest; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledForJreRange; -import org.junit.jupiter.api.condition.JRE; - -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.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.util.ReflectionTestUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * @author Eko Kurniawan Khannedy - * @author Olga Maciaszek-Sharma - * @author Ilia Ilinykh - * @author Jonatan Ivanov - * @author Hyeonmin Park - * @author Dominique Villard - */ -@SuppressWarnings("FieldMayBeFinal") -@SpringBootTest(classes = FeignClientUsingPropertiesTests.Application.class, webEnvironment = RANDOM_PORT) -@TestPropertySource("classpath:feign-properties.properties") -@DirtiesContext -public class FeignClientUsingPropertiesTests { - - @Autowired - FeignClientFactory context; - - @Autowired - private ApplicationContext applicationContext; - - @Value("${local.server.port}") - private int port = 0; - - private FeignClientFactoryBean fooFactoryBean; - - private FeignClientFactoryBean barFactoryBean; - - private FeignClientFactoryBean bazFactoryBean; - - private FeignClientFactoryBean unwrapFactoryBean; - - private FeignClientFactoryBean formFactoryBean; - - private FeignClientFactoryBean defaultHeadersAndQuerySingleParamsFeignClientFactoryBean; - - private FeignClientFactoryBean defaultHeadersAndQueryMultipleParamsFeignClientFactoryBean; - - public FeignClientUsingPropertiesTests() { - fooFactoryBean = new FeignClientFactoryBean(); - fooFactoryBean.setContextId("foo"); - fooFactoryBean.setType(FeignClientFactoryBean.class); - - barFactoryBean = new FeignClientFactoryBean(); - barFactoryBean.setContextId("bar"); - barFactoryBean.setType(FeignClientFactoryBean.class); - - bazFactoryBean = new FeignClientFactoryBean(); - bazFactoryBean.setContextId("baz"); - bazFactoryBean.setType(FeignClientFactoryBean.class); - - unwrapFactoryBean = new FeignClientFactoryBean(); - unwrapFactoryBean.setContextId("unwrap"); - unwrapFactoryBean.setType(FeignClientFactoryBean.class); - - formFactoryBean = new FeignClientFactoryBean(); - formFactoryBean.setContextId("form"); - formFactoryBean.setType(FeignClientFactoryBean.class); - - this.defaultHeadersAndQuerySingleParamsFeignClientFactoryBean = new FeignClientFactoryBean(); - this.defaultHeadersAndQuerySingleParamsFeignClientFactoryBean.setContextId("singleValue"); - this.defaultHeadersAndQuerySingleParamsFeignClientFactoryBean.setType(FeignClientFactoryBean.class); - - this.defaultHeadersAndQueryMultipleParamsFeignClientFactoryBean = new FeignClientFactoryBean(); - this.defaultHeadersAndQueryMultipleParamsFeignClientFactoryBean.setContextId("multipleValue"); - this.defaultHeadersAndQueryMultipleParamsFeignClientFactoryBean.setType(FeignClientFactoryBean.class); - } - - public FooClient fooClient() { - fooFactoryBean.setApplicationContext(applicationContext); - return fooFactoryBean.feign(context).target(FooClient.class, "http://localhost:" + port); - } - - public BarClient barClient() { - barFactoryBean.setApplicationContext(applicationContext); - return barFactoryBean.feign(context).target(BarClient.class, "http://localhost:" + port); - } - - public PingClient pingClient() { - bazFactoryBean.setApplicationContext(applicationContext); - return bazFactoryBean.feign(context).target(PingClient.class, "http://localhost:" + port); - } - - public UnwrapClient unwrapClient() { - unwrapFactoryBean.setApplicationContext(applicationContext); - return unwrapFactoryBean.feign(context).target(UnwrapClient.class, "http://localhost:" + port); - } - - public FormClient formClient() { - formFactoryBean.setApplicationContext(applicationContext); - return formFactoryBean.feign(context).target(FormClient.class, "http://localhost:" + port); - } - - @Test - public void testFoo() { - String response = fooClient().foo(); - assertThat(response).isEqualTo("OK"); - } - - @Test - public void testBar() { - assertThatThrownBy(() -> barClient().bar()).isInstanceOf(RetryableException.class); - } - - @Test - public void testBaz() { - String response = pingClient().ping(); - assertThat(response).isEqualTo("baz"); - } - - @Test - public void testUnwrap() throws Exception { - assertThatThrownBy(() -> unwrapClient().unwrap()).isInstanceOf(SocketTimeoutException.class); - } - - @Test - public void testForm() { - Map request = Collections.singletonMap("form", "Data"); - String response = formClient().form(request); - assertThat(response).isEqualTo("Data"); - } - - @Test - public void testSingleValue() { - List response = singleValueClient().singleValue(); - assertThat(response).isEqualTo(Arrays.asList("header", "parameter")); - } - - @Test - public void testMultipleValue() { - List response = multipleValueClient().multipleValue(); - assertThat(response).isEqualTo(Arrays.asList("header1", "header2", "parameter1", "parameter2")); - } - - public SingleValueClient singleValueClient() { - this.defaultHeadersAndQuerySingleParamsFeignClientFactoryBean.setApplicationContext(this.applicationContext); - return this.defaultHeadersAndQuerySingleParamsFeignClientFactoryBean.feign(this.context) - .target(SingleValueClient.class, "http://localhost:" + this.port); - } - - public MultipleValueClient multipleValueClient() { - this.defaultHeadersAndQueryMultipleParamsFeignClientFactoryBean.setApplicationContext(this.applicationContext); - return this.defaultHeadersAndQueryMultipleParamsFeignClientFactoryBean.feign(this.context) - .target(MultipleValueClient.class, "http://localhost:" + this.port); - } - - @Test - @DisabledForJreRange(min = JRE.JAVA_16) - public void readTimeoutShouldWorkWhenConnectTimeoutNotSet() { - FeignClientFactoryBean readTimeoutFactoryBean = new FeignClientFactoryBean(); - readTimeoutFactoryBean.setContextId("readTimeout"); - readTimeoutFactoryBean.setType(FeignClientFactoryBean.class); - readTimeoutFactoryBean.setApplicationContext(applicationContext); - - TimeoutClient client = readTimeoutFactoryBean.feign(context).target(TimeoutClient.class, - "http://localhost:" + port); - - Request.Options options = getRequestOptions((Proxy) client); - - assertThat(options.readTimeoutMillis()).isEqualTo(1000); - assertThat(options.connectTimeoutMillis()).isEqualTo(5000); - } - - @Test - @DisabledForJreRange(min = JRE.JAVA_16) - public void connectTimeoutShouldWorkWhenReadTimeoutNotSet() { - FeignClientFactoryBean readTimeoutFactoryBean = new FeignClientFactoryBean(); - readTimeoutFactoryBean.setContextId("connectTimeout"); - readTimeoutFactoryBean.setType(FeignClientFactoryBean.class); - readTimeoutFactoryBean.setApplicationContext(applicationContext); - - TimeoutClient client = readTimeoutFactoryBean.feign(context).target(TimeoutClient.class, - "http://localhost:" + port); - - Request.Options options = getRequestOptions((Proxy) client); - - assertThat(options.connectTimeoutMillis()).isEqualTo(1000); - assertThat(options.readTimeoutMillis()).isEqualTo(5000); - } - - @Test - public void clientShouldContainCapabilities() { - fooFactoryBean.setApplicationContext(applicationContext); - Feign.Builder feignBuilder = fooFactoryBean.feign(context); - FooClient fooClient = feignBuilder.target(FooClient.class, "http://localhost:" + port); - - String response = fooClient.foo(); - assertThat(response).isEqualTo("OK"); - List capabilities = (List) ReflectionTestUtils.getField(feignBuilder, "capabilities"); - assertThat(capabilities).hasSize(2).hasAtLeastOneElementOfType(NoOpCapability.class) - .hasAtLeastOneElementOfType(MicrometerObservationCapability.class); - } - - @Test - public void clientShouldContainQueryMapEncoder() { - fooFactoryBean.setApplicationContext(applicationContext); - Feign.Builder feignBuilder = fooFactoryBean.feign(context); - FooClient fooClient = feignBuilder.target(FooClient.class, "http://localhost:" + port); - - String response = fooClient.foo(); - assertThat(response).isEqualTo("OK"); - QueryMapEncoder queryMapEncoder = (QueryMapEncoder) ReflectionTestUtils.getField(feignBuilder, - "queryMapEncoder"); - assertThat(queryMapEncoder).isInstanceOf(NoOpQueryMapEncoder.class); - } - - @Test - @DisabledForJreRange(min = JRE.JAVA_16) - public void shouldSetFollowRedirects() { - FeignClientFactoryBean testFactoryBean = new FeignClientFactoryBean(); - testFactoryBean.setContextId("test"); - testFactoryBean.setType(FeignClientFactoryBean.class); - testFactoryBean.setApplicationContext(applicationContext); - - TimeoutClient client = testFactoryBean.feign(context).target(TimeoutClient.class, "http://localhost:" + port); - - Request.Options options = getRequestOptions((Proxy) client); - - assertThat(options.isFollowRedirects()).isFalse(); - } - - private Request.Options getRequestOptions(Proxy client) { - Object invocationHandlerLambda = ReflectionTestUtils.getField(client, "h"); - Object invocationHandler = ReflectionTestUtils.getField(invocationHandlerLambda, "arg$2"); - Map dispatch = (Map) ReflectionTestUtils - .getField(Objects.requireNonNull(invocationHandler), "dispatch"); - Method key = new ArrayList<>(dispatch.keySet()).get(0); - return (Request.Options) ReflectionTestUtils.getField(dispatch.get(key), "options"); - } - - protected interface FooClient { - - @GetMapping(path = "/foo") - String foo(); - - } - - protected interface BarClient { - - @GetMapping(path = "/bar") - String bar(); - - } - - protected interface PingClient { - - @GetMapping(path = "/ping") - String ping(); - - } - - protected interface UnwrapClient { - - @GetMapping(path = "/bar") // intentionally /bar - String unwrap() throws IOException; - - } - - protected interface FormClient { - - @PostMapping(value = "/form", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) - String form(Map form); - - } - - protected interface SingleValueClient { - - @GetMapping(path = "/singleValue") - List singleValue(); - - } - - protected interface MultipleValueClient { - - @GetMapping(path = "/multipleValue") - List multipleValue(); - - } - - protected interface TimeoutClient { - - @GetMapping("/timeouts") - String timeouts(); - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @Import(NoSecurityConfiguration.class) - protected static class Application { - - @GetMapping("/foo") - public String foo(HttpServletRequest request) throws IllegalAccessException { - if ("Foo".equals(request.getHeader("Foo")) && "Bar".equals(request.getHeader("Bar"))) { - return "OK"; - } - else { - throw new IllegalAccessException("It should has Foo and Bar header"); - } - } - - @GetMapping(path = "/bar") - public String bar() throws InterruptedException { - TimeUnit.SECONDS.sleep(2); - return "OK"; - } - - @GetMapping(path = "/ping") - public String ping() { - return "pong"; - } - - @PostMapping(path = "/form", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) - public String form(HttpServletRequest request) { - return request.getParameter("form"); - } - - @GetMapping(path = "/singleValue") - public List singleValue(@RequestHeader List singleValueHeaders, - @RequestParam List singleValueParameters) { - return Stream.of(singleValueHeaders, singleValueParameters).flatMap(Collection::stream) - .collect(Collectors.toList()); - } - - @GetMapping(path = "/multipleValue") - public List multipleValue(@RequestHeader List multipleValueHeaders, - @RequestParam List multipleValueParameters) { - return Stream.of(multipleValueHeaders, multipleValueParameters).flatMap(Collection::stream) - .collect(Collectors.toList()); - } - - } - - public static class FooRequestInterceptor implements RequestInterceptor { - - @Override - public void apply(RequestTemplate template) { - template.header("Foo", "Foo"); - } - - } - - public static class BarRequestInterceptor implements RequestInterceptor { - - @Override - public void apply(RequestTemplate template) { - template.header("Bar", "Bar"); - } - - } - - public static class BazResponseInterceptor implements ResponseInterceptor { - - @Override - public Object aroundDecode(InvocationContext invocationContext) { - return "baz"; - } - - } - - public static class NoRetryer implements Retryer { - - @Override - public void continueOrPropagate(RetryableException e) { - throw e; - } - - @Override - public Retryer clone() { - return this; - } - - } - - public static class DefaultErrorDecoder extends ErrorDecoder.Default { - - } - - public static class FormEncoder implements Encoder { - - @Override - public void encode(Object o, Type type, RequestTemplate requestTemplate) throws EncodeException { - Map form = (Map) o; - StringBuilder builder = new StringBuilder(); - form.forEach((key, value) -> { - builder.append(key); - builder.append("="); - builder.append(value); - builder.append("&"); - }); - - requestTemplate.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); - requestTemplate.body(builder.toString()); - } - - } - - public static class NoOpCapability implements Capability { - - } - - public static class NoOpQueryMapEncoder implements QueryMapEncoder { - - @Override - public Map encode(Object o) { - return null; - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientWithRefreshableOptionsTest.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientWithRefreshableOptionsTest.java deleted file mode 100644 index 4ec14ba11..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientWithRefreshableOptionsTest.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.concurrent.TimeUnit; - -import feign.Request; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.context.scope.refresh.RefreshScope; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.TestPropertySource; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.context.support.GenericWebApplicationContext; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Jasbir Singh - */ -@SpringBootTest -@TestPropertySource("classpath:feign-refreshable-properties.properties") -@DirtiesContext -public class FeignClientWithRefreshableOptionsTest { - - @Autowired - private ApplicationContext applicationContext; - - @Autowired - private RefreshScope refreshScope; - - @Autowired - private Application.RefreshableClient refreshableClient; - - @Autowired - private Application.ReadTimeoutClient readTimeoutClient; - - @Autowired - private Application.ConnectTimeoutClient connectTimeoutClient; - - @Autowired - private Application.OverrideOptionsClient overrideOptionsClient; - - @Autowired - private FeignClientProperties clientProperties; - - @Test - public void overriddenOptionsBeanShouldBePresentInsteadOfRefreshable() { - OptionsTestClient.OptionsResponseForTests options = overrideOptionsClient.override(); - assertConnectionAndReadTimeout(options, 1, 1); - } - - @Test - public void refreshScopeBeanDefinitionShouldBePresent() { - BeanDefinition beanDefinition = ((GenericWebApplicationContext) applicationContext) - .getBeanDefinition(Request.Options.class.getCanonicalName() + "-" + "refreshableClient"); - BeanDefinition originBeanDefinition = beanDefinition.getOriginatingBeanDefinition(); - assertThat(originBeanDefinition.getBeanClassName()).isEqualTo(OptionsFactoryBean.class.getCanonicalName()); - assertThat(originBeanDefinition.getScope()).isEqualTo("refresh"); - } - - @Test - public void withConfigDefaultConnectTimeoutAndReadTimeout() { - OptionsTestClient.OptionsResponseForTests options = refreshableClient.refreshable(); - assertConnectionAndReadTimeout(options, 5000, 5000); - } - - @Test - public void readTimeoutShouldWorkWhenConnectTimeoutNotSet() { - OptionsTestClient.OptionsResponseForTests options = readTimeoutClient.readTimeout(); - assertConnectionAndReadTimeout(options, 5000, 2000); - } - - @Test - public void connectTimeoutShouldWorkWhenReadTimeoutNotSet() { - OptionsTestClient.OptionsResponseForTests options = connectTimeoutClient.connectTimeout(); - assertConnectionAndReadTimeout(options, 2000, 5000); - } - - @Test - public void connectTimeoutShouldNotChangeWithoutContextRefresh() { - OptionsTestClient.OptionsResponseForTests options = connectTimeoutClient.connectTimeout(); - assertConnectionAndReadTimeout(options, 2000, 5000); - - clientProperties.getConfig().get("connectTimeout").setConnectTimeout(5000); - options = connectTimeoutClient.connectTimeout(); - assertConnectionAndReadTimeout(options, 2000, 5000); - } - - @Test - public void connectTimeoutShouldChangeAfterContextRefresh() { - OptionsTestClient.OptionsResponseForTests options = connectTimeoutClient.connectTimeout(); - assertConnectionAndReadTimeout(options, 2000, 5000); - - clientProperties.getConfig().get("connectTimeout").setConnectTimeout(5000); - refreshScope.refreshAll(); - options = connectTimeoutClient.connectTimeout(); - assertConnectionAndReadTimeout(options, 5000, 5000); - } - - private void assertConnectionAndReadTimeout(OptionsTestClient.OptionsResponseForTests options, - int expectedConnectTimeoutInMillis, int expectedReadTimeoutInMillis) { - assertThat(options.connectTimeout()).isEqualTo(expectedConnectTimeoutInMillis); - assertThat(options.readTimeout()).isEqualTo(expectedReadTimeoutInMillis); - } - - @Configuration - @EnableAutoConfiguration - @EnableConfigurationProperties(FeignClientProperties.class) - @EnableFeignClients(clients = { Application.OverrideOptionsClient.class, Application.RefreshableClient.class, - Application.ReadTimeoutClient.class, Application.ConnectTimeoutClient.class }) - protected static class Application { - - @Bean - OptionsTestClient client() { - return new OptionsTestClient(); - } - - @FeignClient(name = "overrideOptionsClient", configuration = OverrideConfig.class) - protected interface OverrideOptionsClient { - - @GetMapping("/override") - OptionsTestClient.OptionsResponseForTests override(); - - } - - @FeignClient(name = "refreshableClient") - protected interface RefreshableClient { - - @GetMapping("/refreshable") - OptionsTestClient.OptionsResponseForTests refreshable(); - - } - - @FeignClient(name = "readTimeout") - protected interface ReadTimeoutClient { - - @GetMapping("/readTimeout") - OptionsTestClient.OptionsResponseForTests readTimeout(); - - } - - @FeignClient(name = "connectTimeout") - protected interface ConnectTimeoutClient { - - @GetMapping("/connectTimeout") - OptionsTestClient.OptionsResponseForTests connectTimeout(); - - } - - @Configuration - protected static class OverrideConfig { - - @Bean - public Request.Options options() { - return new Request.Options(1, TimeUnit.MILLISECONDS, 1, TimeUnit.MILLISECONDS, true); - } - - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsMicrometerAutoConfigurationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsMicrometerAutoConfigurationTests.java deleted file mode 100644 index 2218fbbab..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsMicrometerAutoConfigurationTests.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2022-2022 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; - -import feign.micrometer.MicrometerCapability; -import feign.micrometer.MicrometerObservationCapability; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration; -import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration; -import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.context.FilteredClassLoader; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Micrometer auto-configuration tests for {@link FeignClientsConfiguration}. - * - * @author Jonatan Ivanov - */ -class FeignClientsMicrometerAutoConfigurationTests { - - private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration( - AutoConfigurations.of(ObservationAutoConfiguration.class, SimpleMetricsExportAutoConfiguration.class, - MetricsAutoConfiguration.class, FeignClientsConfiguration.class)); - - @Test - void shouldProvideMicrometerObservationCapability() { - contextRunner.run(context -> assertThat(context).hasSingleBean(MicrometerObservationCapability.class) - .doesNotHaveBean(MicrometerCapability.class)); - } - - @Test - void shouldNotProvideMicrometerObservationCapabilityIfFeatureIsDisabled() { - contextRunner.withPropertyValues("spring.cloud.openfeign.micrometer.enabled=false") - .run(context -> assertThat(context).doesNotHaveBean(MicrometerObservationCapability.class) - .doesNotHaveBean(MicrometerCapability.class)); - } - - @Test - void shouldProvideMicrometerCapabilityIfObservationRegistryIsMissing() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(SimpleMetricsExportAutoConfiguration.class, - MetricsAutoConfiguration.class, FeignClientsConfiguration.class)) - .run(context -> assertThat(context).doesNotHaveBean(MicrometerObservationCapability.class) - .hasSingleBean(MicrometerCapability.class)); - } - - @Test - void shouldNotProvideMicrometerCapabilitiesIfFeignMicrometerSupportIsMissing() { - contextRunner.withClassLoader(new FilteredClassLoader("feign.micrometer")).run(context -> assertThat(context) - .doesNotHaveBean(MicrometerObservationCapability.class).doesNotHaveBean(MicrometerCapability.class)); - } - - @Test - void shouldNotProvideMicrometerCapabilitiesIfMicrometerSupportIsMissing() { - contextRunner.withClassLoader(new FilteredClassLoader("io.micrometer")).run(context -> assertThat(context) - .doesNotHaveBean(MicrometerObservationCapability.class).doesNotHaveBean(MicrometerCapability.class)); - } - - @Test - void shouldNotProvideMicrometerCapabilitiesIfBeansAreMissing() { - new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(FeignClientsConfiguration.class)) - .run(context -> assertThat(context).doesNotHaveBean(MicrometerObservationCapability.class) - .doesNotHaveBean(MicrometerCapability.class)); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsRegistrarIntegrationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsRegistrarIntegrationTests.java deleted file mode 100644 index e756c66f3..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsRegistrarIntegrationTests.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Tests for {@link FeignClientsRegistrar}. - * - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(classes = FeignClientsRegistrarIntegrationTests.QualifiersTestConfig.class) -class FeignClientsRegistrarIntegrationTests { - - @Autowired - ConfigurableApplicationContext context; - - @Test - void shouldUseQualifiersIfPresent() { - assertThat(context.getBean("qualifier1")).isNotNull(); - assertThat(context.getBean("qualifier2")).isNotNull(); - assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> context.getBean("qualifier3")); - } - - @Test - void shouldUseDefaultQualifierWhenNonePresent() { - assertThat(context.getBean("noQualifiersFeignClient")).isNotNull(); - } - - @Test - void shouldUseDefaultQualifierWhenEmptyQualifiers() { - assertThat(context.getBean("emptyQualifiersNoQualifierFeignClient")).isNotNull(); - } - - @Test - void shouldUseDefaultQualifierWhenWhitespaceQualifiers() { - assertThat(context.getBean("whitespaceQualifiersNoQualifierFeignClient")).isNotNull(); - } - - @FeignClient(name = "qualifiersClient", qualifiers = { "qualifier1", "qualifier2" }) - protected interface QualifiersClient { - - } - - @FeignClient(name = "noQualifiers") - protected interface NoQualifiersClient { - - } - - @FeignClient(name = "emptyQualifiersNoQualifier", qualifiers = {}) - protected interface EmptyQualifiersNoQualifierClient { - - } - - @FeignClient(name = "whitespaceQualifiersNoQualifier", qualifiers = { " " }) - protected interface WhitespaceQualifiersNoQualifierClient { - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @Import(NoSecurityConfiguration.class) - @EnableFeignClients(clients = { NoQualifiersClient.class, QualifiersClient.class, - EmptyQualifiersNoQualifierClient.class, WhitespaceQualifiersNoQualifierClient.class }) - protected static class QualifiersTestConfig { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsRegistrarTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsRegistrarTests.java deleted file mode 100644 index 0d2982928..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsRegistrarTests.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.Collections; - -import feign.Target; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledForJreRange; -import org.junit.jupiter.api.condition.JRE; - -import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.mock.env.MockEnvironment; -import org.springframework.test.util.ReflectionTestUtils; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatCode; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.assertj.core.api.Assertions.assertThatIllegalStateException; - -/** - * @author Spencer Gibb - * @author Gang Li - * @author Michal Domagala - * @author Szymon Linowski - * @author Olga Maciaszek-Sharma - */ -class FeignClientsRegistrarTests { - - @Test - void badNameHttpPrefix() { - assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> testGetName("http://bad_hostname")); - } - - @Test - void badNameHttpsPrefix() { - assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> testGetName("https://bad_hostname")); - } - - @Test - void badName() { - assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> testGetName("bad_hostname")); - } - - @Test - void badNameStartsWithHttp() { - assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> testGetName("http_bad_hostname")); - } - - @Test - void goodName() { - String name = testGetName("good-name"); - assertThat(name).as("name was wrong").isEqualTo("good-name"); - } - - @Test - void goodNameHttpPrefix() { - String name = testGetName("https://good-name"); - assertThat(name).as("name was wrong").isEqualTo("https://good-name"); - } - - @Test - void goodNameHttpsPrefix() { - String name = testGetName("https://goodname"); - assertThat(name).as("name was wrong").isEqualTo("https://goodname"); - } - - private String testGetName(String name) { - FeignClientsRegistrar registrar = new FeignClientsRegistrar(); - registrar.setEnvironment(new MockEnvironment()); - return registrar.getName(Collections.singletonMap("name", name)); - } - - @Test - void testFallback() { - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> new AnnotationConfigApplicationContext(FallbackTestConfig.class)); - } - - @Test - void testFallbackFactory() { - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> new AnnotationConfigApplicationContext(FallbackFactoryTestConfig.class)); - } - - @Test - void shouldPassSubLevelFeignClient() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - ((DefaultListableBeanFactory) context.getBeanFactory()).setAllowBeanDefinitionOverriding(false); - context.register(TopLevelSubLevelTestConfig.class); - assertThatCode(context::refresh) - .as("Case https://github.com/spring-cloud/spring-cloud-openfeign/issues/331 should be solved") - .doesNotThrowAnyException(); - } - - @SuppressWarnings("unchecked") - @Test - @DisabledForJreRange(min = JRE.JAVA_16) - void shouldResolveNullUrl() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - context.register(NullUrlFeignClientTestConfig.class); - context.refresh(); - - Object feignClientBean = context.getBean(NullUrlFeignClient.class); - - Object invocationHandlerLambda = ReflectionTestUtils.getField(feignClientBean, "h"); - Target.HardCodedTarget target = (Target.HardCodedTarget) ReflectionTestUtils - .getField(invocationHandlerLambda, "arg$3"); - assertThat(target.name()).isEqualTo("nullUrlFeignClient"); - assertThat(target.url()).isEqualTo("http://nullUrlFeignClient"); - } - - @Test - void shouldResolveAndValidateNullName() { - assertThatIllegalStateException().isThrownBy(() -> { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - context.register(NullExpressionNameFeignClientTestConfig.class); - context.refresh(); - }); - } - - @FeignClient(name = "fallbackTestClient", url = "http://localhost:8080/", fallback = FallbackClient.class) - protected interface FallbackClient { - - @GetMapping("/hello") - String fallbackTest(); - - } - - @FeignClient(name = "fallbackFactoryTestClient", url = "http://localhost:8081/", - fallbackFactory = FallbackFactoryClient.class) - protected interface FallbackFactoryClient { - - @GetMapping("/hello") - String fallbackFactoryTest(); - - } - - @FeignClient(name = "nullUrlFeignClient", url = "${test.url:#{null}}", path = "${test.path:#{null}}") - protected interface NullUrlFeignClient { - - } - - @FeignClient(name = "${test.name:#{null}}") - protected interface NullExpressionNameFeignClient { - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @EnableFeignClients(clients = { FeignClientsRegistrarTests.FallbackClient.class }) - protected static class FallbackTestConfig { - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @EnableFeignClients(clients = { FeignClientsRegistrarTests.FallbackFactoryClient.class }) - protected static class FallbackFactoryTestConfig { - - } - - @EnableFeignClients(clients = { org.springframework.cloud.openfeign.feignclientsregistrar.TopLevelClient.class, - org.springframework.cloud.openfeign.feignclientsregistrar.sub.SubLevelClient.class }) - protected static class TopLevelSubLevelTestConfig { - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @EnableFeignClients(clients = NullUrlFeignClient.class) - protected static class NullUrlFeignClientTestConfig { - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @EnableFeignClients(clients = NullExpressionNameFeignClient.class) - protected static class NullExpressionNameFeignClientTestConfig { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignCompressionTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignCompressionTests.java deleted file mode 100644 index 0f4c5485c..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignCompressionTests.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2013-2023 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.encoding; - -import java.util.Map; - -import feign.RequestInterceptor; -import okhttp3.OkHttpClient; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.cloud.openfeign.FeignAutoConfiguration; -import org.springframework.cloud.openfeign.FeignClientFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Ryan Baxter - * @author Biju Kunjummen - * @author Olga Maciaszek-Sharma - */ -class FeignCompressionTests { - - @Test - void shouldAddCompressionInterceptors() { - new ApplicationContextRunner() - .withPropertyValues("spring.cloud.openfeign.compression.response.enabled=true", - "spring.cloud.openfeign.compression.request.enabled=true", - "spring.cloud.openfeign.okhttp.enabled=false") - .withConfiguration(AutoConfigurations.of(FeignAutoConfiguration.class, - FeignContentGzipEncodingAutoConfiguration.class, - FeignAcceptGzipEncodingAutoConfiguration.class)) - .run(context -> { - FeignClientFactory feignClientFactory = context.getBean(FeignClientFactory.class); - Map interceptors = feignClientFactory.getInstances("foo", - RequestInterceptor.class); - assertThat(interceptors.size()).isEqualTo(2); - assertThat(interceptors.get("feignAcceptGzipEncodingInterceptor")) - .isInstanceOf(FeignAcceptGzipEncodingInterceptor.class); - assertThat(interceptors.get("feignContentGzipEncodingInterceptor")) - .isInstanceOf(FeignContentGzipEncodingInterceptor.class); - }); - } - - @Test - void shouldNotAddInterceptorsIfFeignOkHttpClientPresent() { - new ApplicationContextRunner() - .withPropertyValues("spring.cloud.openfeign.compression.response.enabled=true", - "spring.cloud.openfeign.compression.request.enabled=true", - "spring.cloud.openfeign.okhttp.enabled=true", "spring.cloud.openfeign.httpclient.hc5.enabled") - .withConfiguration(AutoConfigurations.of(FeignAutoConfiguration.class, - FeignContentGzipEncodingAutoConfiguration.class, - FeignAcceptGzipEncodingAutoConfiguration.class)) - .run(context -> { - FeignClientFactory feignClientFactory = context.getBean(FeignClientFactory.class); - Map interceptors = feignClientFactory.getInstances("foo", - RequestInterceptor.class); - assertThat(interceptors).isEmpty(); - }); - } - - @Configuration - static class OkHttpClientConfiguration { - - @Bean - OkHttpClient okHttpClient() { - return new OkHttpClient(); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignErrorDecoderFactoryTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignErrorDecoderFactoryTests.java deleted file mode 100644 index 9e2422531..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignErrorDecoderFactoryTests.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2020-2022 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; - -import feign.Response; -import feign.codec.ErrorDecoder; -import org.junit.jupiter.api.Test; - -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Michael Cramer - */ -class FeignErrorDecoderFactoryTests { - - @Test - void testNoDefaultFactory() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SampleConfiguration1.class); - String[] beanNamesForType = context.getBeanNamesForType(FeignErrorDecoderFactory.class); - assertThat(beanNamesForType).isEmpty(); - context.close(); - } - - @Test - void testCustomErrorDecoderFactory() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SampleConfiguration2.class); - FeignErrorDecoderFactory errorDecoderFactory = context.getBean(FeignErrorDecoderFactory.class); - assertThat(errorDecoderFactory).isNotNull(); - ErrorDecoder errorDecoder = errorDecoderFactory.create(Object.class); - assertThat(errorDecoder).isNotNull(); - assertThat(errorDecoder instanceof ErrorDecoderImpl).isTrue(); - context.close(); - } - - @Test - void testCustomErrorDecoderFactoryNotOverwritingErrorDecoder() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SampleConfiguration3.class); - FeignErrorDecoderFactory errorDecoderFactory = context.getBean(FeignErrorDecoderFactory.class); - assertThat(errorDecoderFactory).isNotNull(); - ErrorDecoder errorDecoderFromFactory = errorDecoderFactory.create(Object.class); - assertThat(errorDecoderFromFactory).isNotNull(); - assertThat(errorDecoderFromFactory instanceof ErrorDecoderImpl).isTrue(); - ErrorDecoder errorDecoder = context.getBean(ErrorDecoder.class); - assertThat(errorDecoder).isNotNull(); - assertThat(errorDecoder instanceof ErrorDecoder.Default).isTrue(); - context.close(); - } - - @Configuration - @Import(FeignClientsConfiguration.class) - protected static class SampleConfiguration1 { - - } - - @Configuration - @Import(FeignClientsConfiguration.class) - protected static class SampleConfiguration2 { - - @Bean - public FeignErrorDecoderFactory errorDecoderFactory() { - return new ErrorDecoderFactoryImpl(); - } - - } - - @Configuration - @Import(FeignClientsConfiguration.class) - protected static class SampleConfiguration3 { - - @Bean - public FeignErrorDecoderFactory errorDecoderFactory() { - return new ErrorDecoderFactoryImpl(); - } - - @Bean - public ErrorDecoder errorDecoder() { - return new ErrorDecoder.Default(); - } - - } - - static class ErrorDecoderFactoryImpl implements FeignErrorDecoderFactory { - - @Override - public ErrorDecoder create(final Class type) { - return new ErrorDecoderImpl(); - } - - } - - static class ErrorDecoderImpl implements ErrorDecoder { - - @Override - public Exception decode(final String methodKey, final Response response) { - return null; - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttp2ClientConfigurationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttp2ClientConfigurationTests.java deleted file mode 100644 index 89e6022cf..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttp2ClientConfigurationTests.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2013-2023 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; - -import java.net.http.HttpClient; -import java.time.Duration; -import java.util.Optional; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.ConfigurableApplicationContext; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author changjin wei(魏昌进) - */ -class FeignHttp2ClientConfigurationTests { - - private ConfigurableApplicationContext context; - - @BeforeEach - void setUp() { - context = new SpringApplicationBuilder() - .properties("debug=true", "spring.cloud.openfeign.http2client.enabled=true", - "spring.cloud.openfeign.httpclient.http2.version=HTTP_1_1", - "spring.cloud.openfeign.httpclient.connectionTimeout=15") - .web(WebApplicationType.NONE).sources(FeignAutoConfiguration.class).run(); - } - - @AfterEach - void tearDown() { - if (context != null) { - context.close(); - } - } - - @Test - void shouldConfigureConnectTimeout() { - HttpClient httpClient = context.getBean(HttpClient.class); - - assertThat(httpClient.connectTimeout()).isEqualTo(Optional.ofNullable(Duration.ofMillis(15))); - } - - @Test - void shouldResolveVersionFromProperties() { - HttpClient httpClient = context.getBean(HttpClient.class); - - assertThat(httpClient.version()).isEqualTo(HttpClient.Version.HTTP_1_1); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClient5ConfigurationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClient5ConfigurationTests.java deleted file mode 100644 index 937a03e18..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClient5ConfigurationTests.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import feign.Client; -import feign.hc5.ApacheHttp5Client; -import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; -import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; -import org.apache.hc.client5.http.io.HttpClientConnectionManager; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.ConfigurableApplicationContext; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * @author Nguyen Ky Thanh - * @author Olga Maciaszek-Sharma - */ -class FeignHttpClient5ConfigurationTests { - - private static void verifyHc5BeansAvailable(ConfigurableApplicationContext context) { - CloseableHttpClient httpClient = context.getBean(CloseableHttpClient.class); - assertThat(httpClient).isNotNull(); - HttpClientConnectionManager connectionManager = context.getBean(HttpClientConnectionManager.class); - assertThat(connectionManager).isInstanceOf(PoolingHttpClientConnectionManager.class); - Client client = context.getBean(Client.class); - assertThat(client).isInstanceOf(ApacheHttp5Client.class); - } - - @Test - void shouldInstantiateHttpClient5ByDefaultWhenDependenciesPresent() { - ConfigurableApplicationContext context = new SpringApplicationBuilder().web(WebApplicationType.NONE) - .sources(FeignAutoConfiguration.class).run(); - - verifyHc5BeansAvailable(context); - - if (context != null) { - context.close(); - } - } - - @Test - void shouldNotInstantiateHttpClient5ByWhenDependenciesPresentButPropertyDisabled() { - ConfigurableApplicationContext context = new SpringApplicationBuilder() - .properties("spring.cloud.openfeign.httpclient.hc5.enabled=false").web(WebApplicationType.NONE) - .sources(FeignAutoConfiguration.class).run(); - - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> context.getBean(CloseableHttpClient.class)); - - if (context != null) { - context.close(); - } - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlTests.java deleted file mode 100644 index 92d204604..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlTests.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.reflect.Field; -import java.util.Objects; - -import feign.Client; -import feign.Feign; -import feign.Target; -import feign.hc5.ApacheHttp5Client; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.cloud.test.TestSocketUtils; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.util.ReflectionUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT; - -/** - * @author Spencer Gibb - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(classes = FeignHttpClientUrlTests.TestConfig.class, webEnvironment = DEFINED_PORT, - value = { "spring.application.name=feignclienturltest", "spring.cloud.openfeign.circuitbreaker.enabled=false", - "spring.cloud.openfeign.okhttp.enabled=false", "spring.cloud.loadbalancer.retry.enabled=false" }) -@DirtiesContext -class FeignHttpClientUrlTests { - - static int port; - - @Autowired - BeanUrlClientNoProtocol beanClientNoProtocol; - - @Autowired - private UrlClient urlClient; - - @Autowired - private BeanUrlClient beanClient; - - @BeforeAll - static void beforeClass() { - port = TestSocketUtils.findAvailableTcpPort(); - System.setProperty("server.port", String.valueOf(port)); - } - - @AfterAll - static void afterClass() { - System.clearProperty("server.port"); - } - - @Test - void testUrlHttpClient() { - assertThat(urlClient).as("UrlClient was null").isNotNull(); - Hello hello = urlClient.getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - } - - @Test - void testBeanUrl() { - Hello hello = beanClient.getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - } - - @Test - void testBeanUrlNoProtocol() { - Hello hello = beanClientNoProtocol.getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - } - - // this tests that - @FeignClient(name = "localappurl", url = "http://localhost:${server.port}/") - protected interface UrlClient { - - @GetMapping("/hello") - Hello getHello(); - - } - - @FeignClient(name = "beanappurl", url = "#{SERVER_URL}path") - protected interface BeanUrlClient { - - @GetMapping("/hello") - Hello getHello(); - - } - - @FeignClient(name = "beanappurlnoprotocol", url = "#{SERVER_URL_NO_PROTOCOL}path") - protected interface BeanUrlClientNoProtocol { - - @GetMapping("/hello") - Hello getHello(); - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients(clients = { UrlClient.class, BeanUrlClient.class, BeanUrlClientNoProtocol.class }) - @Import(NoSecurityConfiguration.class) - protected static class TestConfig { - - @GetMapping("/hello") - public Hello getHello() { - return new Hello("hello world 1"); - } - - @GetMapping("/path/hello") - public Hello getHelloWithPath() { - return getHello(); - } - - @Bean(name = "SERVER_URL") - public String serverUrl() { - return "http://localhost:" + port + "/"; - } - - @Bean(name = "SERVER_URL_NO_PROTOCOL") - public String serverUrlNoProtocol() { - return "localhost:" + port + "/"; - } - - @Bean - public Targeter feignTargeter() { - return new Targeter() { - @Override - public T target(FeignClientFactoryBean factory, Feign.Builder feign, FeignClientFactory context, - Target.HardCodedTarget target) { - Field field = ReflectionUtils.findField(Feign.Builder.class, "client"); - ReflectionUtils.makeAccessible(field); - Client client = (Client) ReflectionUtils.getField(field, feign); - if (target.name().equals("localappurl")) { - assertThat(client).isInstanceOf(ApacheHttp5Client.class).as("client was wrong type"); - } - return feign.target(target); - } - }; - } - - } - - public static class Hello { - - private String message; - - Hello() { - } - - Hello(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Hello that = (Hello) o; - return Objects.equals(message, that.message); - } - - @Override - public int hashCode() { - return Objects.hash(message); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlWithRetryableLoadBalancerTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlWithRetryableLoadBalancerTests.java deleted file mode 100644 index 233c867c0..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignHttpClientUrlWithRetryableLoadBalancerTests.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.reflect.Field; -import java.util.Objects; - -import feign.Client; -import feign.Feign; -import feign.Target; -import feign.hc5.ApacheHttp5Client; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.cloud.test.TestSocketUtils; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.util.ReflectionUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT; - -/** - * @author Spencer Gibb - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(classes = FeignHttpClientUrlWithRetryableLoadBalancerTests.TestConfig.class, - webEnvironment = DEFINED_PORT, - value = { "spring.application.name=feignclienturlwithretryableloadbalancertest", - "spring.cloud.openfeign.hystrix.enabled=false", "spring.cloud.openfeign.okhttp.enabled=false" }) -@DirtiesContext -class FeignHttpClientUrlWithRetryableLoadBalancerTests { - - static int port; - - @Autowired - BeanUrlClientNoProtocol beanClientNoProtocol; - - @Autowired - private UrlClient urlClient; - - @Autowired - private BeanUrlClient beanClient; - - @BeforeAll - static void beforeClass() { - port = TestSocketUtils.findAvailableTcpPort(); - System.setProperty("server.port", String.valueOf(port)); - } - - @AfterAll - static void afterClass() { - System.clearProperty("server.port"); - } - - @Test - void testUrlHttpClient() { - assertThat(urlClient).as("UrlClient was null").isNotNull(); - Hello hello = urlClient.getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - } - - @Test - void testBeanUrl() { - Hello hello = beanClient.getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - } - - @Test - void testBeanUrlNoProtocol() { - Hello hello = beanClientNoProtocol.getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - } - - // this tests that - @FeignClient(name = "localappurl", url = "http://localhost:${server.port}/") - protected interface UrlClient { - - @GetMapping("/hello") - Hello getHello(); - - } - - @FeignClient(name = "beanappurl", url = "#{SERVER_URL}path") - protected interface BeanUrlClient { - - @GetMapping("/hello") - Hello getHello(); - - } - - @FeignClient(name = "beanappurlnoprotocol", url = "#{SERVER_URL_NO_PROTOCOL}path") - protected interface BeanUrlClientNoProtocol { - - @GetMapping("/hello") - Hello getHello(); - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients(clients = { UrlClient.class, BeanUrlClient.class, BeanUrlClientNoProtocol.class }) - @Import(NoSecurityConfiguration.class) - protected static class TestConfig { - - @GetMapping("/hello") - public Hello getHello() { - return new Hello("hello world 1"); - } - - @GetMapping("/path/hello") - public Hello getHelloWithPath() { - return getHello(); - } - - @Bean(name = "SERVER_URL") - public String serverUrl() { - return "http://localhost:" + port + "/"; - } - - @Bean(name = "SERVER_URL_NO_PROTOCOL") - public String serverUrlNoProtocol() { - return "localhost:" + port + "/"; - } - - @Bean - public Targeter feignTargeter() { - return new Targeter() { - @Override - public T target(FeignClientFactoryBean factory, Feign.Builder feign, FeignClientFactory context, - Target.HardCodedTarget target) { - Field field = ReflectionUtils.findField(Feign.Builder.class, "client"); - ReflectionUtils.makeAccessible(field); - Client client = (Client) ReflectionUtils.getField(field, feign); - if (target.name().equals("localappurl")) { - assertThat(client).isInstanceOf(ApacheHttp5Client.class).as("client was wrong type"); - } - return feign.target(target); - } - }; - } - - } - - public static class Hello { - - private String message; - - Hello() { - - } - - Hello(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Hello that = (Hello) o; - return Objects.equals(message, that.message); - } - - @Override - public int hashCode() { - return Objects.hash(message); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignLoggerFactoryTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignLoggerFactoryTests.java deleted file mode 100644 index a6e0d0cb2..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignLoggerFactoryTests.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2016-2022 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; - -import feign.Logger; -import feign.slf4j.Slf4jLogger; -import org.junit.jupiter.api.Test; - -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Venil Noronha - */ -class FeignLoggerFactoryTests { - - @Test - void testDefaultLogger() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SampleConfiguration1.class); - FeignLoggerFactory loggerFactory = context.getBean(FeignLoggerFactory.class); - assertThat(loggerFactory).isNotNull(); - Logger logger = loggerFactory.create(Object.class); - assertThat(logger).isNotNull(); - assertThat(logger instanceof Slf4jLogger).isTrue(); - context.close(); - } - - @Test - void testCustomLogger() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SampleConfiguration2.class); - FeignLoggerFactory loggerFactory = context.getBean(FeignLoggerFactory.class); - assertThat(loggerFactory).isNotNull(); - Logger logger = loggerFactory.create(Object.class); - assertThat(logger).isNotNull(); - assertThat(logger instanceof LoggerImpl1).isTrue(); - context.close(); - } - - @Test - void testCustomLoggerFactory() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SampleConfiguration3.class); - FeignLoggerFactory loggerFactory = context.getBean(FeignLoggerFactory.class); - assertThat(loggerFactory).isNotNull(); - assertThat(loggerFactory instanceof LoggerFactoryImpl).isTrue(); - Logger logger = loggerFactory.create(Object.class); - assertThat(logger).isNotNull(); - assertThat(logger instanceof LoggerImpl2).isTrue(); - context.close(); - } - - @Configuration(proxyBeanMethods = false) - @Import(FeignClientsConfiguration.class) - protected static class SampleConfiguration1 { - - } - - @Configuration(proxyBeanMethods = false) - @Import(FeignClientsConfiguration.class) - protected static class SampleConfiguration2 { - - @Bean - public Logger logger() { - return new LoggerImpl1(); - } - - } - - static class LoggerImpl1 extends Logger { - - @Override - protected void log(String arg0, String arg1, Object... arg2) { - // noop - } - - } - - @Configuration(proxyBeanMethods = false) - @Import(FeignClientsConfiguration.class) - protected static class SampleConfiguration3 { - - @Bean - public FeignLoggerFactory feignLoggerFactory() { - return new LoggerFactoryImpl(); - } - - } - - static class LoggerFactoryImpl implements FeignLoggerFactory { - - @Override - public Logger create(Class type) { - return new LoggerImpl2(); - } - - } - - static class LoggerImpl2 extends Logger { - - @Override - protected void log(String arg0, String arg1, Object... arg2) { - // noop - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignOkHttpConfigurationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignOkHttpConfigurationTests.java deleted file mode 100644 index ec55790b6..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignOkHttpConfigurationTests.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.reflect.Field; - -import javax.net.ssl.HostnameVerifier; - -import okhttp3.OkHttpClient; -import okhttp3.Protocol; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.util.ReflectionUtils; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Ryan Baxter - * @author changjin wei(魏昌进) - */ -class FeignOkHttpConfigurationTests { - - private ConfigurableApplicationContext context; - - @BeforeEach - void setUp() { - this.context = new SpringApplicationBuilder() - .properties("debug=true", "spring.cloud.openfeign.httpclient.disableSslValidation=true", - "spring.cloud.openfeign.okhttp.enabled=true", - "spring.cloud.openfeign.httpclient.hc5.enabled=false", - "spring.cloud.openfeign.httpclient.okhttp.read-timeout=9s", - "spring.cloud.openfeign.httpclient.okhttp.protocols=H2_PRIOR_KNOWLEDGE") - .web(WebApplicationType.NONE).sources(FeignAutoConfiguration.class).run(); - } - - @AfterEach - void tearDown() { - if (context != null) { - context.close(); - } - } - - @Test - void disableSslTest() { - OkHttpClient httpClient = context.getBean(OkHttpClient.class); - HostnameVerifier hostnameVerifier = (HostnameVerifier) this.getField(httpClient, "hostnameVerifier"); - assertThat(hostnameVerifier instanceof FeignAutoConfiguration.OkHttpFeignConfiguration.TrustAllHostnames) - .isTrue(); - } - - @Test - void shouldConfigureReadTimeout() { - OkHttpClient httpClient = context.getBean(OkHttpClient.class); - - assertThat(httpClient.readTimeoutMillis()).isEqualTo(9000); - } - - @Test - void shouldResolveProtocolFromProperties() { - OkHttpClient httpClient = context.getBean(OkHttpClient.class); - - assertThat(httpClient.protocols()).containsExactly(Protocol.H2_PRIOR_KNOWLEDGE); - } - - protected Object getField(Object target, String name) { - Field field = ReflectionUtils.findField(target.getClass(), name); - ReflectionUtils.makeAccessible(field); - return ReflectionUtils.getField(field, target); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/GzipDecodingTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/GzipDecodingTests.java deleted file mode 100644 index 6ccc6df68..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/GzipDecodingTests.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.Objects; - -import org.junit.jupiter.api.Test; - -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.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Jaesik Kim - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(classes = GzipDecodingTests.Application.class, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=defaultGzipDecoderTests", - "spring.cloud.openfeign.compression.response.enabled=true", - "spring.cloud.openfeign.client.config.default.loggerLevel=none", - "spring.cloud.openfeign.micrometer.enabled=false", - "logging.level.org.springframework.cloud.openfeign=DEBUG" }) -@DirtiesContext -class GzipDecodingTests extends FeignClientFactoryBean { - - @Autowired - FeignClientFactory context; - - @Value("${local.server.port}") - private int port = 0; - - GzipDecodingTests() { - setName("tests"); - setContextId("test"); - } - - public TestClient testClient() { - setType(this.getClass()); - return feign(context).target(TestClient.class, "http://localhost:" + this.port); - } - - @Test - void testBodyDecompress() { - ResponseEntity response = testClient().getGzipResponse(); - assertThat(response).as("response was null").isNotNull(); - assertThat(response.getStatusCode()).as("wrong status code").isEqualTo(HttpStatus.OK); - Hello hello = response.getBody(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world via response")); - } - - @Test - void testNullBodyDecompress() { - ResponseEntity response = testClient().getNullResponse(); - assertThat(response).as("response was null").isNotNull(); - assertThat(response.getStatusCode()).as("wrong status code").isEqualTo(HttpStatus.OK); - Hello hello = response.getBody(); - assertThat(hello).as("hello was not null").isNull(); - assertThat(hello).as("null hello didn't match").isEqualTo(null); - } - - @Test - void testCharsetDecompress() { - ResponseEntity response = testClient().getUtf8Response(); - assertThat(response).as("response was null").isNotNull(); - assertThat(response.getStatusCode()).as("wrong status code").isEqualTo(HttpStatus.OK); - Hello hello = response.getBody(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("utf8 hello didn't match").isEqualTo(new Hello("안녕하세요 means Hello in Korean")); - } - - private static class Hello { - - private String message; - - Hello() { - } - - Hello(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Hello that = (Hello) o; - return Objects.equals(message, that.message); - } - - @Override - public int hashCode() { - return Objects.hash(message); - } - - } - - protected interface TestClient { - - @GetMapping("/helloGzipResponse") - ResponseEntity getGzipResponse(); - - @GetMapping("/nullGzipResponse") - ResponseEntity getNullResponse(); - - @GetMapping("/utf8Response") - ResponseEntity getUtf8Response(); - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @Import(NoSecurityConfiguration.class) - protected static class Application implements TestClient { - - @Override - public ResponseEntity getGzipResponse() { - return ResponseEntity.ok(new Hello("hello world via response")); - } - - @Override - public ResponseEntity getNullResponse() { - return ResponseEntity.ok(null); - } - - @Override - public ResponseEntity getUtf8Response() { - return ResponseEntity.ok(new Hello("안녕하세요 means Hello in Korean")); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/LazyInitFeignClientUsingConfigurerTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/LazyInitFeignClientUsingConfigurerTests.java deleted file mode 100644 index 76f60c750..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/LazyInitFeignClientUsingConfigurerTests.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.lang.reflect.Field; -import java.util.List; - -import feign.Capability; -import feign.Feign; -import feign.Logger; -import feign.RequestInterceptor; -import feign.micrometer.MicrometerObservationCapability; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.openfeign.clientconfig.FeignClientConfigurer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.util.ReflectionUtils; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author matt king - * @author Jonatan Ivanov - * @author Olga Maciaszek-Sharma - */ -@DirtiesContext -@SpringBootTest(classes = LazyInitFeignClientUsingConfigurerTests.Application.class, value = { - "spring.cloud.openfeign.lazy-attributes-resolution=true", - "spring.cloud.openfeign.client.config.default.loggerLevel=full", - "spring.cloud.openfeign.client.config.default.requestInterceptors[0]=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.FooRequestInterceptor", - "spring.cloud.openfeign.client.config.default.requestInterceptors[1]=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.BarRequestInterceptor" }) -class LazyInitFeignClientUsingConfigurerTests { - - private static final String BEAN_NAME_PREFIX = "org.springframework.cloud.openfeign.LazyInitFeignClientUsingConfigurerTests$"; - - @Autowired - private ConfigurableListableBeanFactory beanFactory; - - @Autowired - private FeignClientFactory context; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Test - void testFeignClient() { - FeignClientFactoryBean factoryBean = (FeignClientFactoryBean) beanFactory - .getBeanDefinition(BEAN_NAME_PREFIX + "TestFeignClient") - .getAttribute("feignClientsRegistrarFactoryBean"); - Feign.Builder builder = factoryBean.feign(context); - - List interceptors = (List) getBuilderValue(builder, "requestInterceptors"); - assertThat(interceptors.size()).as("interceptors not set").isEqualTo(3); - assertThat(getBuilderValue(builder, "logLevel")).as("log level not set").isEqualTo(Logger.Level.FULL); - - List capabilities = (List) getBuilderValue(builder, "capabilities"); - assertThat(capabilities).hasSize(2).hasAtLeastOneElementOfType(NoOpCapability.class) - .hasAtLeastOneElementOfType(MicrometerObservationCapability.class); - } - - private Object getBuilderValue(Feign.Builder builder, String member) { - Field builderField = ReflectionUtils.findField(Feign.Builder.class, member); - ReflectionUtils.makeAccessible(builderField); - - return ReflectionUtils.getField(builderField, builder); - } - - @SuppressWarnings("unchecked") - @Test - void testNoInheritFeignClient() { - FeignClientFactoryBean factoryBean = (FeignClientFactoryBean) beanFactory - .getBeanDefinition(BEAN_NAME_PREFIX + "NoInheritFeignClient") - .getAttribute("feignClientsRegistrarFactoryBean"); - Feign.Builder builder = factoryBean.feign(context); - - List interceptors = (List) getBuilderValue(builder, "requestInterceptors"); - assertThat(interceptors).as("interceptors not set").isEmpty(); - assertThat(factoryBean.isInheritParentContext()).as("is inheriting from parent configuration").isFalse(); - - List capabilities = (List) getBuilderValue(builder, "capabilities"); - assertThat(capabilities).hasSize(2).hasAtLeastOneElementOfType(NoOpCapability.class) - .hasAtLeastOneElementOfType(MicrometerObservationCapability.class); - } - - @SuppressWarnings("unchecked") - @Test - void testNoInheritFeignClient_ignoreProperties() { - FeignClientFactoryBean factoryBean = (FeignClientFactoryBean) beanFactory - .getBeanDefinition(BEAN_NAME_PREFIX + "NoInheritFeignClient") - .getAttribute("feignClientsRegistrarFactoryBean"); - Feign.Builder builder = factoryBean.feign(context); - - assertThat(getBuilderValue(builder, "logLevel")).as("log level not set").isEqualTo(Logger.Level.HEADERS); - - List capabilities = (List) getBuilderValue(builder, "capabilities"); - assertThat(capabilities).hasSize(2).hasAtLeastOneElementOfType(NoOpCapability.class) - .hasAtLeastOneElementOfType(MicrometerObservationCapability.class); - } - - @EnableAutoConfiguration - @Configuration(proxyBeanMethods = false) - @EnableFeignClients(clients = { TestFeignClient.class, NoInheritFeignClient.class }) - protected static class Application { - - @Bean - public RequestInterceptor requestInterceptor() { - return requestTemplate -> { - }; - } - - @Bean - public NoOpCapability noOpCapability() { - return new NoOpCapability(); - } - - } - - public static class NoInheritConfiguration { - - @Bean - public Logger.Level logLevel() { - return Logger.Level.HEADERS; - } - - @Bean - public NoOpCapability noOpCapability() { - return new NoOpCapability(); - } - - @Bean - public FeignClientConfigurer feignClientConfigurer() { - return new FeignClientConfigurer() { - - @Override - public boolean inheritParentConfiguration() { - return false; - } - }; - - } - - } - - @FeignClient("testFeignClient") - interface TestFeignClient { - - } - - @FeignClient(name = "noInheritFeignClient", configuration = NoInheritConfiguration.class) - interface NoInheritFeignClient { - - } - - private static class NoOpCapability implements Capability { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/MicrometerPropertiesTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/MicrometerPropertiesTests.java deleted file mode 100644 index 455f1ae52..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/MicrometerPropertiesTests.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2021-2022 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; - -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsAndHashCodeConsistency; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsConsistency; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsReflexivity; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsSymmetricity; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertEqualsTransitivity; -import static org.springframework.cloud.openfeign.test.EqualsAndHashCodeAssert.assertHashCodeConsistency; - -/** - * Tests for {@link FeignClientProperties.MicrometerProperties} - * - * @author Jonatan Ivanov - */ -class MicrometerPropertiesTests { - - @Test - void shouldBeEnabledByDefault() { - FeignClientProperties.MicrometerProperties properties = new FeignClientProperties.MicrometerProperties(); - assertThat(properties.getEnabled()).isTrue(); - } - - @Test - void shouldBeDisabledWhenSet() { - FeignClientProperties.MicrometerProperties properties = new FeignClientProperties.MicrometerProperties(); - properties.setEnabled(false); - assertThat(properties.getEnabled()).isFalse(); - } - - /** - * Sanity-checks equals and hashCode contracts but does not check every variation of - * the fields. - */ - @Test - void shouldHaveSomewhatValidEqualsAndHashCode() { - FeignClientProperties.MicrometerProperties propertyOne = new FeignClientProperties.MicrometerProperties(); - FeignClientProperties.MicrometerProperties propertyTwo = new FeignClientProperties.MicrometerProperties(); - FeignClientProperties.MicrometerProperties propertyThree = new FeignClientProperties.MicrometerProperties(); - FeignClientProperties.MicrometerProperties differentProperty = new FeignClientProperties.MicrometerProperties(); - differentProperty.setEnabled(false); - - assertEqualsReflexivity(propertyOne); - - assertEqualsSymmetricity(propertyOne, propertyTwo); - assertEqualsSymmetricity(propertyOne, differentProperty); - assertEqualsSymmetricity(propertyOne, 42); - - assertEqualsTransitivity(propertyOne, propertyTwo, propertyThree); - - assertEqualsConsistency(propertyOne, propertyTwo); - assertEqualsConsistency(propertyOne, differentProperty); - assertEqualsConsistency(propertyOne, 42); - assertEqualsConsistency(propertyOne, null); - - assertHashCodeConsistency(propertyOne); - assertEqualsAndHashCodeConsistency(propertyOne, propertyTwo); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/NonRefreshableFeignClientUrlTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/NonRefreshableFeignClientUrlTests.java deleted file mode 100644 index 1670e6355..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/NonRefreshableFeignClientUrlTests.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2013-2023 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; - -import feign.Target; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.TestPropertySource; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Jasbir Singh - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest -@TestPropertySource("classpath:feign-properties.properties") -@DirtiesContext -class NonRefreshableFeignClientUrlTests { - - @Autowired - private Application.FeignClientWithFixUrl feignClientWithFixUrl; - - @Autowired - private Application.ConfigBasedClient configBasedClient; - - @Autowired - private Application.NameBasedUrlClient nameBasedUrlClient; - - @Test - void shouldInstantiateFeignClientWhenUrlFromFeignClientUrl() { - UrlTestClient.UrlResponseForTests response = feignClientWithFixUrl.fixPath(); - assertThat(response.getUrl()).isEqualTo("http://localhost:8081/fixPath"); - assertThat(response.getTargetType()).isEqualTo(Target.HardCodedTarget.class); - } - - @Test - void shouldInstantiateFeignClientWhenUrlFromFeignClientUrlGivenPreferenceOverProperties() { - UrlTestClient.UrlResponseForTests response = feignClientWithFixUrl.fixPath(); - assertThat(response.getUrl()).isEqualTo("http://localhost:8081/fixPath"); - } - - @Test - public void shouldInstantiateFeignClientWhenUrlFromProperties() { - UrlTestClient.UrlResponseForTests response = configBasedClient.test(); - assertThat(response.getUrl()).isEqualTo("http://localhost:9999/test"); - assertThat(response.getTargetType()).isEqualTo(PropertyBasedTarget.class); - } - - @Test - void shouldInstantiateFeignClientWhenUrlFromFeignClientName() { - UrlTestClient.UrlResponseForTests response = nameBasedUrlClient.test(); - assertThat(response.getUrl()).isEqualTo("http://nameBasedClient/test"); - assertThat(response.getTargetType()).isEqualTo(Target.HardCodedTarget.class); - } - - @Configuration - @EnableAutoConfiguration - @EnableConfigurationProperties(FeignClientProperties.class) - @EnableFeignClients(clients = { Application.FeignClientWithFixUrl.class, Application.ConfigBasedClient.class, - Application.NameBasedUrlClient.class }) - protected static class Application { - - @Bean - UrlTestClient client() { - return new UrlTestClient(); - } - - @FeignClient(name = "feignClientWithFixUrl", url = "http://localhost:8081") - protected interface FeignClientWithFixUrl { - - @GetMapping("/fixPath") - UrlTestClient.UrlResponseForTests fixPath(); - - } - - @FeignClient(name = "configBasedClient") - protected interface ConfigBasedClient { - - @GetMapping("/test") - UrlTestClient.UrlResponseForTests test(); - - } - - @FeignClient(name = "nameBasedClient") - protected interface NameBasedUrlClient { - - @GetMapping("/test") - UrlTestClient.UrlResponseForTests test(); - - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/OptionsTestClient.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/OptionsTestClient.java deleted file mode 100644 index b99bf6fcc..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/OptionsTestClient.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import feign.Client; -import feign.Request; -import feign.Response; - -/** - * @author Jasbir Singh - */ -public class OptionsTestClient implements Client { - - private final static ObjectMapper mapper; - - static { - mapper = new ObjectMapper(); - mapper.registerModule(new JavaTimeModule()).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - } - - @Override - public Response execute(Request request, Request.Options options) { - return Response.builder().status(200).request(request).headers(headers()).body(prepareResponse(options)) - .build(); - } - - private Map> headers() { - Map> headers = new LinkedHashMap<>(); - headers.put("Content-Type", Collections.singletonList("application/json")); - return headers; - } - - private byte[] prepareResponse(Request.Options options) { - try { - - OptionsResponseForTests response = new OptionsResponseForTests(options.connectTimeoutMillis(), - TimeUnit.MILLISECONDS, options.readTimeoutMillis(), TimeUnit.MILLISECONDS); - return mapper.writeValueAsString(response).getBytes(); - } - catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - record OptionsResponseForTests(long connectTimeout, TimeUnit connectTimeoutUnit, long readTimeout, - TimeUnit readTimeoutUnit) { - - @Override - public String toString() { - return "OptionsResponseForTests{" + "connectTimeout=" + connectTimeout + ", connectTimeoutUnit=" - + connectTimeoutUnit + ", readTimeout=" + readTimeout + ", readTimeoutUnit=" + readTimeoutUnit - + '}'; - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/RefreshableFeignClientUrlTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/RefreshableFeignClientUrlTests.java deleted file mode 100644 index 836fa1f60..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/RefreshableFeignClientUrlTests.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import feign.Target; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.context.scope.refresh.RefreshScope; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.TestPropertySource; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Jasbir Singh - */ -@SpringBootTest -@TestPropertySource("classpath:feign-refreshable-properties.properties") -@DirtiesContext -class RefreshableFeignClientUrlTests { - - @Autowired - private ApplicationContext applicationContext; - - @Autowired - private RefreshScope refreshScope; - - @Autowired - private RefreshableFeignClientUrlTests.Application.RefreshableClientWithFixUrl refreshableClientWithFixUrl; - - @Autowired - private RefreshableFeignClientUrlTests.Application.RefreshableUrlClient refreshableUrlClient; - - @Autowired - private Application.RefreshableUrlClientForContextRefreshCase refreshableUrlClientForContextRefreshCase; - - @Autowired - private Application.NameBasedUrlClient nameBasedUrlClient; - - @Autowired - private FeignClientProperties clientProperties; - - @Test - void shouldInstantiateFeignClientWhenUrlFromFeignClientUrl() { - UrlTestClient.UrlResponseForTests response = refreshableClientWithFixUrl.fixPath(); - assertThat(response.getUrl()).isEqualTo("http://localhost:8081/fixPath"); - assertThat(response.getTargetType()).isEqualTo(Target.HardCodedTarget.class); - } - - @Test - void shouldInstantiateFeignClientWhenUrlFromFeignClientUrlGivenPreferenceOverProperties() { - UrlTestClient.UrlResponseForTests response = refreshableClientWithFixUrl.fixPath(); - assertThat(response.getUrl()).isEqualTo("http://localhost:8081/fixPath"); - } - - @Test - public void shouldInstantiateFeignClientWhenUrlFromProperties() { - UrlTestClient.UrlResponseForTests response = refreshableUrlClient.refreshable(); - assertThat(response.getUrl()).isEqualTo("http://localhost:8082/refreshable"); - assertThat(response.getTargetType()).isEqualTo(RefreshableHardCodedTarget.class); - } - - @Test - void shouldInstantiateFeignClientWhenUrlFromPropertiesAndThenUpdateUrlWhenContextRefresh() { - UrlTestClient.UrlResponseForTests response = refreshableUrlClientForContextRefreshCase.refreshable(); - assertThat(response.getUrl()).isEqualTo("http://localhost:8080/refreshable"); - - clientProperties.getConfig().get("refreshableClient").setUrl("http://localhost:8888/"); - refreshScope.refreshAll(); - response = refreshableUrlClient.refreshable(); - assertThat(response.getUrl()).isEqualTo("http://localhost:8888/refreshable"); - } - - @Test - void shouldInstantiateFeignClientWhenUrlFromFeignClientName() { - UrlTestClient.UrlResponseForTests response = nameBasedUrlClient.nonRefreshable(); - assertThat(response.getUrl()).isEqualTo("http://nameBasedClient/nonRefreshable"); - assertThat(response.getTargetType()).isEqualTo(Target.HardCodedTarget.class); - } - - @Configuration - @EnableAutoConfiguration - @EnableConfigurationProperties(FeignClientProperties.class) - @EnableFeignClients(clients = { Application.RefreshableUrlClient.class, Application.NameBasedUrlClient.class, - Application.RefreshableClientWithFixUrl.class, - Application.RefreshableUrlClientForContextRefreshCase.class }) - protected static class Application { - - @Bean - UrlTestClient client() { - return new UrlTestClient(); - } - - @FeignClient(name = "refreshableClientWithFixUrl", url = "http://localhost:8081") - protected interface RefreshableClientWithFixUrl { - - @GetMapping("/fixPath") - UrlTestClient.UrlResponseForTests fixPath(); - - } - - @FeignClient(name = "refreshableClient") - protected interface RefreshableUrlClient { - - @GetMapping("/refreshable") - UrlTestClient.UrlResponseForTests refreshable(); - - } - - @FeignClient(name = "refreshableClientForContextRefreshCase") - protected interface RefreshableUrlClientForContextRefreshCase { - - @GetMapping("/refreshable") - UrlTestClient.UrlResponseForTests refreshable(); - - } - - @FeignClient(name = "nameBasedClient") - protected interface NameBasedUrlClient { - - @GetMapping("/nonRefreshable") - UrlTestClient.UrlResponseForTests nonRefreshable(); - - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/SpringDecoderTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/SpringDecoderTests.java deleted file mode 100644 index bc975bab9..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/SpringDecoderTests.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Spencer Gibb - * @author Olga Maciaszek-Sharma - * @author Szymon Linowski - */ -@SpringBootTest(classes = SpringDecoderTests.Application.class, webEnvironment = WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=springdecodertest", "spring.jmx.enabled=false" }) -@DirtiesContext -class SpringDecoderTests extends FeignClientFactoryBean { - - @Autowired - FeignClientFactory context; - - @LocalServerPort - private int port = 0; - - SpringDecoderTests() { - setName("test"); - setContextId("test"); - } - - public TestClient testClient() { - return testClient(false); - } - - public TestClient testClient(boolean dismiss404) { - setType(this.getClass()); - setDismiss404(dismiss404); - return feign(this.context).target(TestClient.class, "http://localhost:" + this.port); - } - - @Test - void testResponseEntity() { - ResponseEntity response = testClient().getHelloResponse(); - assertThat(response).as("response was null").isNotNull(); - assertThat(response.getStatusCode()).as("wrong status code").isEqualTo(HttpStatus.OK); - Hello hello = response.getBody(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world via response")); - } - - @Test - void testSimpleType() { - Hello hello = testClient().getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - } - - @Test - void testUserParameterizedTypeDecode() { - List hellos = testClient().getHellos(); - assertThat(hellos).as("hellos was null").isNotNull(); - assertThat(hellos.size()).as("hellos was not the right size").isEqualTo(2); - assertThat(hellos.get(0)).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - } - - @Test - void testSimpleParameterizedTypeDecode() { - List hellos = testClient().getHelloStrings(); - assertThat(hellos).as("hellos was null").isNotNull(); - assertThat(hellos.size()).as("hellos was not the right size").isEqualTo(2); - assertThat(hellos.get(0)).as("first hello didn't match").isEqualTo("hello world 1"); - } - - @Test - @SuppressWarnings("unchecked") - void testWildcardTypeDecode() { - ResponseEntity wildcard = testClient().getWildcard(); - assertThat(wildcard).as("wildcard was null").isNotNull(); - assertThat(wildcard.getStatusCode()).as("wrong status code").isEqualTo(HttpStatus.OK); - Object wildcardBody = wildcard.getBody(); - assertThat(wildcardBody).as("wildcardBody was null").isNotNull(); - assertThat(wildcardBody instanceof Map).as("wildcard not an instance of Map").isTrue(); - Map hello = (Map) wildcardBody; - assertThat(hello.get("message")).as("first hello didn't match").isEqualTo("wildcard"); - } - - @Test - void testResponseEntityVoid() { - ResponseEntity response = testClient().getHelloVoid(); - assertThat(response).as("response was null").isNotNull(); - List headerVals = response.getHeaders().get("x-test-header"); - assertThat(headerVals).as("headerVals was null").isNotNull(); - assertThat(headerVals.size()).as("headerVals size was wrong").isEqualTo(1); - String header = headerVals.get(0); - assertThat(header).as("header was wrong").isEqualTo("myval"); - } - - @Test - void test404() { - Assertions.assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> testClient().getNotFound()); - } - - @Test - void testDecodes404() { - final ResponseEntity response = testClient(true).getNotFound(); - assertThat(response).as("response was null").isNotNull(); - assertThat(response.getBody()).as("response body was not null").isNull(); - } - - @Test - // Issue: https://github.com/spring-cloud/spring-cloud-openfeign/issues/456 - void testResponseEntityHeaders() { - ResponseEntity response = testClient().getContentType(); - assertThat(response.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_JSON); - } - - protected interface TestClient { - - @GetMapping("/helloresponse") - ResponseEntity getHelloResponse(); - - @GetMapping("/hellovoid") - ResponseEntity getHelloVoid(); - - @GetMapping("/hello") - Hello getHello(); - - @GetMapping("/hellos") - List getHellos(); - - @GetMapping("/hellostrings") - List getHelloStrings(); - - @GetMapping("/hellonotfound") - ResponseEntity getNotFound(); - - @GetMapping("/helloWildcard") - ResponseEntity getWildcard(); - - @GetMapping(path = "/contentType", produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity getContentType(); - - } - - public static class Hello { - - private String message; - - Hello() { - } - - Hello(String message) { - this.message = message; - } - - public String getMessage() { - return this.message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Hello that = (Hello) o; - return Objects.equals(this.message, that.message); - } - - @Override - public int hashCode() { - return Objects.hash(this.message); - } - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @Import(NoSecurityConfiguration.class) - protected static class Application implements TestClient { - - @Override - public ResponseEntity getHelloResponse() { - return ResponseEntity.ok(new Hello("hello world via response")); - } - - @Override - public ResponseEntity getHelloVoid() { - return ResponseEntity.noContent().header("X-test-header", "myval").build(); - } - - @Override - public Hello getHello() { - return new Hello("hello world 1"); - } - - @Override - public List getHellos() { - ArrayList hellos = new ArrayList<>(); - hellos.add(new Hello("hello world 1")); - hellos.add(new Hello("oi terra 2")); - return hellos; - } - - @Override - public List getHelloStrings() { - ArrayList hellos = new ArrayList<>(); - hellos.add("hello world 1"); - hellos.add("oi terra 2"); - return hellos; - } - - @Override - public ResponseEntity getNotFound() { - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); - } - - @Override - public ResponseEntity getWildcard() { - return ResponseEntity.ok(new Hello("wildcard")); - } - - @Override - public ResponseEntity getContentType() { - return ResponseEntity.ok().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).body("test"); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/UrlTestClient.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/UrlTestClient.java deleted file mode 100644 index 3d1d5277c..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/UrlTestClient.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import feign.Client; -import feign.Request; -import feign.Response; - -/** - * @author Jasbir Singh - */ -public class UrlTestClient implements Client { - - protected static ObjectMapper mapper; - - static { - mapper = new ObjectMapper(); - mapper.registerModule(new JavaTimeModule()).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - } - - @Override - public Response execute(Request request, Request.Options options) { - return Response.builder().status(200).request(request).headers(headers()).body(prepareResponse(request)) - .build(); - } - - private Map> headers() { - Map> headers = new LinkedHashMap<>(); - headers.put("Content-Type", Collections.singletonList("application/json")); - return headers; - } - - private byte[] prepareResponse(Request request) { - try { - UrlResponseForTests response = new UrlResponseForTests(request.url(), - request.requestTemplate().feignTarget().getClass()); - return mapper.writeValueAsString(response).getBytes(); - } - catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - static class UrlResponseForTests { - - private String url; - - private Class targetType; - - UrlResponseForTests() { - } - - UrlResponseForTests(String url, Class targetType) { - this.url = url; - this.targetType = targetType; - } - - void setUrl(String url) { - this.url = url; - } - - public String getUrl() { - return url; - } - - public Class getTargetType() { - return targetType; - } - - public void setTargetType(Class targetType) { - this.targetType = targetType; - } - - @Override - public String toString() { - return "UrlResponseForTests{" + "url='" + url + '\'' + ", targetType=" + targetType + '}'; - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/aot/FeignAotTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/aot/FeignAotTests.java deleted file mode 100644 index 34c2d8f8a..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/aot/FeignAotTests.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2022-2022 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.aot; - -import java.net.URL; - -import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import org.springframework.aot.AotDetector; -import org.springframework.aot.test.generate.TestGenerationContext; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration; -import org.springframework.boot.context.annotation.UserConfigurations; -import org.springframework.boot.test.context.runner.WebApplicationContextRunner; -import org.springframework.boot.test.system.CapturedOutput; -import org.springframework.boot.test.system.OutputCaptureExtension; -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext; -import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignAutoConfiguration; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.context.ApplicationContextInitializer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.aot.ApplicationContextAotGenerator; -import org.springframework.context.support.GenericApplicationContext; -import org.springframework.core.test.tools.CompileWithForkedClassLoader; -import org.springframework.core.test.tools.TestCompiler; -import org.springframework.javapoet.ClassName; -import org.springframework.test.util.ReflectionTestUtils; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * AOT processing tests. - * - * @author Olga Maciaszek-Sharma - */ -@ExtendWith(OutputCaptureExtension.class) -public class FeignAotTests { - - private static final Log LOG = LogFactory.getLog(FeignAotTests.class); - - @BeforeEach - @AfterEach - void reset() { - ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance", null); - ReflectionTestUtils.setField(URL.class, "factory", null); - } - - @Test - @CompileWithForkedClassLoader - @SuppressWarnings("unchecked") - void shouldStartFeignChildContextsFromAotContributions(CapturedOutput output) { - WebApplicationContextRunner contextRunner = new WebApplicationContextRunner( - AnnotationConfigServletWebApplicationContext::new) - .withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class, - FeignAutoConfiguration.class)) - .withConfiguration(UserConfigurations.of(TestFeignConfiguration.class)) - .withPropertyValues("logging.level.org.springframework.cloud=DEBUG"); - contextRunner.prepare(context -> { - TestGenerationContext generationContext = new TestGenerationContext(TestTarget.class); - ClassName className = new ApplicationContextAotGenerator().processAheadOfTime( - (GenericApplicationContext) context.getSourceApplicationContext(), generationContext); - generationContext.writeGeneratedContent(); - TestCompiler compiler = TestCompiler.forSystem(); - compiler.with(generationContext).compile(compiled -> { - ServletWebServerApplicationContext freshApplicationContext = new ServletWebServerApplicationContext(); - ApplicationContextInitializer initializer = compiled - .getInstance(ApplicationContextInitializer.class, className.toString()); - initializer.initialize(freshApplicationContext); - assertThat(output).contains("Creating a FeignClientFactoryBean."); - assertThat(output).contains("Refreshing FeignClientFactory-test-with-config", - "Refreshing FeignClientFactory-test"); - assertThat(output).doesNotContain("Instantiating bean from Test custom config", - "Instantiating bean from default custom config"); - TestPropertyValues.of(AotDetector.AOT_ENABLED + "=true") - .applyToSystemProperties(freshApplicationContext::refresh); - assertThat(output).contains("Instantiating bean from Test custom config", - "Instantiating bean from default custom config"); - assertThat(freshApplicationContext.getBean(TestFeignClient.class)).isNotNull(); - assertThat(freshApplicationContext.getBean(TestFeignClientWithConfig.class)).isNotNull(); - }); - }); - } - - static class TestTarget { - - } - - @Configuration(proxyBeanMethods = false) - @EnableFeignClients(clients = { TestFeignClient.class, TestFeignClientWithConfig.class }, - defaultConfiguration = DefaultConfiguration.class) - public static class TestFeignConfiguration { - - @Autowired - TestFeignClient testFeignClient; - - @Autowired - TestFeignClientWithConfig testFeignClientWithConfig; - - } - - public static class TestConfiguration { - - @Bean - TestBean testBean() { - if (LOG.isDebugEnabled()) { - LOG.debug("Instantiating bean from Test custom config"); - } - return new TestBean(); - } - - } - - public static class DefaultConfiguration { - - @Bean - TestBean defaultTestBean() { - if (LOG.isDebugEnabled()) { - LOG.debug("Instantiating bean from default custom config"); - } - return new TestBean(); - } - - } - - public static class TestBean { - - } - - @FeignClient(value = "test", dismiss404 = true, url = "http://example.com") - interface TestFeignClient { - - @GetMapping - void test(); - - } - - @FeignClient(value = "test-with-config", configuration = TestConfiguration.class) - interface TestFeignClientWithConfig { - - @GetMapping - void test(); - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/aot/FeignClientBeanFactoryInitializationAotProcessorTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/aot/FeignClientBeanFactoryInitializationAotProcessorTests.java deleted file mode 100644 index 80988c57e..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/aot/FeignClientBeanFactoryInitializationAotProcessorTests.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright 2022-2023 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.aot; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.aot.generate.GeneratedClass; -import org.springframework.aot.generate.GeneratedMethods; -import org.springframework.aot.generate.GenerationContext; -import org.springframework.aot.generate.MethodReference; -import org.springframework.aot.hint.RuntimeHints; -import org.springframework.aot.test.generate.TestGenerationContext; -import org.springframework.beans.MutablePropertyValues; -import org.springframework.beans.PropertyValue; -import org.springframework.beans.PropertyValues; -import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution; -import org.springframework.beans.factory.aot.BeanFactoryInitializationCode; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.ConstructorArgumentValues; -import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.factory.support.GenericBeanDefinition; -import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.FeignClientFactory; -import org.springframework.cloud.openfeign.FeignClientSpecification; -import org.springframework.context.support.GenericApplicationContext; -import org.springframework.javapoet.TypeSpec; -import org.springframework.web.bind.annotation.PostMapping; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.springframework.aot.hint.predicate.RuntimeHintsPredicates.proxies; -import static org.springframework.aot.hint.predicate.RuntimeHintsPredicates.reflection; - -/** - * Tests for {@link FeignClientBeanFactoryInitializationAotProcessor}. - * - * @author Olga Maciaszek-Sharma - */ -class FeignClientBeanFactoryInitializationAotProcessorTests { - - private static final String BEAN_DEFINITION_CLASS_NAME = "org.springframework.cloud.openfeign.aot.FeignClientBeanFactoryInitializationAotProcessorTests$TestClient"; - - private final TestGenerationContext generationContext = new TestGenerationContext(); - - private final FeignClientFactory feignClientFactory = mock(FeignClientFactory.class); - - private final BeanFactoryInitializationCode beanFactoryInitializationCode = new MockBeanFactoryInitializationCode( - generationContext); - - @BeforeEach - void setUp() { - Map configurations = Map.of("test", - new FeignClientSpecification("test", TestClient.class.getCanonicalName(), new Class[] {})); - when(feignClientFactory.getConfigurations()).thenReturn(configurations); - - } - - @Test - void shouldGenerateBeanInitializationCodeAndRegisterHints() { - DefaultListableBeanFactory beanFactory = beanFactory(); - GenericApplicationContext context = new GenericApplicationContext(beanFactory); - FeignClientBeanFactoryInitializationAotProcessor processor = new FeignClientBeanFactoryInitializationAotProcessor( - context, feignClientFactory); - - BeanFactoryInitializationAotContribution contribution = processor.processAheadOfTime(beanFactory); - assertThat(contribution).isNotNull(); - - verifyContribution((FeignClientBeanFactoryInitializationAotProcessor.AotContribution) contribution); - contribution.applyTo(generationContext, beanFactoryInitializationCode); - - RuntimeHints hints = generationContext.getRuntimeHints(); - assertThat(reflection().onType(TestReturnType.class)).accepts(hints); - assertThat(reflection().onType(TestArgType.class)).accepts(hints); - assertThat(proxies().forInterfaces(TestClient.class)).accepts(hints); - } - - private static void verifyContribution( - FeignClientBeanFactoryInitializationAotProcessor.AotContribution contribution) { - BeanDefinition contributionBeanDefinition = contribution.getFeignClientBeanDefinitions() - .get(TestClient.class.getCanonicalName()); - assertThat(contributionBeanDefinition.getBeanClassName()).isEqualTo(BEAN_DEFINITION_CLASS_NAME); - PropertyValues propertyValues = contributionBeanDefinition.getPropertyValues(); - assertThat(propertyValues).isNotEmpty(); - assertThat(((String[]) propertyValues.getPropertyValue("qualifiers").getValue())).containsExactly("test"); - assertThat(propertyValues.getPropertyValue("type").getValue()).isEqualTo(TestClient.class.getCanonicalName()); - assertThat(propertyValues.getPropertyValue("fallback").getValue()).isEqualTo(String.class); - } - - private DefaultListableBeanFactory beanFactory() { - GenericBeanDefinition beanDefinition = new GenericBeanDefinition(new RootBeanDefinition(TestClient.class, - new ConstructorArgumentValues(), - new MutablePropertyValues(List.of(new PropertyValue("type", TestClient.class.getCanonicalName()), - new PropertyValue("qualifiers", new String[] { "test" }), - new PropertyValue("fallback", String.class), - new PropertyValue("fallbackFactory", Void.class))))); - DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - beanFactory.registerBeanDefinition(TestClient.class.getCanonicalName(), beanDefinition); - return beanFactory; - } - - @FeignClient - interface TestClient { - - @PostMapping("/test") - TestReturnType test(TestArgType arg); - - } - - @SuppressWarnings("NullableProblems") - static class MockBeanFactoryInitializationCode implements BeanFactoryInitializationCode { - - private static final Consumer emptyTypeCustomizer = type -> { - }; - - private final GeneratedClass generatedClass; - - MockBeanFactoryInitializationCode(GenerationContext generationContext) { - generatedClass = generationContext.getGeneratedClasses().addForFeature("Test", emptyTypeCustomizer); - } - - @Override - public GeneratedMethods getMethods() { - return generatedClass.getMethods(); - } - - @Override - public void addInitializer(MethodReference methodReference) { - new ArrayList<>(); - } - - } - - static class TestReturnType { - - private String test; - - TestReturnType(String test) { - this.test = test; - } - - TestReturnType() { - } - - String getTest() { - return test; - } - - void setTest(String test) { - this.test = test; - } - - } - - static class TestArgType { - - private String test; - - TestArgType(String test) { - this.test = test; - } - - TestArgType() { - } - - String getTest() { - return test; - } - - void setTest(String test) { - this.test = test; - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/BeansFeignClientTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/BeansFeignClientTests.java deleted file mode 100644 index 0adcdb223..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/BeansFeignClientTests.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2013-2022 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.beans; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Proxy; -import java.util.Map; -import java.util.Objects; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -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.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.FeignClientBuilder; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Dave Syer - * @author Spencer Gibb - * @author Jakub Narloch - * @author Erik Kringen - * @author Halvdan Hoem Grelland - * @author Aaron Whiteside - */ -@SpringBootTest(classes = BeansFeignClientTests.Application.class, webEnvironment = WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=feignclienttest", "spring.cloud.openfeign.httpclient.hc5.enabled=false", - "spring.cloud.openfeign.okhttp.enabled=false" }) -@DirtiesContext -public class BeansFeignClientTests { - - @Value("${local.server.port}") - private int port = 0; - - @Autowired - private TestClient testClient; - - @Autowired - private ApplicationContext context; - - @Qualifier("uniquequalifier") - @Autowired - private org.springframework.cloud.openfeign.beans.extra.TestClient extraClient; - - @Qualifier("build-by-builder") - @Autowired - private TestClient buildByBuilder; - - @Test - void testAnnotations() { - Map beans = this.context.getBeansWithAnnotation(FeignClient.class); - assertThat(beans.containsKey(TestClient.class.getName())).as("Wrong clients: " + beans).isTrue(); - } - - @Test - void testClient() { - assertThat(this.testClient).as("testClient was null").isNotNull(); - assertThat(this.extraClient).as("extraClient was null").isNotNull(); - assertThat(Proxy.isProxyClass(this.testClient.getClass())).as("testClient is not a java Proxy").isTrue(); - InvocationHandler invocationHandler = Proxy.getInvocationHandler(this.testClient); - assertThat(invocationHandler).as("invocationHandler was null").isNotNull(); - } - - @Test - void extraClient() { - assertThat(this.extraClient).as("extraClient was null").isNotNull(); - assertThat(Proxy.isProxyClass(this.extraClient.getClass())).as("extraClient is not a java Proxy").isTrue(); - InvocationHandler invocationHandler = Proxy.getInvocationHandler(this.extraClient); - assertThat(invocationHandler).as("invocationHandler was null").isNotNull(); - } - - @Test - void buildByBuilder() { - assertThat(this.buildByBuilder).as("buildByBuilder was null").isNotNull(); - assertThat(Proxy.isProxyClass(this.buildByBuilder.getClass())).as("buildByBuilder is not a java Proxy") - .isTrue(); - InvocationHandler invocationHandler = Proxy.getInvocationHandler(this.buildByBuilder); - assertThat(invocationHandler).as("invocationHandler was null").isNotNull(); - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients - @Import(FeignClientBuilder.class) - protected static class Application { - - @Bean("build-by-builder") - public TestClient buildByBuilder(final FeignClientBuilder feignClientBuilder) { - return feignClientBuilder.forType(TestClient.class, "builderapp").build(); - } - - @GetMapping("/hello") - public Hello getHello() { - return new Hello("hello world 1"); - } - - } - - public static class Hello { - - private String message; - - Hello() { - } - - Hello(String message) { - this.message = message; - } - - public String getMessage() { - return this.message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Hello that = (Hello) o; - - return Objects.equals(this.message, that.message); - } - - @Override - public int hashCode() { - return this.message != null ? this.message.hashCode() : 0; - } - - } - - @Configuration(proxyBeanMethods = false) - public static class TestDefaultFeignConfig { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/FeignClientMockBeanTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/FeignClientMockBeanTests.java deleted file mode 100644 index e412a42e8..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/FeignClientMockBeanTests.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2013-2022 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.beans; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; - -/** - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(classes = FeignClientMockBeanTests.Config.class) -public class FeignClientMockBeanTests { - - @MockBean - private RandomClient randomClient; - - @Autowired - private TestService testService; - - @Test - public void randomClientShouldBeMocked() { - String mockMessage = "Mocked Feign Client"; - when(randomClient.getRandomString()).thenReturn(mockMessage); - - String returnedMessage = testService.testMethod(); - - assertThat(returnedMessage).isEqualTo(mockMessage); - } - - @FeignClient("random-test") - protected interface RandomClient { - - @GetMapping("/random-test") - String getRandomString(); - - } - - @Configuration - protected static class Config { - - @Bean - TestService testService() { - return new TestService(); - } - - } - -} - -class TestService { - - @Autowired - private FeignClientMockBeanTests.RandomClient randomClient; - - public String testMethod() { - return randomClient.getRandomString(); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/TestClient.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/TestClient.java deleted file mode 100644 index a8b433257..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/TestClient.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2013-2022 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.beans; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.beans.BeansFeignClientTests.Hello; -import org.springframework.context.annotation.Primary; -import org.springframework.web.bind.annotation.GetMapping; - -@Primary -@FeignClient("localapp") -public interface TestClient { - - @GetMapping("/hello") - Hello getHello(); - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/extra/TestClient.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/extra/TestClient.java deleted file mode 100644 index 8202aea3a..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/beans/extra/TestClient.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013-2022 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.beans.extra; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.beans.BeansFeignClientTests.Hello; -import org.springframework.web.bind.annotation.GetMapping; - -@FeignClient(value = "otherapp", qualifiers = { "uniquequalifier" }) -public interface TestClient { - - @GetMapping("/hello") - Hello getHello(); - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/AsyncCircuitBreaker.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/AsyncCircuitBreaker.java deleted file mode 100644 index ec317a6ff..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/AsyncCircuitBreaker.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2013-2022 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.circuitbreaker; - -import java.time.Duration; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.function.Function; -import java.util.function.Supplier; - -import org.springframework.cloud.client.circuitbreaker.CircuitBreaker; - -/** - * Asynchronous circuit breaker. - * - * @author John Niang - */ -class AsyncCircuitBreaker implements CircuitBreaker { - - final Duration timeout; - - final ExecutorService executorService; - - AsyncCircuitBreaker(Duration timeout) { - this(timeout, Executors.newCachedThreadPool()); - } - - AsyncCircuitBreaker(Duration timeout, ExecutorService executorService) { - this.timeout = timeout; - this.executorService = executorService; - } - - @Override - public T run(Supplier toRun, Function fallback) { - Future future = executorService.submit(toRun::get); - try { - return future.get(timeout.toMillis(), TimeUnit.MILLISECONDS); - } - catch (Throwable t) { - return fallback.apply(t); - } - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/AsyncCircuitBreakerTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/AsyncCircuitBreakerTests.java deleted file mode 100644 index 87ae8a0ea..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/AsyncCircuitBreakerTests.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 2013-2022 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.circuitbreaker; - -import java.time.Duration; -import java.util.Objects; -import java.util.UUID; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.function.Function; - -import feign.RequestInterceptor; -import jakarta.servlet.http.HttpServletRequest; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.client.circuitbreaker.CircuitBreaker; -import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; -import org.springframework.cloud.client.circuitbreaker.ConfigBuilder; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.http.HttpHeaders; -import org.springframework.scheduling.concurrent.CustomizableThreadFactory; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -/** - * Tests for asynchronous circuit breaker. - * - * @author John Niang - */ -@SpringBootTest(classes = AsyncCircuitBreakerTests.Application.class, webEnvironment = RANDOM_PORT, - properties = { "spring.cloud.openfeign.circuitbreaker.enabled=true", - "spring.cloud.openfeign.lazy-attributes-resolution=true" }) -@AutoConfigureMockMvc -class AsyncCircuitBreakerTests { - - @Autowired - MockMvc mvc; - - @Autowired - @Qualifier("asyncWorker") - ExecutorService asyncCircuitBreakerExecutor; - - @Test - void shouldWorkNormally() throws Exception { - mvc.perform(get("/hello/proxy")).andDo(print()).andExpect(status().isOk()) - .andExpect(content().string("openfeign")); - } - - @Test - void shouldNotProxyAnyHeadersWithoutHeaderSet() throws Exception { - mvc.perform(get("/headers/" + HttpHeaders.AUTHORIZATION + "/proxy")).andDo(print()).andExpect(status().isOk()) - .andExpect(content().string("")); - } - - @Test - void shouldProxyHeaderWhenHeaderSet() throws Exception { - String authorization = UUID.randomUUID().toString(); - mvc.perform(get("/headers/" + HttpHeaders.AUTHORIZATION + "/proxy").header(HttpHeaders.AUTHORIZATION, - authorization)).andDo(print()).andExpect(status().isOk()).andExpect(content().string(authorization)); - } - - @Test - void shouldProxyHeaderWhenHeaderSetAndCleanRequestAttributesAfterReturn() throws Exception { - shouldNotProxyAnyHeadersWithoutHeaderSet(); - Future future = asyncCircuitBreakerExecutor - .submit(() -> (ServletRequestAttributes) RequestContextHolder.getRequestAttributes()); - assertThat(future.get()).as("the RequestAttributes has been cleared").isNull(); - } - - @EnableAutoConfiguration - @Configuration(proxyBeanMethods = false) - @EnableFeignClients(clients = { TestClient.class }) - @Import({ NoSecurityConfiguration.class, TestController.class }) - static class Application { - - @Bean(name = "asyncWorker", destroyMethod = "shutdown") - ExecutorService asyncCircuitBreakerExecutor() { - return Executors.newSingleThreadExecutor(new CustomizableThreadFactory("async")); - } - - @Bean - CircuitBreakerFactory> circuitBreakerFactory( - @Qualifier("asyncWorker") ExecutorService asyncCircuitBreakerExecutor) { - return new CircuitBreakerFactory<>() { - - Function defaultConfiguration = id -> Duration.ofMillis(1000); - - @Override - public CircuitBreaker create(String id) { - Duration timeout = super.getConfigurations().computeIfAbsent(id, defaultConfiguration); - return new AsyncCircuitBreaker(timeout, asyncCircuitBreakerExecutor); - } - - @Override - protected ConfigBuilder configBuilder(String id) { - return () -> Duration.ofMillis(100); - } - - @Override - public void configureDefault(Function defaultConfiguration) { - this.defaultConfiguration = defaultConfiguration; - } - }; - } - - @Bean - RequestInterceptor proxyHeaderRequestInterceptor() { - return template -> { - ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder - .getRequestAttributes(); - String authorization = Objects.requireNonNull(requestAttributes).getRequest() - .getHeader(HttpHeaders.AUTHORIZATION); - if (authorization != null) { - // proxy authorization header - template.header(HttpHeaders.AUTHORIZATION, authorization); - } - }; - } - - } - - @RestController - static class TestController { - - final ObjectProvider testClient; - - TestController(ObjectProvider testClient) { - this.testClient = testClient; - } - - @GetMapping("/hello") - String hello() { - return "openfeign"; - } - - @GetMapping("/hello/proxy") - String helloProxy() { - return testClient.getObject().hello(); - } - - @GetMapping("/headers/{headerName}") - String header(HttpServletRequest request, @PathVariable String headerName) { - return request.getHeader(headerName); - } - - @GetMapping("/headers/{headerName}/proxy") - String headerProxy(@PathVariable String headerName) { - return testClient.getObject().header(headerName); - } - - } - - @FeignClient(name = "async-circuit-breaker-test", url = "http://localhost:${local.server.port}") - interface TestClient { - - @GetMapping("/hello") - String hello(); - - @GetMapping("/headers/{headerName}") - String header(@PathVariable String headerName); - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerAutoConfigurationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerAutoConfigurationTests.java deleted file mode 100644 index 5ad937ec2..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerAutoConfigurationTests.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2013-2022 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.circuitbreaker; - -import feign.Target; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.openfeign.CircuitBreakerNameResolver; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * @author Ryan Baxter - */ -public class CircuitBreakerAutoConfigurationTests { - - @SpringBootTest(classes = CircuitBreakerTests.Application.class, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=springcircuittest", "spring.jmx.enabled=false", - "spring.cloud.openfeign.circuitbreaker.enabled=true", - "spring.cloud.openfeign.circuitbreaker.alphanumeric-ids.enabled=false" }) - @Nested - class DefaultNamingStrategy { - - @Autowired - CircuitBreakerNameResolver nameResolver; - - @SuppressWarnings("rawtypes") - @Test - public void assertDefaultNamingStrategy() throws Exception { - Target target = mock(Target.class); - when(target.type()).thenReturn(CircuitBreakerTests.TestClientWithFactory.class); - assertThat(nameResolver.resolveCircuitBreakerName("foo", target, - CircuitBreakerTests.TestClientWithFactory.class.getMethod("getHello"))) - .isEqualTo("TestClientWithFactory#getHello()"); - } - - } - - @SpringBootTest(classes = CircuitBreakerTests.Application.class, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=springcircuittest", "spring.jmx.enabled=false", - "spring.cloud.openfeign.circuitbreaker.enabled=true" }) - @Nested - class AlphanumericNamingStrategy { - - @Autowired - CircuitBreakerNameResolver nameResolver; - - @SuppressWarnings("rawtypes") - @Test - public void assertAlphanumericNamingStrategy() throws Exception { - Target target = mock(Target.class); - when(target.type()).thenReturn(CircuitBreakerTests.TestClientWithFactory.class); - assertThat(nameResolver.resolveCircuitBreakerName("foo", target, - CircuitBreakerTests.TestClientWithFactory.class.getMethod("getHello"))) - .isEqualTo("TestClientWithFactorygetHello"); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerTests.java deleted file mode 100644 index e9d9ff57b..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerTests.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright 2013-2022 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.circuitbreaker; - -import java.io.IOException; -import java.util.function.Function; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -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.client.circuitbreaker.CircuitBreaker; -import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; -import org.springframework.cloud.client.circuitbreaker.ConfigBuilder; -import org.springframework.cloud.client.circuitbreaker.NoFallbackAvailableException; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FallbackFactory; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.cloud.test.TestSocketUtils; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.stereotype.Component; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * @author Spencer Gibb - */ -@SpringBootTest(classes = CircuitBreakerTests.Application.class, webEnvironment = WebEnvironment.DEFINED_PORT, - value = { "spring.application.name=springcircuittest", "spring.jmx.enabled=false", - "spring.cloud.openfeign.circuitbreaker.enabled=true" }) -@DirtiesContext -class CircuitBreakerTests { - - @Autowired - MyCircuitBreaker myCircuitBreaker; - - @Autowired - TestClient testClient; - - @Autowired - ExceptionClient exceptionClient; - - @Autowired - TestClientWithFactory testClientWithFactory; - - @BeforeAll - static void beforeClass() { - System.setProperty("server.port", String.valueOf(TestSocketUtils.findAvailableTcpPort())); - } - - @AfterAll - static void afterClass() { - System.clearProperty("server.port"); - } - - @BeforeEach - void setup() { - this.myCircuitBreaker.clear(); - } - - @Test - void testSimpleTypeWithFallback() { - Hello hello = testClient.getHello(); - - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - assertThat(myCircuitBreaker.runWasCalled).as("Circuit Breaker was called").isTrue(); - } - - @Test - void test404WithFallback() { - assertThat(testClient.getException()).isEqualTo("Fixed response"); - } - - @Test - void testSimpleTypeWithFallbackFactory() { - Hello hello = testClientWithFactory.getHello(); - - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - assertThat(myCircuitBreaker.runWasCalled).as("Circuit Breaker was called").isTrue(); - } - - @Test - void test404WithFallbackFactory() { - assertThat(testClientWithFactory.getException()).isEqualTo("Fixed response"); - } - - @Test - void testRuntimeExceptionUnwrapped() { - assertThatExceptionOfType(UnsupportedOperationException.class) - .isThrownBy(() -> exceptionClient.getRuntimeException()); - } - - @Test - void testCheckedExceptionWrapped() { - assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> exceptionClient.getCheckedException()); - } - - @FeignClient(name = "test", url = "http://localhost:${server.port}/", fallback = Fallback.class) - protected interface TestClient { - - @GetMapping("/hello") - Hello getHello(); - - @GetMapping("/hellonotfound") - String getException(); - - } - - @FeignClient(name = "exceptionClient", url = "http://localhost:${server.port}/", - fallbackFactory = ExceptionThrowingFallbackFactory.class) - protected interface ExceptionClient { - - @GetMapping("/runtimeException") - Hello getRuntimeException(); - - @GetMapping("/runtimeException") - Hello getCheckedException() throws IOException; - - } - - @Component - static class Fallback implements TestClient { - - @Override - public Hello getHello() { - throw new NoFallbackAvailableException("Boom!", new RuntimeException()); - } - - @Override - public String getException() { - return "Fixed response"; - } - - } - - @FeignClient(name = "testClientWithFactory", url = "http://localhost:${server.port}/", - fallbackFactory = TestFallbackFactory.class) - protected interface TestClientWithFactory { - - @GetMapping("/hello") - Hello getHello(); - - @GetMapping("/hellonotfound") - String getException(); - - } - - @Component - static class TestFallbackFactory implements FallbackFactory { - - @Override - public FallbackWithFactory create(Throwable cause) { - return new FallbackWithFactory(); - } - - } - - static class ExceptionThrowingFallbackFactory implements FallbackFactory { - - @Override - public ExceptionClient create(Throwable cause) { - return new ExceptionClient() { - @Override - public Hello getRuntimeException() { - throw new UnsupportedOperationException("Not implemented!"); - } - - @Override - public Hello getCheckedException() throws IOException { - throw new IOException(); - } - }; - } - - } - - static class FallbackWithFactory implements TestClientWithFactory { - - @Override - public Hello getHello() { - throw new NoFallbackAvailableException("Boom!", new RuntimeException()); - } - - @Override - public String getException() { - return "Fixed response"; - } - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients(clients = { TestClient.class, TestClientWithFactory.class, ExceptionClient.class }) - @Import(NoSecurityConfiguration.class) - protected static class Application implements TestClient { - - static final Log log = LogFactory.getLog(Application.class); - - @Bean - MyCircuitBreaker myCircuitBreaker() { - return new MyCircuitBreaker(); - } - - @SuppressWarnings("rawtypes") - @Bean - CircuitBreakerFactory circuitBreakerFactory(MyCircuitBreaker myCircuitBreaker) { - return new CircuitBreakerFactory() { - @Override - public CircuitBreaker create(String id) { - log.info("Creating a circuit breaker with id [" + id + "]"); - return myCircuitBreaker; - } - - @Override - protected ConfigBuilder configBuilder(String id) { - return Object::new; - } - - @Override - public void configureDefault(Function defaultConfiguration) { - - } - }; - } - - @Override - public Hello getHello() { - return new Hello("hello world 1"); - } - - @Override - public String getException() { - throw new IllegalStateException("BOOM!"); - } - - @Bean - Fallback fallback() { - return new Fallback(); - } - - @Bean - TestFallbackFactory testFallbackFactory() { - return new TestFallbackFactory(); - } - - @Bean - ExceptionThrowingFallbackFactory exceptionThrowingFallbackFactory() { - return new ExceptionThrowingFallbackFactory(); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerWithNoFallbackTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerWithNoFallbackTests.java deleted file mode 100644 index eb30b8634..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/CircuitBreakerWithNoFallbackTests.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright 2013-2022 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.circuitbreaker; - -import java.util.function.Function; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.client.circuitbreaker.CircuitBreaker; -import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; -import org.springframework.cloud.client.circuitbreaker.ConfigBuilder; -import org.springframework.cloud.client.circuitbreaker.NoFallbackAvailableException; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.cloud.test.TestSocketUtils; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -/** - * Tests for Feign calls with CircuitBreaker, without fallbacks. - * - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(classes = CircuitBreakerWithNoFallbackTests.Application.class, - webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, - value = { "spring.application.name=springcircuittest", "spring.jmx.enabled=false", - "spring.cloud.openfeign.circuitbreaker.enabled=true" }) -@DirtiesContext -public class CircuitBreakerWithNoFallbackTests { - - @Autowired - MyCircuitBreaker myCircuitBreaker; - - @Autowired - CircuitBreakerTestClient testClient; - - @BeforeAll - public static void beforeClass() { - System.setProperty("server.port", String.valueOf(TestSocketUtils.findAvailableTcpPort())); - } - - @AfterAll - public static void afterClass() { - System.clearProperty("server.port"); - } - - @BeforeEach - public void setup() { - this.myCircuitBreaker.clear(); - } - - @Test - public void testSimpleTypeWithFallback() { - Hello hello = testClient.getHello(); - - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - assertThat(myCircuitBreaker.runWasCalled).as("Circuit Breaker was called").isTrue(); - } - - @Test - public void test404WithoutFallback() { - assertThatThrownBy(() -> testClient.getException()).isInstanceOf(NoFallbackAvailableException.class); - } - - @FeignClient(name = "test", url = "http://localhost:${server.port}/") - protected interface CircuitBreakerTestClient { - - @GetMapping("/hello") - Hello getHello(); - - @GetMapping("/hellonotfound") - String getException(); - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients(clients = { CircuitBreakerTestClient.class }) - @Import(NoSecurityConfiguration.class) - protected static class Application implements CircuitBreakerTestClient { - - static final Log log = LogFactory.getLog(Application.class); - - @Bean - MyCircuitBreaker myCircuitBreaker() { - return new MyCircuitBreaker(); - } - - @SuppressWarnings("rawtypes") - @Bean - CircuitBreakerFactory circuitBreakerFactory(MyCircuitBreaker myCircuitBreaker) { - return new CircuitBreakerFactory() { - @Override - public CircuitBreaker create(String id) { - log.info("Creating a circuit breaker with id [" + id + "]"); - return myCircuitBreaker; - } - - @Override - protected ConfigBuilder configBuilder(String id) { - return Object::new; - } - - @Override - public void configureDefault(Function defaultConfiguration) { - - } - }; - } - - @Override - public Hello getHello() { - return new Hello("hello world 1"); - } - - @Override - public String getException() { - throw new IllegalStateException("BOOM!"); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/FallbackSupportFactoryBeanTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/FallbackSupportFactoryBeanTests.java deleted file mode 100644 index 9f2afc41a..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/FallbackSupportFactoryBeanTests.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2013-2023 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.circuitbreaker; - -import java.util.function.Function; -import java.util.function.Supplier; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.FactoryBean; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.cloud.client.circuitbreaker.CircuitBreaker; -import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; -import org.springframework.cloud.client.circuitbreaker.ConfigBuilder; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignAutoConfiguration; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author 黄学敏(huangxuemin) - */ -class FallbackSupportFactoryBeanTests { - - private static final String FACTORY_BEAN_FALLBACK_MESSAGE = "factoryBean fallback message"; - - private static final String ORIGINAL_FALLBACK_MESSAGE = "OriginalFeign fallback message"; - - private final ApplicationContextRunner runner = new ApplicationContextRunner() - .withBean(FactoryBeanFallbackFeignFallback.class).withBean(OriginalFeignFallback.class) - .withConfiguration(AutoConfigurations.of(TestConfiguration.class, FeignAutoConfiguration.class)) - .withBean(CircuitBreakerFactory.class, () -> new CircuitBreakerFactory() { - @Override - public CircuitBreaker create(String id) { - return new CircuitBreaker() { - @Override - public T run(Supplier toRun, Function fallback) { - try { - return toRun.get(); - } - catch (Throwable t) { - return fallback.apply(t); - } - } - }; - } - - @Override - protected ConfigBuilder configBuilder(String id) { - return null; - } - - @Override - public void configureDefault(Function defaultConfiguration) { - - } - }).withPropertyValues("spring.cloud.openfeign.circuitbreaker.enabled=true"); - - @Test - void shouldRunFallbackFromBeanOrFactoryBean() { - runner.run(ctx -> { - assertThat(ctx.getBean(OriginalFeign.class).get().equals(ORIGINAL_FALLBACK_MESSAGE)).isTrue(); - assertThat(ctx.getBean(FactoryBeanFallbackFeign.class).get().equals(FACTORY_BEAN_FALLBACK_MESSAGE)) - .isTrue(); - }); - } - - @Configuration(proxyBeanMethods = false) - @EnableFeignClients(clients = { FallbackSupportFactoryBeanTests.OriginalFeign.class, - FallbackSupportFactoryBeanTests.FactoryBeanFallbackFeign.class }) - @EnableAutoConfiguration - private static class TestConfiguration { - - } - - @FeignClient(name = "original", url = "https://original", fallback = OriginalFeignFallback.class) - interface OriginalFeign { - - @GetMapping("/") - String get(); - - } - - @FeignClient(name = "factoryBean", url = "https://factoryBean", fallback = FactoryBeanFallbackFeignFallback.class) - interface FactoryBeanFallbackFeign { - - @GetMapping("/") - String get(); - - } - - private static class FactoryBeanFallbackFeignFallback implements FactoryBean { - - @Override - public FactoryBeanFallbackFeign getObject() { - return () -> FACTORY_BEAN_FALLBACK_MESSAGE; - } - - @Override - public Class getObjectType() { - return FactoryBeanFallbackFeign.class; - } - - } - - private static class OriginalFeignFallback implements OriginalFeign { - - @Override - public String get() { - return ORIGINAL_FALLBACK_MESSAGE; - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/Hello.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/Hello.java deleted file mode 100644 index 9ca25a3fa..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/Hello.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2013-2022 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.circuitbreaker; - -import java.util.Objects; - -/** - * @author Marcin Grzejszczak - */ -class Hello { - - private String message; - - public Hello() { - } - - public Hello(String message) { - this.message = message; - } - - public String getMessage() { - return this.message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Hello that = (Hello) o; - return Objects.equals(this.message, that.message); - } - - @Override - public int hashCode() { - return Objects.hash(this.message); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/MyCircuitBreaker.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/MyCircuitBreaker.java deleted file mode 100644 index 173d5e31e..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/circuitbreaker/MyCircuitBreaker.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2013-2022 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.circuitbreaker; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Function; -import java.util.function.Supplier; - -import org.springframework.cloud.client.circuitbreaker.CircuitBreaker; -import org.springframework.cloud.client.circuitbreaker.NoFallbackAvailableException; - -/** - * @author Marcin Grzejszczak - * @author Olga Maciaszek-Sharma - */ -class MyCircuitBreaker implements CircuitBreaker { - - AtomicBoolean runWasCalled = new AtomicBoolean(); - - @Override - public T run(Supplier toRun) { - try { - this.runWasCalled.set(true); - return toRun.get(); - } - catch (Throwable throwable) { - throw new NoFallbackAvailableException("No fallback available.", throwable); - } - } - - @Override - public T run(Supplier toRun, Function fallback) { - try { - return run(toRun); - } - catch (Throwable throwable) { - return fallback.apply(throwable); - } - } - - public void clear() { - this.runWasCalled.set(false); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/FeignAcceptEncodingTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/FeignAcceptEncodingTests.java deleted file mode 100644 index cb4c339af..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/FeignAcceptEncodingTests.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding; - -import java.util.List; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient; -import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; -import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.encoding.app.client.InvoiceClient; -import org.springframework.cloud.openfeign.encoding.app.domain.Invoice; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.annotation.DirtiesContext; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * Tests the response compression. - * - * @author Jakub Narloch - */ -@SpringBootTest(classes = FeignAcceptEncodingTests.Application.class, webEnvironment = RANDOM_PORT, - value = { "spring.cloud.openfeign.compression.response.enabled=true" }) -@DirtiesContext -class FeignAcceptEncodingTests { - - @Autowired - private InvoiceClient invoiceClient; - - @Test - void compressedResponse() { - - // when - final ResponseEntity> invoices = this.invoiceClient.getInvoices(); - - // then - assertThat(invoices).isNotNull(); - assertThat(invoices.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(invoices.getBody()).isNotNull(); - assertThat(invoices.getBody().size()).isEqualTo(100); - - } - - @EnableFeignClients(clients = InvoiceClient.class) - @LoadBalancerClient(name = "local", configuration = LocalClientConfiguration.class) - @SpringBootApplication(scanBasePackages = "org.springframework.cloud.openfeign.encoding.app") - @Import(NoSecurityConfiguration.class) - public static class Application { - - } - - @Configuration(proxyBeanMethods = false) - static class LocalClientConfiguration { - - @LocalServerPort - private int port = 0; - - @Bean - public ServiceInstanceListSupplier staticServiceInstanceListSupplier() { - return ServiceInstanceListSuppliers.from("local", - new DefaultServiceInstance("local-1", "local", "localhost", port, false)); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/FeignContentEncodingTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/FeignContentEncodingTests.java deleted file mode 100644 index 1d81d5044..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/FeignContentEncodingTests.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding; - -import java.util.List; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient; -import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; -import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.encoding.app.client.InvoiceClient; -import org.springframework.cloud.openfeign.encoding.app.domain.Invoice; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * Tests the response compression. - * - * @author Jakub Narloch - */ -@SpringBootTest(classes = FeignContentEncodingTests.Application.class, webEnvironment = RANDOM_PORT, - value = { "spring.cloud.openfeign.compression.request.enabled=true" }) -class FeignContentEncodingTests { - - @Autowired - private InvoiceClient invoiceClient; - - @Test - void compressedResponse() { - - // given - final List invoices = Invoices.createInvoiceList(50); - - // when - final ResponseEntity> response = this.invoiceClient.saveInvoices(invoices); - - // then - assertThat(response).isNotNull(); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).isNotNull(); - assertThat(response.getBody().size()).isEqualTo(invoices.size()); - - } - - @EnableFeignClients(clients = InvoiceClient.class) - @LoadBalancerClient(name = "local", configuration = LocalClientConfiguration.class) - @SpringBootApplication(scanBasePackages = "org.springframework.cloud.openfeign.encoding.app") - @Import(NoSecurityConfiguration.class) - public static class Application { - - } - - @Configuration(proxyBeanMethods = false) - static class LocalClientConfiguration { - - @LocalServerPort - private int port = 0; - - @Bean - public ServiceInstanceListSupplier staticServiceInstanceListSupplier() { - return ServiceInstanceListSuppliers.from("local", - new DefaultServiceInstance("local-1", "local", "localhost", port, false)); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/FeignPageableEncodingTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/FeignPageableEncodingTests.java deleted file mode 100644 index 30fe65990..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/FeignPageableEncodingTests.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding; - -import java.util.List; -import java.util.Optional; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient; -import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; -import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.encoding.app.client.InvoiceClient; -import org.springframework.cloud.openfeign.encoding.app.domain.Invoice; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.data.web.config.EnableSpringDataWebSupport; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * Tests the pagination encoding. - * - * @author Charlie Mordant. - * @author Hyeonmin Park - */ -@SpringBootTest(classes = FeignPageableEncodingTests.Application.class, webEnvironment = RANDOM_PORT, - value = { "spring.cloud.openfeign.compression.request.enabled=true" }) -class FeignPageableEncodingTests { - - @Autowired - private InvoiceClient invoiceClient; - - @Test - void testPageable() { - // given - Pageable pageable = PageRequest.of(0, 10, Sort.Direction.ASC, "sortProperty"); - - // when - final ResponseEntity> response = this.invoiceClient.getInvoicesPaged(pageable); - - // then - assertThat(response).isNotNull(); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).isNotNull(); - assertThat(pageable.getPageSize()).isEqualTo(response.getBody().getSize()); - assertThat(response.getBody().getPageable().getSort()).hasSize(1); - Optional optionalOrder = response.getBody().getPageable().getSort().get().findFirst(); - if (optionalOrder.isPresent()) { - Sort.Order order = optionalOrder.get(); - assertThat(order.getDirection()).isEqualTo(Sort.Direction.ASC); - assertThat(order.getProperty()).isEqualTo("sortProperty"); - } - } - - @Test - void testPageableWithDescDirection() { - // given - Pageable pageable = PageRequest.of(0, 10, Sort.Direction.DESC, "sortProperty"); - - // when - final ResponseEntity> response = this.invoiceClient.getInvoicesPaged(pageable); - - // then - assertThat(response).isNotNull(); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).isNotNull(); - assertThat(pageable.getPageSize()).isEqualTo(response.getBody().getSize()); - - Sort sort = response.getBody().getPageable().getSort(); - assertThat(sort).hasSize(1); - assertThat(sort.get()).hasSize(1); - - Optional optionalOrder = sort.get().findFirst(); - assertThat(optionalOrder.isPresent()).isTrue(); - - Sort.Order order = optionalOrder.get(); - assertThat(order.getDirection()).isEqualTo(Sort.Direction.DESC); - assertThat(order.getProperty()).isEqualTo("sortProperty"); - } - - @Test - void testPageableWithMultipleSort() { - // given - Pageable pageable = PageRequest.of(0, 10, - Sort.by(Sort.Order.desc("sortProperty1"), Sort.Order.asc("sortProperty2"))); - - // when - final ResponseEntity> response = this.invoiceClient.getInvoicesPaged(pageable); - - // then - assertThat(response).isNotNull(); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).isNotNull(); - assertThat(pageable.getPageSize()).isEqualTo(response.getBody().getSize()); - - Sort sort = response.getBody().getPageable().getSort(); - assertThat(sort).hasSize(2); - - List orderList = sort.toList(); - assertThat(orderList).hasSize(2); - - Sort.Order firstOrder = orderList.get(0); - assertThat(firstOrder.getDirection()).isEqualTo(Sort.Direction.DESC); - assertThat(firstOrder.getProperty()).isEqualTo("sortProperty1"); - - Sort.Order secondOrder = orderList.get(1); - assertThat(secondOrder.getDirection()).isEqualTo(Sort.Direction.ASC); - assertThat(secondOrder.getProperty()).isEqualTo("sortProperty2"); - } - - @Test - void testPageableWithoutSort() { - // given - Pageable pageable = PageRequest.of(0, 10); - - // when - final ResponseEntity> response = this.invoiceClient.getInvoicesPaged(pageable); - - // then - assertThat(response).isNotNull(); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).isNotNull(); - assertThat(pageable.getPageSize()).isEqualTo(response.getBody().getSize()); - assertThat(response.getBody().getPageable().getSort().isSorted()).isFalse(); - - List invoiceList = response.getBody().getContent(); - assertThat(invoiceList).hasSizeGreaterThanOrEqualTo(1); - } - - @Test - void testPageableWithoutSortWithBody() { - // given - Pageable pageable = PageRequest.of(0, 10); - - // when - final ResponseEntity> response = this.invoiceClient.getInvoicesPagedWithBody(pageable, - "InvoiceTitleFromBody"); - - // then - assertThat(response).isNotNull(); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).isNotNull(); - assertThat(pageable.getPageSize()).isEqualTo(response.getBody().getSize()); - - List invoiceList = response.getBody().getContent(); - assertThat(invoiceList).hasSizeGreaterThanOrEqualTo(1); - - Invoice firstInvoice = invoiceList.get(0); - assertThat(firstInvoice.getTitle()).startsWith("InvoiceTitleFromBody"); - } - - @Test - void testPageableWithBody() { - // given - Pageable pageable = PageRequest.of(0, 10, - Sort.by(Sort.Order.desc("sortProperty1"), Sort.Order.asc("sortProperty2"))); - - // when - final ResponseEntity> response = this.invoiceClient.getInvoicesPagedWithBody(pageable, - "InvoiceTitleFromBody"); - - // then - assertThat(response).isNotNull(); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).isNotNull(); - assertThat(pageable.getPageSize()).isEqualTo(response.getBody().getSize()); - - List invoiceList = response.getBody().getContent(); - assertThat(invoiceList).hasSizeGreaterThanOrEqualTo(1); - - Invoice firstInvoice = invoiceList.get(0); - assertThat(firstInvoice.getTitle()).startsWith("InvoiceTitleFromBody"); - - Sort sort = response.getBody().getPageable().getSort(); - assertThat(sort).hasSize(2); - - List orderList = sort.toList(); - assertThat(orderList).hasSize(2); - - Sort.Order firstOrder = orderList.get(0); - assertThat(firstOrder.getDirection()).isEqualTo(Sort.Direction.DESC); - assertThat(firstOrder.getProperty()).isEqualTo("sortProperty1"); - - Sort.Order secondOrder = orderList.get(1); - assertThat(secondOrder.getDirection()).isEqualTo(Sort.Direction.ASC); - assertThat(secondOrder.getProperty()).isEqualTo("sortProperty2"); - } - - @Test - void testUnpagedWithBody() { - // given - Pageable unpaged = Pageable.unpaged(); - - // when - final ResponseEntity> response = this.invoiceClient.getInvoicesPagedWithBody(unpaged, - "InvoiceTitleFromBody"); - - // then - assertThat(response).isNotNull(); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).isNotNull(); - - List invoiceList = response.getBody().getContent(); - assertThat(invoiceList).hasSizeGreaterThanOrEqualTo(1); - - Invoice firstInvoice = invoiceList.get(0); - assertThat(firstInvoice.getTitle()).startsWith("InvoiceTitleFromBody"); - } - - @Test - void testSortWithBody() { - // given - Sort sort = Sort.by(Sort.Order.desc("amount")); - - // when - final ResponseEntity> response = this.invoiceClient.getInvoicesSortedWithBody(sort, - "InvoiceTitleFromBody"); - - // then - assertThat(response).isNotNull(); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).isNotNull(); - assertThat(sort).isEqualTo(response.getBody().getSort()); - - List invoiceList = response.getBody().getContent(); - assertThat(invoiceList).hasSizeGreaterThanOrEqualTo(1); - - Invoice firstInvoice = invoiceList.get(0); - assertThat(firstInvoice.getTitle()).startsWith("InvoiceTitleFromBody"); - - for (int ind = 0; ind < invoiceList.size() - 1; ind++) { - assertThat(invoiceList.get(ind).getAmount()).isGreaterThanOrEqualTo(invoiceList.get(ind + 1).getAmount()); - } - } - - @EnableFeignClients(clients = InvoiceClient.class) - @LoadBalancerClient(name = "local", configuration = LocalClientConfiguration.class) - @SpringBootApplication(scanBasePackages = "org.springframework.cloud.openfeign.encoding.app", - exclude = { RepositoryRestMvcAutoConfiguration.class }) - @EnableSpringDataWebSupport - @Import({ NoSecurityConfiguration.class }) - public static class Application { - - } - - @Configuration(proxyBeanMethods = false) - static class LocalClientConfiguration { - - @LocalServerPort - private int port = 0; - - @Bean - public ServiceInstanceListSupplier staticServiceInstanceListSupplier() { - return ServiceInstanceListSuppliers.from("local", - new DefaultServiceInstance("local-1", "local", "localhost", port, false)); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/Invoices.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/Invoices.java deleted file mode 100644 index b9bbb827e..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/Invoices.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import org.springframework.cloud.openfeign.encoding.app.domain.Invoice; - -/** - * Utility class used for testing. - * - * @author Jakub Narloch - * @author Olga Maciaszek-Sharma - */ -final class Invoices { - - private Invoices() { - throw new IllegalStateException("Can't instantiate a utility class"); - } - - public static List createInvoiceList(int count) { - final List invoices = new ArrayList<>(); - for (int ind = 0; ind < count; ind++) { - final Invoice invoice = new Invoice(); - invoice.setTitle("Invoice " + (ind + 1)); - invoice.setAmount(new BigDecimal(String.format(Locale.US, "%.2f", Math.random() * 1000))); - invoices.add(invoice); - } - return invoices; - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/client/InvoiceClient.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/client/InvoiceClient.java deleted file mode 100644 index 77e9a33cf..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/client/InvoiceClient.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding.app.client; - -import java.util.List; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.SpringQueryMap; -import org.springframework.cloud.openfeign.encoding.app.domain.Invoice; -import org.springframework.data.domain.Page; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -/** - * Simple Feign client for retrieving the invoice list. - * - * @author Jakub Narloch - * @author Hyeonmin Park - */ -@FeignClient("local") -public interface InvoiceClient { - - @GetMapping(value = "invoicesPaged", produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity> getInvoicesPaged(org.springframework.data.domain.Pageable pageable); - - @PostMapping(value = "invoicesPagedWithBody", consumes = MediaType.APPLICATION_JSON_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity> getInvoicesPagedWithBody( - @SpringQueryMap org.springframework.data.domain.Pageable pageable, @RequestBody String titlePrefix); - - @PostMapping(value = "invoicesSortedWithBody", consumes = MediaType.APPLICATION_JSON_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity> getInvoicesSortedWithBody(@SpringQueryMap org.springframework.data.domain.Sort sort, - @RequestBody String titlePrefix); - - @GetMapping(value = "invoices", produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity> getInvoices(); - - @PostMapping(value = "invoices", consumes = MediaType.APPLICATION_JSON_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity> saveInvoices(List invoices); - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/domain/Invoice.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/domain/Invoice.java deleted file mode 100644 index 4b9cfa95c..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/domain/Invoice.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding.app.domain; - -import java.math.BigDecimal; - -/** - * An Invoice model - used for testing. - * - * @author Jakub Narloch - */ -public class Invoice { - - private String title; - - private BigDecimal amount; - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public BigDecimal getAmount() { - return this.amount; - } - - public void setAmount(BigDecimal amount) { - this.amount = amount; - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/resource/InvoiceResource.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/resource/InvoiceResource.java deleted file mode 100644 index 227e17e0f..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/app/resource/InvoiceResource.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding.app.resource; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Locale; - -import org.springframework.cloud.openfeign.encoding.app.domain.Invoice; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.PageRequest; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * An sample REST controller, that potentially returns large response - used for testing. - * - * @author Jakub Narloch - * @author Hyeonmin Park - */ -@RestController -public class InvoiceResource { - - @GetMapping(value = "invoices", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getInvoices() { - - return ResponseEntity.ok(createInvoiceList(null, 100, null)); - } - - @PostMapping(value = "invoices", consumes = MediaType.APPLICATION_JSON_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity> saveInvoices(@RequestBody List invoices) { - - return ResponseEntity.ok(invoices); - } - - @GetMapping(value = "invoicesPaged", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getInvoicesPaged(org.springframework.data.domain.Pageable pageable) { - Page page = new PageImpl<>(createInvoiceList(null, pageable.getPageSize(), pageable.getSort()), - pageable, 100); - return ResponseEntity.ok(page); - } - - @PostMapping(value = "invoicesPagedWithBody", consumes = MediaType.APPLICATION_JSON_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getInvoicesPagedWithBody(org.springframework.data.domain.Pageable pageable, - @RequestBody String titlePrefix) { - Page page = new PageImpl<>(createInvoiceList(titlePrefix, pageable.getPageSize(), pageable.getSort()), - pageable, 100); - return ResponseEntity.ok(page); - } - - @PostMapping(value = "invoicesSortedWithBody", consumes = MediaType.APPLICATION_JSON_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getInvoicesSortedWithBody(org.springframework.data.domain.Sort sort, - @RequestBody String titlePrefix) { - Page page = new PageImpl<>(createInvoiceList(titlePrefix, 100, sort), PageRequest.of(0, 100, sort), - 100); - return ResponseEntity.ok(page); - } - - private List createInvoiceList(String titlePrefix, int count, org.springframework.data.domain.Sort sort) { - if (titlePrefix == null) { - titlePrefix = "Invoice"; - } - final List invoices = new ArrayList<>(); - for (int ind = 0; ind < count; ind++) { - final Invoice invoice = new Invoice(); - invoice.setTitle(titlePrefix + " " + (ind + 1)); - invoice.setAmount(new BigDecimal(String.format(Locale.US, "%.2f", Math.random() * 1000))); - invoices.add(invoice); - } - if (sort != null) { - Comparator comparatorForSort = null; - for (org.springframework.data.domain.Sort.Order order : sort) { - Comparator comparatorForOrder; - if (order.getProperty().equals("title")) { - comparatorForOrder = Comparator.comparing(Invoice::getTitle); - } - else if (order.getProperty().equals("amount")) { - comparatorForOrder = Comparator.comparing(Invoice::getAmount); - } - else { - continue; - } - - if (order.isDescending()) { - comparatorForOrder = comparatorForOrder.reversed(); - } - - if (comparatorForSort == null) { - comparatorForSort = comparatorForOrder; - } - else { - comparatorForSort = comparatorForSort.thenComparing(comparatorForOrder); - } - } - if (comparatorForSort != null) { - invoices.sort(comparatorForSort); - } - } - return invoices; - } - -} 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 deleted file mode 100644 index 0e229d0f7..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufNotInClasspathTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding.proto; - -import feign.RequestTemplate; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.ObjectFactory; -import org.springframework.boot.autoconfigure.http.HttpMessageConverters; -import org.springframework.cloud.openfeign.support.SpringEncoder; -import org.springframework.cloud.test.ClassPathExclusions; -import org.springframework.http.converter.StringHttpMessageConverter; - -import static feign.Request.HttpMethod.POST; - -/** - * Test {@link SpringEncoder} when protobuf is not in classpath - * - * @author ScienJus - */ -@ClassPathExclusions("protobuf-*.jar") -class ProtobufNotInClasspathTest { - - @Test - void testEncodeWhenProtobufNotInClasspath() { - ObjectFactory converters = () -> new HttpMessageConverters( - new StringHttpMessageConverter()); - RequestTemplate requestTemplate = new RequestTemplate(); - 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/ProtobufSpringEncoderTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufSpringEncoderTests.java deleted file mode 100644 index 6570f1956..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufSpringEncoderTests.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2013-2022 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.encoding.proto; - -import java.io.IOException; -import java.io.InputStream; -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.hc5.ApacheHttp5Client; -import org.apache.hc.client5.http.classic.HttpClient; -import org.apache.hc.core5.http.ClassicHttpRequest; -import org.apache.hc.core5.http.ClassicHttpResponse; -import org.apache.hc.core5.http.HttpEntity; -import org.apache.hc.core5.http.HttpResponse; -import org.apache.hc.core5.http.ProtocolVersion; -import org.apache.hc.core5.http.message.BasicClassicHttpResponse; -import org.apache.hc.core5.http.protocol.HttpContext; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.ArgumentMatchers; -import org.mockito.BDDMockito; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import org.mockito.stubbing.Answer; - -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 static feign.Request.HttpMethod.POST; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -/** - * Test {@link SpringEncoder} with {@link ProtobufHttpMessageConverter} - * - * @author ScienJus - * @author Olga Maciaszek-Sharma - */ -@ExtendWith(MockitoExtension.class) -class ProtobufSpringEncoderTests { - - @Mock - private HttpClient httpClient; - - // a protobuf object with some content - private final org.springframework.cloud.openfeign.encoding.proto.Request request = org.springframework.cloud.openfeign.encoding.proto.Request - .newBuilder().setId(1000000) - .setMsg("Erlang/OTP 最初是爱立信为开发电信设备系统设计的编程语言平台," + "电信设备(路由器、接入网关、…)典型设计是通过背板连接主控板卡与多块业务板卡的分布式系统。").build(); - - @Test - void testProtobuf() throws IOException { - // protobuf convert to request by feign and ProtobufHttpMessageConverter - RequestTemplate requestTemplate = newRequestTemplate(); - requestTemplate.target("http://example.com"); - newEncoder().encode(request, Request.class, requestTemplate); - HttpEntity entity = toApacheHttpEntity(requestTemplate); - byte[] bytes = read(entity.getContent(), (int) entity.getContentLength()); - - assertThat(request.toByteArray()).isEqualTo(bytes); - org.springframework.cloud.openfeign.encoding.proto.Request copy = org.springframework.cloud.openfeign.encoding.proto.Request - .parseFrom(bytes); - assertThat(copy).isEqualTo(request); - } - - @Test - void testProtobufWithCharsetWillFail() throws IOException { - // protobuf convert to request by feign and ProtobufHttpMessageConverter - RequestTemplate requestTemplate = newRequestTemplate(); - requestTemplate.target("http://example.com"); - newEncoder().encode(request, Request.class, requestTemplate); - // set a charset - requestTemplate.body(requestTemplate.body(), StandardCharsets.UTF_8); - HttpEntity entity = toApacheHttpEntity(requestTemplate); - byte[] bytes = read(entity.getContent(), (int) entity.getContentLength()); - - // http request-body is different with original protobuf body - assertThat(request.toByteArray().length).isNotEqualTo(bytes.length); - try { - org.springframework.cloud.openfeign.encoding.proto.Request copy = org.springframework.cloud.openfeign.encoding.proto.Request - .parseFrom(bytes); - fail("Expected an InvalidProtocolBufferException to be thrown"); - } - catch (InvalidProtocolBufferException e) { - // success - } - } - - private SpringEncoder newEncoder() { - ObjectFactory converters = () -> new HttpMessageConverters( - new ProtobufHttpMessageConverter()); - return new SpringEncoder(converters); - } - - private RequestTemplate newRequestTemplate() { - RequestTemplate requestTemplate = new RequestTemplate(); - requestTemplate.method(POST); - return requestTemplate; - } - - private HttpEntity toApacheHttpEntity(RequestTemplate requestTemplate) throws IOException { - final List request = new ArrayList<>(1); - BDDMockito.given(httpClient.execute(ArgumentMatchers.any(), ArgumentMatchers.any(), - ArgumentMatchers.any(HttpContext.class))).will((Answer) invocationOnMock -> { - request.add((ClassicHttpRequest) invocationOnMock.getArguments()[1]); - try (ClassicHttpResponse response = new BasicClassicHttpResponse(200)) { - response.setVersion(new ProtocolVersion("http", 1, 1)); - return response; - } - }); - new ApacheHttp5Client(httpClient).execute(requestTemplate.resolve(new HashMap<>()).request(), - new feign.Request.Options()); - ClassicHttpRequest httpUriRequest = request.get(0); - return httpUriRequest.getEntity(); - } - - private byte[] read(InputStream in, int length) throws IOException { - byte[] bytes = new byte[length]; - in.read(bytes); - return bytes; - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufTest.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufTest.java deleted file mode 100644 index 150cd034c..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/ProtobufTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2013-2022 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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: protobuf_test.proto - -package org.springframework.cloud.openfeign.encoding.proto; - -public final class ProtobufTest { - - static final com.google.protobuf.Descriptors.Descriptor internal_static_Request_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_Request_fieldAccessorTable; - - private static com.google.protobuf.Descriptors.FileDescriptor descriptor; - - static { - String[] descriptorData = { """ - - \023protobuf_test.proto"" - \007Request\022 - - \002id\030\001 \001(\005\022\013 - \003msg\030\002 \001(\tB\024 - \020feign.httpclientP\001b\006proto3""" }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] {}, assigner); - internal_static_Request_descriptor = getDescriptor().getMessageTypes().get(0); - internal_static_Request_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_Request_descriptor, new String[] { "Id", "Msg", }); - } - - private ProtobufTest() { - } - - public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); - } - - public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { - return descriptor; - } - - // @@protoc_insertion_point(outer_class_scope) - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/Request.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/Request.java deleted file mode 100644 index 686b47708..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/Request.java +++ /dev/null @@ -1,575 +0,0 @@ -/* - * Copyright 2013-2022 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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: protobuf_test.proto - -package org.springframework.cloud.openfeign.encoding.proto; - -/** - * Protobuf type {@code Request} - */ -public final class Request extends com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:Request) - org.springframework.cloud.openfeign.encoding.proto.RequestOrBuilder { - - public static final int ID_FIELD_NUMBER = 1; - - public static final int MSG_FIELD_NUMBER = 2; - - private static final long serialVersionUID = 0L; - - // @@protoc_insertion_point(class_scope:Request) - private static final Request DEFAULT_INSTANCE; - - private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser<>() { - public Request parsePartialFrom(com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Request(input, extensionRegistry); - } - }; - - static { - DEFAULT_INSTANCE = new Request(); - } - - private int id_; - - private volatile Object msg_; - - private byte memoizedIsInitialized = -1; - - // Use Request.newBuilder() to construct. - private Request(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private Request() { - this.id_ = 0; - this.msg_ = ""; - } - - private Request(com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: - if (!parseUnknownFieldProto3(input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - case 8: - this.id_ = input.readInt32(); - break; - case 18: - String s = input.readStringRequireUtf8(); - this.msg_ = s; - break; - } - } - } - catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } - catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); - } - finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - - public static com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_descriptor; - } - - public static Request parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Request parseFrom(java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Request parseFrom(com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Request parseFrom(com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Request parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static Request parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static Request parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static Request parseFrom(java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input, extensionRegistry); - } - - public static Request parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static Request parseDelimitedFrom(java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static Request parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static Request parseFrom(com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input, extensionRegistry); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(Request prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - public static Request getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @Override - public com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - protected FieldAccessorTable internalGetFieldAccessorTable() { - return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_fieldAccessorTable - .ensureFieldAccessorsInitialized(Request.class, Request.Builder.class); - } - - /** - * int32 id = 1; - */ - public int getId() { - return this.id_; - } - - /** - * string msg = 2; - */ - public String getMsg() { - Object ref = this.msg_; - if (ref instanceof String) { - return (String) ref; - } - else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - this.msg_ = s; - return s; - } - } - - /** - * string msg = 2; - */ - public com.google.protobuf.ByteString getMsgBytes() { - Object ref = this.msg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - this.msg_ = b; - return b; - } - else { - return (com.google.protobuf.ByteString) ref; - } - } - - public boolean isInitialized() { - byte isInitialized = this.memoizedIsInitialized; - if (isInitialized == 1) { - return true; - } - if (isInitialized == 0) { - return false; - } - this.memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (this.id_ != 0) { - output.writeInt32(1, this.id_); - } - if (!getMsgBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, this.msg_); - } - this.unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = this.memoizedSize; - if (size != -1) { - return size; - } - - size = 0; - if (this.id_ != 0) { - size += com.google.protobuf.CodedOutputStream.computeInt32Size(1, this.id_); - } - if (!getMsgBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, this.msg_); - } - size += this.unknownFields.getSerializedSize(); - this.memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof Request other)) { - return super.equals(obj); - } - - boolean result = true; - result = result && (getId() == other.getId()); - result = result && getMsg().equals(other.getMsg()); - result = result && this.unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (this.memoizedHashCode != 0) { - return this.memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + ID_FIELD_NUMBER; - hash = (53 * hash) + getId(); - hash = (37 * hash) + MSG_FIELD_NUMBER; - hash = (53 * hash) + getMsg().hashCode(); - hash = (29 * hash) + this.unknownFields.hashCode(); - this.memoizedHashCode = hash; - return hash; - } - - public Builder newBuilderForType() { - return newBuilder(); - } - - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @Override - protected Builder newBuilderForType(BuilderParent parent) { - return new Builder(parent); - } - - @Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public Request getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - /** - * Protobuf type {@code Request} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:Request) - org.springframework.cloud.openfeign.encoding.proto.RequestOrBuilder { - - private int id_; - - private Object msg_ = ""; - - // Construct using - // org.springframework.cloud.openfeign.encoding.proto.Request.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder(BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - - public static com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_descriptor; - } - - protected FieldAccessorTable internalGetFieldAccessorTable() { - return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_fieldAccessorTable - .ensureFieldAccessorsInitialized(Request.class, Request.Builder.class); - } - - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { - // TODO: Remove this? - } - } - - public Builder clear() { - super.clear(); - this.id_ = 0; - this.msg_ = ""; - return this; - } - - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_descriptor; - } - - public Request getDefaultInstanceForType() { - return Request.getDefaultInstance(); - } - - public Request build() { - Request result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Request buildPartial() { - Request result = new Request(this); - result.id_ = this.id_; - result.msg_ = this.msg_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - - public Builder setField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value) { - return (Builder) super.setField(field, value); - } - - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - - public Builder setRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, int index, - Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - - public Builder addRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value) { - return (Builder) super.addRepeatedField(field, value); - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof Request) { - return mergeFrom((Request) other); - } - else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(Request other) { - if (other == Request.getDefaultInstance()) { - return this; - } - if (other.getId() != 0) { - setId(other.getId()); - } - if (!other.getMsg().isEmpty()) { - this.msg_ = other.msg_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public boolean isInitialized() { - return true; - } - - public Builder mergeFrom(com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - Request parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } - catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Request) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } - finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - /** - * int32 id = 1; - */ - public int getId() { - return this.id_; - } - - /** - * int32 id = 1; - */ - public Builder setId(int value) { - - this.id_ = value; - onChanged(); - return this; - } - - /** - * int32 id = 1; - */ - public Builder clearId() { - - this.id_ = 0; - onChanged(); - return this; - } - - /** - * string msg = 2; - */ - public String getMsg() { - Object ref = this.msg_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - this.msg_ = s; - return s; - } - else { - return (String) ref; - } - } - - /** - * string msg = 2; - */ - public Builder setMsg(String value) { - if (value == null) { - throw new NullPointerException(); - } - - this.msg_ = value; - onChanged(); - return this; - } - - /** - * string msg = 2; - */ - public com.google.protobuf.ByteString getMsgBytes() { - Object ref = this.msg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); - this.msg_ = b; - return b; - } - else { - return (com.google.protobuf.ByteString) ref; - } - } - - /** - * string msg = 2; - */ - public Builder setMsgBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - this.msg_ = value; - onChanged(); - return this; - } - - /** - * string msg = 2; - */ - public Builder clearMsg() { - - this.msg_ = getDefaultInstance().getMsg(); - onChanged(); - return this; - } - - public Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public Builder mergeUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:Request) - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/RequestOrBuilder.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/RequestOrBuilder.java deleted file mode 100644 index 131435ccf..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/encoding/proto/RequestOrBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2013-2022 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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: protobuf_test.proto - -package org.springframework.cloud.openfeign.encoding.proto; - -public interface RequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:Request) - com.google.protobuf.MessageOrBuilder { - - /** - * int32 id = 1; - */ - int getId(); - - /** - * string msg = 2; - */ - String getMsg(); - - /** - * string msg = 2; - */ - com.google.protobuf.ByteString getMsgBytes(); - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/feignclientsregistrar/TopLevelClient.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/feignclientsregistrar/TopLevelClient.java deleted file mode 100644 index f05f09196..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/feignclientsregistrar/TopLevelClient.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013-2022 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.feignclientsregistrar; - -import org.springframework.cloud.openfeign.FeignClient; - -/** - * @author Michal Domagala - */ - -@FeignClient("top-level") -public interface TopLevelClient { - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/feignclientsregistrar/sub/SubLevelClient.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/feignclientsregistrar/sub/SubLevelClient.java deleted file mode 100644 index a8ea8b1cb..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/feignclientsregistrar/sub/SubLevelClient.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013-2022 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.feignclientsregistrar.sub; - -import org.springframework.cloud.openfeign.FeignClient; - -/** - * @author Michal Domagala - */ - -@FeignClient("sub-level") -public interface SubLevelClient { - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/FeignHalAutoConfigurationContextTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/FeignHalAutoConfigurationContextTests.java deleted file mode 100644 index f92af6235..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/FeignHalAutoConfigurationContextTests.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2016-2022 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.hateoas; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration; -import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration; -import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.boot.test.context.FilteredClassLoader; -import org.springframework.boot.test.context.runner.WebApplicationContextRunner; -import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; -import org.springframework.hateoas.config.WebConverters; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Hector Espert - * @author Olga Maciaszek-Sharma - */ -class FeignHalAutoConfigurationContextTests { - - private WebApplicationContextRunner contextRunner; - - @BeforeEach - void setUp() { - contextRunner = new WebApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(JacksonAutoConfiguration.class, - HttpMessageConvertersAutoConfiguration.class, HypermediaAutoConfiguration.class, - RepositoryRestMvcAutoConfiguration.class, FeignHalAutoConfiguration.class)) - .withPropertyValues("debug=true"); - } - - @Test - void shouldNotLoadWebConvertersCustomizerWhenNotWebConvertersNotInClasspath() { - FilteredClassLoader filteredClassLoader = new FilteredClassLoader(RepositoryRestMvcConfiguration.class, - WebConverters.class); - contextRunner.withClassLoader(filteredClassLoader) - .run(context -> assertThat(context).doesNotHaveBean("webConvertersCustomizer")); - } - - @Test - void shouldLoadWebConvertersCustomizer() { - FilteredClassLoader filteredClassLoader = new FilteredClassLoader(RepositoryRestMvcConfiguration.class); - contextRunner.withClassLoader(filteredClassLoader) - .run(context -> assertThat(context).hasBean("webConvertersCustomizer")); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/FeignHalTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/FeignHalTests.java deleted file mode 100644 index 31eeda6e2..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/FeignHalTests.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2016-2022 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.hateoas; - -import java.util.Collection; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.openfeign.hateoas.app.FeignHalApplication; -import org.springframework.cloud.openfeign.hateoas.app.FeignHalClient; -import org.springframework.cloud.openfeign.hateoas.app.MarsRover; -import org.springframework.hateoas.CollectionModel; -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.Link; -import org.springframework.hateoas.PagedModel; -import org.springframework.test.annotation.DirtiesContext; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * Test HATEOAS support. - * - * @author Hector Espert - */ -@SpringBootTest(classes = FeignHalApplication.class, webEnvironment = RANDOM_PORT, value = "debug=true") -@DirtiesContext -class FeignHalTests { - - @Autowired - private FeignHalClient feignHalClient; - - @Test - void testEntityModel() { - EntityModel entity = feignHalClient.entity(); - assertThat(entity).isNotNull(); - - assertThat(entity.hasLinks()).isTrue(); - assertThat(entity.hasLink("self")).isTrue(); - - assertThat(entity.getLink("self")).map(Link::getHref).contains("/entity"); - - MarsRover marsRover = entity.getContent(); - assertThat(marsRover).isNotNull(); - assertThat(marsRover.getName()).isEqualTo("Sojourner"); - } - - @Test - void testCollectionModel() { - CollectionModel collectionModel = feignHalClient.collection(); - assertThat(collectionModel).isNotNull(); - assertThat(collectionModel).isNotEmpty(); - - assertThat(collectionModel.hasLinks()).isTrue(); - assertThat(collectionModel.hasLink("self")).isTrue(); - - assertThat(collectionModel.getLink("self")).map(Link::getHref).contains("/collection"); - - Collection collection = collectionModel.getContent(); - assertThat(collection).isNotEmpty(); - - MarsRover marsRover = collection.stream().findAny().orElse(null); - assertThat(marsRover).isNotNull(); - assertThat(marsRover.getName()).isEqualTo("Opportunity"); - } - - @Test - void testPagedModel() { - PagedModel paged = feignHalClient.paged(); - assertThat(paged).isNotNull(); - assertThat(paged).isNotEmpty(); - - assertThat(paged.hasLinks()).isTrue(); - assertThat(paged.hasLink("self")).isTrue(); - - assertThat(paged.getLink("self")).map(Link::getHref).contains("/paged"); - - Collection collection = paged.getContent(); - assertThat(collection).isNotEmpty(); - - MarsRover marsRover = collection.stream().findAny().orElse(null); - assertThat(marsRover).isNotNull(); - assertThat(marsRover.getName()).isEqualTo("Curiosity"); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalApplication.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalApplication.java deleted file mode 100644 index 47b734529..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalApplication.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2016-2022 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.hateoas.app; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient; -import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; -import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; - -/** - * Test HATEOAS application. - * - * @author Hector Espert - */ -@EnableFeignClients(clients = FeignHalClient.class) -@SpringBootApplication(scanBasePackages = "org.springframework.cloud.openfeign.hateoas.app", - exclude = RepositoryRestMvcAutoConfiguration.class) -@LoadBalancerClient(name = "local", configuration = LocalHalClientConfiguration.class) -@Import(NoSecurityConfiguration.class) -public class FeignHalApplication { - - // Load balancer with fixed server list for "local" pointing to localhost - -} - -class LocalHalClientConfiguration { - - @LocalServerPort - private int port = 0; - - @Bean - public ServiceInstanceListSupplier staticServiceInstanceListSupplier() { - return ServiceInstanceListSuppliers.from("local", - new DefaultServiceInstance("local-1", "local", "localhost", port, false)); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalClient.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalClient.java deleted file mode 100644 index ed65d8a3f..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalClient.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2016-2022 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.hateoas.app; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.hateoas.CollectionModel; -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.PagedModel; -import org.springframework.web.bind.annotation.GetMapping; - -/** - * @author Hector Espert - */ -@FeignClient("local") -public interface FeignHalClient { - - @GetMapping("entity") - EntityModel entity(); - - @GetMapping("collection") - CollectionModel collection(); - - @GetMapping("paged") - PagedModel paged(); - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalConfiguration.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalConfiguration.java deleted file mode 100644 index 45461adac..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalConfiguration.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2016-2022 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.hateoas.app; - -import org.springframework.beans.factory.annotation.Value; - -/** - * @author Hector Espert - */ -public class FeignHalConfiguration { - - @Value("${local.server.port}") - private int serverPort = 0; - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalController.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalController.java deleted file mode 100644 index cb7abf6da..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/FeignHalController.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2016-2022 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.hateoas.app; - -import java.util.Collections; - -import org.springframework.hateoas.CollectionModel; -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.Link; -import org.springframework.hateoas.PagedModel; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author Hector Espert - */ -@RestController -public class FeignHalController { - - @GetMapping("/entity") - public EntityModel getEntity() { - MarsRover marsRover = new MarsRover(); - marsRover.setName("Sojourner"); - Link link = Link.of("/entity", "self"); - return EntityModel.of(marsRover, link); - } - - @GetMapping("/collection") - public CollectionModel getCollection() { - MarsRover marsRover = new MarsRover(); - marsRover.setName("Opportunity"); - Link link = Link.of("/collection", "self"); - return CollectionModel.of(Collections.singleton(marsRover), link); - } - - @GetMapping("/paged") - public CollectionModel getPaged() { - MarsRover marsRover = new MarsRover(); - marsRover.setName("Curiosity"); - Link link = Link.of("/paged", "self"); - PagedModel.PageMetadata metadata = new PagedModel.PageMetadata(1, 1, 1); - return PagedModel.of(Collections.singleton(marsRover), metadata, link); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/MarsRover.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/MarsRover.java deleted file mode 100644 index c1f0fd250..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/hateoas/app/MarsRover.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2016-2022 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.hateoas.app; - -/** - * @author Hector Espert - */ -public class MarsRover { - - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/invalid/FeignClientValidationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/invalid/FeignClientValidationTests.java deleted file mode 100644 index fc4b9f81f..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/invalid/FeignClientValidationTests.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2013-2022 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.invalid; - -import org.junit.jupiter.api.Test; - -import org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignAutoConfiguration; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * @author Dave Syer - * @author Szymon Linowski - */ -class FeignClientValidationTests { - - @Test - void testServiceIdAndValue() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( - LoadBalancerAutoConfiguration.class, NameAndServiceIdConfiguration.class); - assertThat(context.getBean(NameAndServiceIdConfiguration.Client.class)).isNotNull(); - context.close(); - } - - @Test - void testDuplicatedClientNames() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - context.setAllowBeanDefinitionOverriding(false); - context.register(LoadBalancerAutoConfiguration.class, DuplicatedFeignClientNamesConfiguration.class); - context.refresh(); - assertThat(context.getBean(DuplicatedFeignClientNamesConfiguration.FooClient.class)).isNotNull(); - assertThat(context.getBean(DuplicatedFeignClientNamesConfiguration.BarClient.class)).isNotNull(); - context.close(); - } - - @Test - void testNotLegalHostname() { - assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> new AnnotationConfigApplicationContext(BadHostnameConfiguration.class)) - .withMessage("Service id not legal hostname (foo_bar)"); - } - - @Configuration(proxyBeanMethods = false) - @Import({ FeignAutoConfiguration.class }) - @EnableFeignClients(clients = NameAndServiceIdConfiguration.Client.class) - protected static class NameAndServiceIdConfiguration { - - @FeignClient(name = "bar") - interface Client { - - @GetMapping("/") - String get(); - - } - - } - - @Configuration(proxyBeanMethods = false) - @Import({ FeignAutoConfiguration.class }) - @EnableFeignClients(clients = { DuplicatedFeignClientNamesConfiguration.FooClient.class, - DuplicatedFeignClientNamesConfiguration.BarClient.class }) - protected static class DuplicatedFeignClientNamesConfiguration { - - @FeignClient(contextId = "foo", name = "bar") - interface FooClient { - - @GetMapping("/") - String get(); - - } - - @FeignClient(name = "bar") - interface BarClient { - - @GetMapping("/") - String get(); - - } - - } - - @Configuration(proxyBeanMethods = false) - @Import(FeignAutoConfiguration.class) - @EnableFeignClients(clients = BadHostnameConfiguration.Client.class) - protected static class BadHostnameConfiguration { - - @FeignClient("foo_bar") - interface Client { - - @GetMapping("/") - String get(); - - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/FeignBlockingLoadBalancerClientTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/FeignBlockingLoadBalancerClientTests.java deleted file mode 100644 index 3a5cad54d..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/FeignBlockingLoadBalancerClientTests.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright 2013-2022 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.loadbalancer; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URI; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -import feign.Client; -import feign.Request; -import feign.Response; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.ArgumentCaptor; -import org.mockito.junit.jupiter.MockitoExtension; - -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.client.loadbalancer.CompletionContext; -import org.springframework.cloud.client.loadbalancer.LoadBalancerLifecycle; -import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties; -import org.springframework.cloud.client.loadbalancer.RequestDataContext; -import org.springframework.cloud.client.loadbalancer.ResponseData; -import org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient; -import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * Tests for {@link FeignBlockingLoadBalancerClient}. Note: the underlying - * {@link BlockingLoadBalancerClient} is already extensively tested in the Spring Cloud - * Commons project, so here we are only testing the interactions between - * {@link FeignBlockingLoadBalancerClient} and its delegates. - * - * @author Olga Maciaszek-Sharma - * @author changjin wei(魏昌进) - * @see BlockingLoadBalancerClientTests - */ -@ExtendWith(MockitoExtension.class) -class FeignBlockingLoadBalancerClientTests { - - private final Client delegate = mock(Client.class); - - private final BlockingLoadBalancerClient loadBalancerClient = mock(BlockingLoadBalancerClient.class); - - private final LoadBalancerClientFactory loadBalancerClientFactory = mock(LoadBalancerClientFactory.class); - - private final LoadBalancerProperties loadBalancerProperties = new LoadBalancerProperties(); - - private final List transformers = Arrays.asList(new InstanceIdTransformer(), - new ServiceIdTransformer()); - - private final FeignBlockingLoadBalancerClient feignBlockingLoadBalancerClient = new FeignBlockingLoadBalancerClient( - delegate, loadBalancerClient, loadBalancerClientFactory, transformers); - - @BeforeEach - void setUp() { - when(loadBalancerClientFactory.getProperties(any(String.class))).thenReturn(loadBalancerProperties); - } - - @Test - void shouldExtractServiceIdFromRequestUrl() throws IOException { - Request request = testRequest(); - - feignBlockingLoadBalancerClient.execute(request, new Request.Options()); - - verify(loadBalancerClient).choose(eq("test"), any()); - } - - @Test - void shouldThrowExceptionIfNoServiceId() { - Request request = testRequest(""); - - assertThatIllegalStateException() - .isThrownBy(() -> feignBlockingLoadBalancerClient.execute(request, new Request.Options())) - .withMessage("Request URI does not contain a valid hostname: http:///path"); - } - - @Test - void shouldRespondWithServiceUnavailableIfInstanceNotFound() throws IOException { - Request request = testRequest(); - - Response response = feignBlockingLoadBalancerClient.execute(request, new Request.Options()); - - assertThat(response.status()).isEqualTo(HttpStatus.SERVICE_UNAVAILABLE.value()); - assertThat(read(response)).isEqualTo("Load balancer does not contain an instance for the service test"); - } - - @Test - void shouldPassCorrectRequestToDelegate() throws IOException { - Request request = testRequest(); - Request.Options options = new Request.Options(); - String url = "http://127.0.0.1/path"; - ServiceInstance serviceInstance = new DefaultServiceInstance("test-1", "test", "test-host", 8888, false); - when(loadBalancerClient.choose(eq("test"), any())).thenReturn(serviceInstance); - when(loadBalancerClient.reconstructURI(serviceInstance, URI.create("http://test/path"))) - .thenReturn(URI.create(url)); - - feignBlockingLoadBalancerClient.execute(request, options); - - ArgumentCaptor captor = ArgumentCaptor.forClass(Request.class); - verify(delegate, times(1)).execute(captor.capture(), eq(options)); - Request actualRequest = captor.getValue(); - assertThat(actualRequest.httpMethod()).isEqualTo(Request.HttpMethod.GET); - assertThat(actualRequest.url()).isEqualTo(url); - assertThat(actualRequest.headers()).hasSize(3); - assertThat(actualRequest.headers()).containsEntry(HttpHeaders.CONTENT_TYPE, - Collections.singletonList(MediaType.APPLICATION_JSON_VALUE)); - assertThat(actualRequest.headers()).containsEntry("X-ServiceId", Collections.singletonList("test")); - assertThat(actualRequest.headers()).containsEntry("X-InstanceId", Collections.singletonList("test-1")); - assertThat(new String(actualRequest.body())).isEqualTo("hello"); - } - - @Test - void shouldExecuteLoadBalancerLifecycleCallbacks() throws IOException { - Request request = testRequest(); - when(delegate.execute(any(), any())).thenReturn(Response.builder().status(200).request(request).build()); - Request.Options options = new Request.Options(); - String url = "http://127.0.0.1/path"; - ServiceInstance serviceInstance = new DefaultServiceInstance("test-1", "test", "test-host", 8888, false); - when(loadBalancerClient.choose(eq("test"), any())).thenReturn(serviceInstance); - when(loadBalancerClient.reconstructURI(serviceInstance, URI.create("http://test/path"))) - .thenReturn(URI.create(url)); - String callbackTestHint = "callbackTestHint"; - loadBalancerProperties.getHint().put("test", callbackTestHint); - Map loadBalancerLifecycleBeans = new HashMap<>(); - loadBalancerLifecycleBeans.put("loadBalancerLifecycle", new TestLoadBalancerLifecycle()); - loadBalancerLifecycleBeans.put("anotherLoadBalancerLifecycle", new AnotherLoadBalancerLifecycle()); - when(loadBalancerClientFactory.getInstances("test", LoadBalancerLifecycle.class)) - .thenReturn(loadBalancerLifecycleBeans); - - feignBlockingLoadBalancerClient.execute(request, options); - - Collection> lifecycleLogRequests = ((TestLoadBalancerLifecycle) loadBalancerLifecycleBeans - .get("loadBalancerLifecycle")).getStartLog().values(); - Collection> lifecycleLogStartedRequests = ((TestLoadBalancerLifecycle) loadBalancerLifecycleBeans - .get("loadBalancerLifecycle")).getStartRequestLog().values(); - Collection> anotherLifecycleLogRequests = ((AnotherLoadBalancerLifecycle) loadBalancerLifecycleBeans - .get("anotherLoadBalancerLifecycle")).getCompleteLog().values(); - assertThat(lifecycleLogRequests).extracting(lbRequest -> lbRequest.getContext().getHint()) - .contains(callbackTestHint); - assertThat(lifecycleLogStartedRequests).extracting(lbRequest -> lbRequest.getContext().getHint()) - .contains(callbackTestHint); - assertThat(anotherLifecycleLogRequests) - .extracting(completionContext -> completionContext.getClientResponse().getHttpStatus()) - .contains(HttpStatus.OK); - } - - private String read(Response response) throws IOException { - BufferedReader reader = new BufferedReader( - new InputStreamReader(response.body().asInputStream(), StandardCharsets.UTF_8)); - StringBuilder outputString = new StringBuilder(); - String line; - while ((line = reader.readLine()) != null) { - outputString.append(line); - } - return outputString.toString(); - } - - private Request testRequest() { - return testRequest("test"); - } - - private Request testRequest(String host) { - return Request.create(Request.HttpMethod.GET, "http://" + host + "/path", testHeaders(), "hello".getBytes(), - StandardCharsets.UTF_8, null); - } - - private Map> testHeaders() { - Map> feignHeaders = new HashMap<>(); - feignHeaders.put(HttpHeaders.CONTENT_TYPE, Collections.singletonList(MediaType.APPLICATION_JSON_VALUE)); - return feignHeaders; - - } - - protected static class TestLoadBalancerLifecycle - implements LoadBalancerLifecycle { - - final Map> startLog = new ConcurrentHashMap<>(); - - final Map> startRequestLog = new ConcurrentHashMap<>(); - - final Map> completeLog = new ConcurrentHashMap<>(); - - @Override - public void onStart(org.springframework.cloud.client.loadbalancer.Request request) { - startLog.put(getName() + UUID.randomUUID(), request); - } - - @Override - public void onStartRequest(org.springframework.cloud.client.loadbalancer.Request request, - org.springframework.cloud.client.loadbalancer.Response lbResponse) { - startRequestLog.put(getName() + UUID.randomUUID(), request); - } - - @Override - public void onComplete(CompletionContext completionContext) { - completeLog.put(getName() + UUID.randomUUID(), completionContext); - } - - Map> getStartLog() { - return startLog; - } - - Map> getCompleteLog() { - return completeLog; - } - - Map> getStartRequestLog() { - return startRequestLog; - } - - protected String getName() { - return this.getClass().getSimpleName(); - } - - } - - protected static class AnotherLoadBalancerLifecycle extends TestLoadBalancerLifecycle { - - @Override - protected String getName() { - return this.getClass().getSimpleName(); - } - - } - - private static class InstanceIdTransformer implements LoadBalancerFeignRequestTransformer { - - @Override - public Request transformRequest(Request request, ServiceInstance instance) { - Map> headers = new HashMap<>(request.headers()); - headers.put("X-InstanceId", Collections.singletonList(instance.getInstanceId())); - return Request.create(request.httpMethod(), request.url(), headers, request.body(), request.charset(), - request.requestTemplate()); - } - - } - - private static class ServiceIdTransformer implements LoadBalancerFeignRequestTransformer { - - @Override - public Request transformRequest(Request request, ServiceInstance instance) { - Map> headers = new HashMap<>(request.headers()); - headers.put("X-ServiceId", Collections.singletonList(instance.getServiceId())); - return Request.create(request.httpMethod(), request.url(), headers, request.body(), request.charset(), - request.requestTemplate()); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/FeignLoadBalancerAutoConfigurationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/FeignLoadBalancerAutoConfigurationTests.java deleted file mode 100644 index 8964a95e8..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/FeignLoadBalancerAutoConfigurationTests.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2013-2023 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.loadbalancer; - -import java.net.http.HttpClient; -import java.util.Map; - -import feign.Client; -import feign.hc5.ApacheHttp5Client; -import feign.http2client.Http2Client; -import feign.okhttp.OkHttpClient; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient; -import org.springframework.cloud.loadbalancer.config.BlockingLoadBalancerClientAutoConfiguration; -import org.springframework.cloud.loadbalancer.config.LoadBalancerAutoConfiguration; -import org.springframework.cloud.openfeign.FeignAutoConfiguration; -import org.springframework.context.ConfigurableApplicationContext; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.test.util.ReflectionTestUtils.getField; - -/** - * @author Olga Maciaszek-Sharma - * @author Nguyen Ky Thanh - * @author changjin wei(魏昌进) - */ -class FeignLoadBalancerAutoConfigurationTests { - - @Test - void shouldInstantiateDefaultFeignBlockingLoadBalancerClientWhenHttpClientDisabled() { - ConfigurableApplicationContext context = initContext("spring.cloud.openfeign.httpclient.hc5.enabled=false", - "spring.cloud.loadbalancer.retry.enabled=false"); - assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class); - assertLoadBalanced(context, Client.Default.class); - } - - @Test - void shouldInstantiateOkHttpFeignClientWhenEnabled() { - ConfigurableApplicationContext context = initContext("spring.cloud.openfeign.httpclient.hc5.enabled=false", - "spring.cloud.openfeign.okhttp.enabled=true", "spring.cloud.loadbalancer.retry.enabled=false", - "spring.cloud.openfeign.httpclient.okhttp.read-timeout=9s"); - assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class); - Map beans = context - .getBeansOfType(FeignBlockingLoadBalancerClient.class); - assertThat(beans).as("Missing bean of type %s", OkHttpClient.class).hasSize(1); - Client client = beans.get("feignClient").getDelegate(); - assertThat(client).isInstanceOf(OkHttpClient.class); - OkHttpClient okHttpClient = (OkHttpClient) client; - okhttp3.OkHttpClient httpClient = (okhttp3.OkHttpClient) getField(okHttpClient, "delegate"); - assertThat(httpClient.readTimeoutMillis()).isEqualTo(9000); - - } - - @Test - void shouldInstantiateHttp2ClientFeignClientWhenEnabled() { - ConfigurableApplicationContext context = initContext("spring.cloud.openfeign.httpclient.hc5.enabled=false", - "spring.cloud.openfeign.http2client.enabled=true", "spring.cloud.loadbalancer.retry.enabled=false"); - assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class); - Map beans = context - .getBeansOfType(FeignBlockingLoadBalancerClient.class); - assertThat(beans).as("Missing bean of type %s", Http2Client.class).hasSize(1); - Client client = beans.get("feignClient").getDelegate(); - assertThat(client).isInstanceOf(Http2Client.class); - Http2Client http2Client = (Http2Client) client; - HttpClient httpClient = (HttpClient) getField(http2Client, "client"); - assertThat(httpClient).isInstanceOf(HttpClient.class); - } - - @Test - void shouldInstantiateHttpFeignClient5WhenAvailableAndOkHttpDisabled() { - ConfigurableApplicationContext context = initContext("spring.cloud.openfeign.okhttp.enabled=false", - "spring.cloud.loadbalancer.retry.enabled=false"); - assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class); - assertLoadBalanced(context, ApacheHttp5Client.class); - } - - @Test - void shouldInstantiateHttpFeignClient5WhenAvailableAndHttp2ClientDisabled() { - ConfigurableApplicationContext context = initContext("spring.cloud.openfeign.http2client.enabled=false", - "spring.cloud.loadbalancer.retry.enabled=false"); - assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class); - assertLoadBalanced(context, ApacheHttp5Client.class); - } - - @Test - void shouldInstantiateRetryableDefaultFeignBlockingLoadBalancerClientWhenHttpClientDisabled() { - ConfigurableApplicationContext context = initContext("spring.cloud.openfeign.httpclient.hc5.enabled=false"); - assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class); - assertLoadBalancedWithRetries(context, Client.Default.class); - } - - @Test - void shouldInstantiateRetryableOkHttpFeignClientWhenEnabled() { - ConfigurableApplicationContext context = initContext("spring.cloud.openfeign.httpclient.hc5.enabled=false", - "spring.cloud.openfeign.okhttp.enabled=true"); - assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class); - assertLoadBalancedWithRetries(context, OkHttpClient.class); - } - - @Test - void shouldInstantiateRetryableHttp2ClientFeignClientWhenEnabled() { - ConfigurableApplicationContext context = initContext("spring.cloud.openfeign.httpclient.hc5.enabled=false", - "spring.cloud.openfeign.http2client.enabled=true"); - assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class); - assertLoadBalancedWithRetries(context, Http2Client.class); - } - - @Test - void shouldInstantiateRetryableHttpFeignClient5WhenEnabled() { - ConfigurableApplicationContext context = initContext(); - assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class); - assertLoadBalancedWithRetries(context, ApacheHttp5Client.class); - } - - private ConfigurableApplicationContext initContext(String... properties) { - return new SpringApplicationBuilder().web(WebApplicationType.NONE).properties(properties) - .sources(LoadBalancerAutoConfiguration.class, BlockingLoadBalancerClientAutoConfiguration.class, - FeignLoadBalancerAutoConfiguration.class, FeignAutoConfiguration.class) - .run(); - } - - private void assertThatOneBeanPresent(ConfigurableApplicationContext context, Class beanClass) { - Map beans = context.getBeansOfType(beanClass); - assertThat(beans).as("Missing bean of type %s", beanClass).hasSize(1); - } - - private void assertLoadBalanced(ConfigurableApplicationContext context, Class delegateClass) { - Map beans = context - .getBeansOfType(FeignBlockingLoadBalancerClient.class); - assertThat(beans).as("Missing bean of type %s", delegateClass).hasSize(1); - assertThat(beans.get("feignClient").getDelegate()).isInstanceOf(delegateClass); - } - - private void assertLoadBalancedWithRetries(ConfigurableApplicationContext context, Class delegateClass) { - Map retryableBeans = context - .getBeansOfType(RetryableFeignBlockingLoadBalancerClient.class); - assertThat(retryableBeans).hasSize(1); - Map beans = context - .getBeansOfType(FeignBlockingLoadBalancerClient.class); - assertThat(beans).isEmpty(); - assertThat(retryableBeans.get("feignRetryClient").getDelegate()).isInstanceOf(delegateClass); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClientTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClientTests.java deleted file mode 100644 index 7cd2e358e..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/RetryableFeignBlockingLoadBalancerClientTests.java +++ /dev/null @@ -1,403 +0,0 @@ -/* - * Copyright 2013-2023 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.loadbalancer; - -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -import feign.Client; -import feign.Request; -import feign.Response; -import org.apache.commons.io.IOUtils; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.ArgumentCaptor; -import org.mockito.junit.jupiter.MockitoExtension; - -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.client.loadbalancer.CompletionContext; -import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory; -import org.springframework.cloud.client.loadbalancer.LoadBalancerLifecycle; -import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties; -import org.springframework.cloud.client.loadbalancer.ResponseData; -import org.springframework.cloud.client.loadbalancer.RetryableRequestContext; -import org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient; -import org.springframework.cloud.loadbalancer.blocking.retry.BlockingLoadBalancedRetryPolicy; -import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * Tests for {@link RetryableFeignBlockingLoadBalancerClient}. Note: the underlying - * {@link BlockingLoadBalancerClient} is already extensively tested in the Spring Cloud - * Commons project, so here we are only testing the interactions between - * {@link RetryableFeignBlockingLoadBalancerClient} and its delegates. - * - * @author Olga Maciaszek-Sharma - * @author changjin wei(魏昌进) - * @author Wonsik Cheung - * @author Andriy Pikozh - * @see BlockingLoadBalancerClientTests - */ -@ExtendWith(MockitoExtension.class) -class RetryableFeignBlockingLoadBalancerClientTests { - - private final Client delegate = mock(Client.class); - - private final LoadBalancedRetryFactory retryFactory = mock(LoadBalancedRetryFactory.class); - - private final BlockingLoadBalancerClient loadBalancerClient = mock(BlockingLoadBalancerClient.class); - - private final LoadBalancerClientFactory loadBalancerClientFactory = mock(LoadBalancerClientFactory.class); - - private final LoadBalancerProperties properties = new LoadBalancerProperties(); - - private final List transformers = Arrays.asList(new InstanceIdTransformer(), - new ServiceIdTransformer()); - - private final RetryableFeignBlockingLoadBalancerClient feignBlockingLoadBalancerClient = new RetryableFeignBlockingLoadBalancerClient( - delegate, loadBalancerClient, retryFactory, loadBalancerClientFactory, transformers); - - private final ServiceInstance serviceInstance = new DefaultServiceInstance("test-a", "test", "testhost", 80, false); - - @BeforeEach - void setUp() { - when(loadBalancerClientFactory.getProperties(any(String.class))).thenReturn(properties); - when(retryFactory.createRetryPolicy(any(), eq(loadBalancerClient))) - .thenReturn(new BlockingLoadBalancedRetryPolicy(properties)); - when(loadBalancerClient.choose(eq("test"), any())).thenReturn(serviceInstance); - } - - @Test - void shouldExtractServiceIdFromRequestUrl() throws IOException { - Request request = testRequest(); - Response response = testResponse(200); - when(delegate.execute(any(), any())).thenReturn(response); - when(retryFactory.createRetryPolicy(any(), eq(loadBalancerClient))) - .thenReturn(new BlockingLoadBalancedRetryPolicy(properties)); - when(loadBalancerClient.reconstructURI(serviceInstance, URI.create("http://test/path"))) - .thenReturn(URI.create("http://testhost:80/path")); - - feignBlockingLoadBalancerClient.execute(request, new Request.Options()); - - verify(loadBalancerClient).choose(eq("test"), any()); - verify(loadBalancerClient).reconstructURI(serviceInstance, URI.create("http://test/path")); - - verify(delegate).execute( - argThat((Request actualRequest) -> actualRequest.url().equals("http://testhost:80/path")), any()); - } - - private Response testResponse(int status) { - return Response.builder().request(testRequest()).status(status).build(); - } - - private Response testResponse(int status, String body) { - // ByteArrayInputStream ignores close() and must be wrapped - InputStream reallyCloseable = new BufferedInputStream( - new ByteArrayInputStream(body.getBytes(StandardCharsets.UTF_8))); - return Response.builder().request(testRequest()).status(status).body(reallyCloseable, null).build(); - } - - @Test - void shouldExecuteOriginalRequestIfInstanceNotFound() throws IOException { - Request request = testRequest(); - Response response = testResponse(503); - when(loadBalancerClient.choose(eq("test"), any())).thenReturn(null); - when(delegate.execute(any(), any())).thenReturn(response); - when(retryFactory.createRetryPolicy(any(), eq(loadBalancerClient))) - .thenReturn(new BlockingLoadBalancedRetryPolicy(properties)); - - feignBlockingLoadBalancerClient.execute(request, new Request.Options()); - - verify(delegate).execute(eq(request), any()); - } - - @Test - void shouldRetryOnRepeatableStatusCode() throws IOException { - properties.getRetry().getRetryableStatusCodes().add(503); - Request request = testRequest(); - Response response = testResponse(503); - when(delegate.execute(any(), any())).thenReturn(response); - when(retryFactory.createRetryPolicy(any(), eq(loadBalancerClient))) - .thenReturn(new BlockingLoadBalancedRetryPolicy(properties)); - when(loadBalancerClient.reconstructURI(serviceInstance, URI.create("http://test/path"))) - .thenReturn(URI.create("http://testhost:80/path")); - - feignBlockingLoadBalancerClient.execute(request, new Request.Options()); - - verify(loadBalancerClient, times(2)).choose(eq("test"), any()); - verify(loadBalancerClient, times(2)).reconstructURI(serviceInstance, URI.create("http://test/path")); - verify(delegate, times(2)).execute(any(), any()); - } - - @Test - void shouldReuseServerInstanceOnSameInstanceRetry() throws IOException { - properties.getRetry().setMaxRetriesOnSameServiceInstance(1); - properties.getRetry().setMaxRetriesOnNextServiceInstance(0); - properties.getRetry().getRetryableStatusCodes().add(503); - Request request = testRequest(); - Response response = testResponse(503); - when(delegate.execute(any(), any())).thenReturn(response); - when(retryFactory.createRetryPolicy(any(), eq(loadBalancerClient))) - .thenReturn(new BlockingLoadBalancedRetryPolicy(properties)); - when(loadBalancerClient.reconstructURI(serviceInstance, URI.create("http://test/path"))) - .thenReturn(URI.create("http://testhost:80/path")); - - feignBlockingLoadBalancerClient.execute(request, new Request.Options()); - - verify(loadBalancerClient, times(1)).choose(eq("test"), any()); - verify(loadBalancerClient, times(2)).reconstructURI(serviceInstance, URI.create("http://test/path")); - verify(delegate, times(2)).execute(any(), any()); - } - - @Test - void shouldReuseServerInstanceOnSameInstanceRetryWithBothSameAndNextRetries() throws IOException { - properties.getRetry().setMaxRetriesOnSameServiceInstance(1); - properties.getRetry().setMaxRetriesOnNextServiceInstance(1); - properties.getRetry().getRetryableStatusCodes().add(503); - Request request = testRequest(); - Response response = testResponse(503); - when(delegate.execute(any(), any())).thenReturn(response); - when(retryFactory.createRetryPolicy(any(), eq(loadBalancerClient))) - .thenReturn(new BlockingLoadBalancedRetryPolicy(properties)); - when(loadBalancerClient.reconstructURI(serviceInstance, URI.create("http://test/path"))) - .thenReturn(URI.create("http://testhost:80/path")); - - feignBlockingLoadBalancerClient.execute(request, new Request.Options()); - - verify(loadBalancerClient, times(2)).choose(eq("test"), any()); - verify(loadBalancerClient, times(4)).reconstructURI(serviceInstance, URI.create("http://test/path")); - verify(delegate, times(4)).execute(any(), any()); - } - - @Test - void shouldNotRetryOnDisabled() throws IOException { - properties.getRetry().setEnabled(false); - Request request = testRequest(); - when(delegate.execute(any(), any())).thenThrow(new IOException()); - when(retryFactory.createRetryPolicy(any(), eq(loadBalancerClient))) - .thenReturn(new BlockingLoadBalancedRetryPolicy(properties)); - - assertThatThrownBy(() -> feignBlockingLoadBalancerClient.execute(request, new Request.Options())) - .isInstanceOf(IOException.class); - - verify(delegate, times(1)).execute(any(), any()); - } - - @Test - void shouldExposeResponseBodyOnRetry() throws IOException { - properties.getRetry().getRetryableStatusCodes().add(503); - Request request = testRequest(); - when(delegate.execute(any(), any())).thenReturn(testResponse(503, "foo"), testResponse(503, "foo")); - when(retryFactory.createRetryPolicy(any(), eq(loadBalancerClient))) - .thenReturn(new BlockingLoadBalancedRetryPolicy(properties)); - when(loadBalancerClient.reconstructURI(serviceInstance, URI.create("http://test/path"))) - .thenReturn(URI.create("http://testhost:80/path")); - - Response response = feignBlockingLoadBalancerClient.execute(request, new Request.Options()); - - String bodyContent = IOUtils.toString(response.body().asReader(StandardCharsets.UTF_8)); - assertThat(bodyContent).isEqualTo("foo"); - } - - @Test - void shouldPassCorrectRequestToDelegate() throws IOException { - Request request = testRequest(); - Request.Options options = new Request.Options(); - String url = "http://127.0.0.1/path"; - ServiceInstance serviceInstance = new DefaultServiceInstance("test-1", "test", "test-host", 8888, false); - when(loadBalancerClient.choose(eq("test"), any())).thenReturn(serviceInstance); - when(loadBalancerClient.reconstructURI(serviceInstance, URI.create("http://test/path"))) - .thenReturn(URI.create(url)); - Response response = testResponse(200); - when(delegate.execute(any(), any())).thenReturn(response); - when(retryFactory.createRetryPolicy(any(), eq(loadBalancerClient))) - .thenReturn(new BlockingLoadBalancedRetryPolicy(properties)); - - feignBlockingLoadBalancerClient.execute(request, options); - - ArgumentCaptor captor = ArgumentCaptor.forClass(Request.class); - verify(delegate, times(1)).execute(captor.capture(), eq(options)); - Request actualRequest = captor.getValue(); - assertThat(actualRequest.httpMethod()).isEqualTo(Request.HttpMethod.GET); - assertThat(actualRequest.url()).isEqualTo(url); - assertThat(actualRequest.headers()).hasSize(3); - assertThat(actualRequest.headers()).containsEntry(HttpHeaders.CONTENT_TYPE, - Collections.singletonList(MediaType.APPLICATION_JSON_VALUE)); - assertThat(actualRequest.headers()).containsEntry("X-ServiceId", Collections.singletonList("test")); - assertThat(actualRequest.headers()).containsEntry("X-InstanceId", Collections.singletonList("test-1")); - assertThat(new String(actualRequest.body())).isEqualTo("hello"); - } - - @Test - void shouldExecuteLoadBalancerLifecycleCallbacks() throws IOException { - Request request = testRequest(); - Request.Options options = new Request.Options(); - String url = "http://127.0.0.1/path"; - ServiceInstance serviceInstance = new DefaultServiceInstance("test-1", "test", "test-host", 8888, false); - when(loadBalancerClient.choose(eq("test"), any())).thenReturn(serviceInstance); - when(loadBalancerClient.reconstructURI(serviceInstance, URI.create("http://test/path"))) - .thenReturn(URI.create(url)); - Response response = testResponse(200); - when(delegate.execute(any(), any())).thenReturn(response); - String callbackTestHint = "callbackTestHint"; - properties.getHint().put("test", callbackTestHint); - Map loadBalancerLifecycleBeans = new HashMap<>(); - loadBalancerLifecycleBeans.put("loadBalancerLifecycle", new TestLoadBalancerLifecycle()); - loadBalancerLifecycleBeans.put("anotherLoadBalancerLifecycle", new AnotherLoadBalancerLifecycle()); - when(loadBalancerClientFactory.getInstances("test", LoadBalancerLifecycle.class)) - .thenReturn(loadBalancerLifecycleBeans); - - feignBlockingLoadBalancerClient.execute(request, options); - - Collection> lifecycleLogRequests = ((TestLoadBalancerLifecycle) loadBalancerLifecycleBeans - .get("loadBalancerLifecycle")).getStartLog().values(); - Collection> lifecycleLogStartedRequests = ((TestLoadBalancerLifecycle) loadBalancerLifecycleBeans - .get("loadBalancerLifecycle")).getStartRequestLog().values(); - Collection> anotherLifecycleLogRequests = ((AnotherLoadBalancerLifecycle) loadBalancerLifecycleBeans - .get("anotherLoadBalancerLifecycle")).getCompleteLog().values(); - assertThat(lifecycleLogRequests).extracting(lbRequest -> lbRequest.getContext().getHint()) - .contains(callbackTestHint); - assertThat(lifecycleLogStartedRequests).extracting(lbRequest -> lbRequest.getContext().getHint()) - .contains(callbackTestHint); - assertThat(anotherLifecycleLogRequests) - .extracting(completionContext -> completionContext.getClientResponse().getHttpStatus()) - .contains(HttpStatus.OK); - } - - private Request testRequest() { - return testRequest("test"); - } - - private Request testRequest(String host) { - return Request.create(Request.HttpMethod.GET, "http://" + host + "/path", testHeaders(), "hello".getBytes(), - StandardCharsets.UTF_8, null); - } - - private Map> testHeaders() { - Map> feignHeaders = new HashMap<>(); - feignHeaders.put(HttpHeaders.CONTENT_TYPE, Collections.singletonList(MediaType.APPLICATION_JSON_VALUE)); - return feignHeaders; - - } - - protected static class TestLoadBalancerLifecycle - implements LoadBalancerLifecycle { - - final Map> startLog = new ConcurrentHashMap<>(); - - final Map> startRequestLog = new ConcurrentHashMap<>(); - - final Map> completeLog = new ConcurrentHashMap<>(); - - @Override - public void onStart(org.springframework.cloud.client.loadbalancer.Request request) { - startLog.put(getName() + UUID.randomUUID(), request); - } - - @Override - public void onStartRequest( - org.springframework.cloud.client.loadbalancer.Request request, - org.springframework.cloud.client.loadbalancer.Response lbResponse) { - startRequestLog.put(getName() + UUID.randomUUID(), request); - } - - @Override - public void onComplete( - CompletionContext completionContext) { - completeLog.put(getName() + UUID.randomUUID(), completionContext); - } - - Map> getStartLog() { - return startLog; - } - - Map> getCompleteLog() { - return completeLog; - } - - Map> getStartRequestLog() { - return startRequestLog; - } - - protected String getName() { - return this.getClass().getSimpleName(); - } - - } - - protected static class AnotherLoadBalancerLifecycle - extends RetryableFeignBlockingLoadBalancerClientTests.TestLoadBalancerLifecycle { - - @Override - protected String getName() { - return this.getClass().getSimpleName(); - } - - } - - private static class InstanceIdTransformer implements LoadBalancerFeignRequestTransformer { - - @Override - public Request transformRequest(Request request, ServiceInstance instance) { - Map> headers = new HashMap<>(request.headers()); - headers.put("X-InstanceId", Collections.singletonList(instance.getInstanceId())); - return Request.create(request.httpMethod(), request.url(), headers, request.body(), request.charset(), - request.requestTemplate()); - } - - } - - private static class ServiceIdTransformer implements LoadBalancerFeignRequestTransformer { - - @Override - public Request transformRequest(Request request, ServiceInstance instance) { - Map> headers = new HashMap<>(request.headers()); - headers.put("X-ServiceId", Collections.singletonList(instance.getServiceId())); - return Request.create(request.httpMethod(), request.url(), headers, request.body(), request.charset(), - request.requestTemplate()); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/XForwardedHeadersTransformerTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/XForwardedHeadersTransformerTests.java deleted file mode 100644 index 3330ee235..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/loadbalancer/XForwardedHeadersTransformerTests.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2013-2022 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.loadbalancer; - -import java.nio.charset.StandardCharsets; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import feign.Request; -import org.junit.jupiter.api.Test; - -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties; -import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * Tests for {@link XForwardedHeadersTransformer}. - * - * @author changjin wei(魏昌进) - */ -class XForwardedHeadersTransformerTests { - - private final LoadBalancerClientFactory loadBalancerClientFactory = mock(LoadBalancerClientFactory.class); - - private final LoadBalancerProperties loadBalancerProperties = new LoadBalancerProperties(); - - private final ServiceInstance serviceInstance = new DefaultServiceInstance("test1", "test", "test.org", 8080, - false); - - private final Request request = testRequest(); - - private Request testRequest() { - return testRequest("spring.io"); - } - - private Request testRequest(String host) { - return Request.create(Request.HttpMethod.GET, "https://" + host + "/path", testHeaders(), "hello".getBytes(), - StandardCharsets.UTF_8, null); - } - - private Map> testHeaders() { - Map> feignHeaders = new HashMap<>(); - feignHeaders.put(HttpHeaders.CONTENT_TYPE, Collections.singletonList(MediaType.APPLICATION_JSON_VALUE)); - return feignHeaders; - - } - - @Test - void shouldAppendXForwardedHeadersIfEnabled() { - loadBalancerProperties.getXForwarded().setEnabled(true); - when(loadBalancerClientFactory.getProperties("test")).thenReturn(loadBalancerProperties); - XForwardedHeadersTransformer transformer = new XForwardedHeadersTransformer(loadBalancerClientFactory); - - Request newRequest = transformer.transformRequest(request, serviceInstance); - - assertThat(newRequest.headers()).containsKey("X-Forwarded-Host"); - assertThat(newRequest.headers()).containsEntry("X-Forwarded-Host", Collections.singleton("spring.io")); - assertThat(newRequest.headers()).containsKey("X-Forwarded-Proto"); - assertThat(newRequest.headers()).containsEntry("X-Forwarded-Proto", Collections.singleton("https")); - - } - - @Test - void shouldNotAppendXForwardedHeadersIfDefault() { - when(loadBalancerClientFactory.getProperties("test")).thenReturn(loadBalancerProperties); - XForwardedHeadersTransformer transformer = new XForwardedHeadersTransformer(loadBalancerClientFactory); - - Request newRequest = transformer.transformRequest(request, serviceInstance); - - assertThat(newRequest.headers()).doesNotContainKey("X-Forwarded-Host"); - assertThat(newRequest.headers()).doesNotContainKey("X-Forwarded-Proto"); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/protocol/FeignOkHttpProtocolsTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/protocol/FeignOkHttpProtocolsTests.java deleted file mode 100644 index 5e0393c8a..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/protocol/FeignOkHttpProtocolsTests.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2013-2023 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.protocol; - -import java.lang.reflect.Field; - -import feign.Client; -import okhttp3.Protocol; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -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.loadbalancer.annotation.LoadBalancerClients; -import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.util.ReflectionUtils; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author changjin wei(魏昌进) - */ -@SpringBootTest(classes = FeignOkHttpProtocolsTests.Application.class, webEnvironment = WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=feignclienttest", "spring.cloud.openfeign.circuitbreaker.enabled=false", - "spring.cloud.openfeign.httpclient.hc5.enabled=false", "spring.cloud.openfeign.okhttp.enabled=true", - "spring.cloud.httpclientfactories.ok.enabled=true", "spring.cloud.loadbalancer.retry.enabled=false", - "server.http2.enabled=true", "spring.cloud.openfeign.httpclient.okhttp.protocols=H2_PRIOR_KNOWLEDGE" }) -@DirtiesContext -class FeignOkHttpProtocolsTests { - - @Autowired - private Client feignClient; - - @Test - void shouldCreateCorrectFeignClientBeanWithProtocolFromProperties() { - assertThat(feignClient).isInstanceOf(FeignBlockingLoadBalancerClient.class); - FeignBlockingLoadBalancerClient client = (FeignBlockingLoadBalancerClient) feignClient; - Client delegate = client.getDelegate(); - assertThat(delegate).isInstanceOf(feign.okhttp.OkHttpClient.class); - okhttp3.OkHttpClient OkHttpClient = (okhttp3.OkHttpClient) getField(delegate, "delegate"); - assertThat(OkHttpClient.protocols()).containsExactly(Protocol.H2_PRIOR_KNOWLEDGE); - } - - protected Object getField(Object target, String name) { - Field field = ReflectionUtils.findField(target.getClass(), name); - ReflectionUtils.makeAccessible(field); - return ReflectionUtils.getField(field, target); - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @LoadBalancerClients - @Import(NoSecurityConfiguration.class) - protected static class Application { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/security/OAuth2AccessTokenInterceptorTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/security/OAuth2AccessTokenInterceptorTests.java deleted file mode 100644 index 686ebab55..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/security/OAuth2AccessTokenInterceptorTests.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2015-2022 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.security; - -import java.time.Instant; - -import feign.Request.HttpMethod; -import feign.RequestTemplate; -import feign.Target; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.security.oauth2.client.OAuth2AuthorizeRequest; -import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; -import org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager; -import org.springframework.security.oauth2.client.registration.ClientRegistration; -import org.springframework.security.oauth2.core.AuthorizationGrantType; -import org.springframework.security.oauth2.core.OAuth2AccessToken; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * Tests for {@link OAuth2AccessTokenInterceptor}. - * - * @author Dangzhicairang(小水牛) - * @author Olga Maciaszek-Sharma - * - */ -class OAuth2AccessTokenInterceptorTests { - - private final OAuth2AuthorizedClientManager mockOAuth2AuthorizedClientManager = mock( - OAuth2AuthorizedClientManager.class); - - private OAuth2AccessTokenInterceptor oAuth2AccessTokenInterceptor; - - private RequestTemplate requestTemplate; - - private static final String DEFAULT_CLIENT_REGISTRATION_ID = "feign-client"; - - @BeforeEach - void setUp() { - requestTemplate = new RequestTemplate().method(HttpMethod.GET); - Target feignTarget = mock(Target.class); - when(feignTarget.url()).thenReturn("http://test"); - requestTemplate.feignTarget(feignTarget); - } - - @Test - void shouldThrowExceptionWhenNoTokenAcquired() { - oAuth2AccessTokenInterceptor = new OAuth2AccessTokenInterceptor(mockOAuth2AuthorizedClientManager); - when(mockOAuth2AuthorizedClientManager.authorize(any())).thenReturn(null); - - assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> oAuth2AccessTokenInterceptor.apply(requestTemplate)) - .withMessage("OAuth2 token has not been successfully acquired."); - } - - @Test - void shouldAcquireValidToken() { - oAuth2AccessTokenInterceptor = new OAuth2AccessTokenInterceptor(mockOAuth2AuthorizedClientManager); - when(mockOAuth2AuthorizedClientManager.authorize( - argThat((OAuth2AuthorizeRequest request) -> ("test").equals(request.getClientRegistrationId())))) - .thenReturn(validTokenOAuth2AuthorizedClient()); - - oAuth2AccessTokenInterceptor.apply(requestTemplate); - - assertThat(requestTemplate.headers().get("Authorization")).contains("Bearer Valid Token"); - } - - @Test - void shouldAcquireValidTokenFromServiceId() { - when(mockOAuth2AuthorizedClientManager.authorize( - argThat((OAuth2AuthorizeRequest request) -> ("test").equals(request.getClientRegistrationId())))) - .thenReturn(validTokenOAuth2AuthorizedClient()); - oAuth2AccessTokenInterceptor = new OAuth2AccessTokenInterceptor(mockOAuth2AuthorizedClientManager); - - oAuth2AccessTokenInterceptor.apply(requestTemplate); - - assertThat(requestTemplate.headers().get("Authorization")).contains("Bearer Valid Token"); - } - - @Test - void shouldAcquireValidTokenFromSpecifiedClientRegistrationId() { - oAuth2AccessTokenInterceptor = new OAuth2AccessTokenInterceptor(DEFAULT_CLIENT_REGISTRATION_ID, - mockOAuth2AuthorizedClientManager); - when(mockOAuth2AuthorizedClientManager - .authorize(argThat((OAuth2AuthorizeRequest request) -> (DEFAULT_CLIENT_REGISTRATION_ID) - .equals(request.getClientRegistrationId())))).thenReturn(validTokenOAuth2AuthorizedClient()); - - oAuth2AccessTokenInterceptor.apply(requestTemplate); - - assertThat(requestTemplate.headers().get("Authorization")).contains("Bearer Valid Token"); - } - - private OAuth2AccessToken validToken() { - return new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, "Valid Token", Instant.now(), - Instant.now().plusSeconds(60L)); - } - - private OAuth2AuthorizedClient validTokenOAuth2AuthorizedClient() { - return new OAuth2AuthorizedClient(defaultClientRegistration(), "anonymousUser", validToken()); - } - - private ClientRegistration defaultClientRegistration() { - return ClientRegistration.withRegistrationId(DEFAULT_CLIENT_REGISTRATION_ID).clientId("clientId") - .tokenUri("mock token uri").authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS).build(); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/AbstractFormWriterTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/AbstractFormWriterTests.java deleted file mode 100644 index 4786298eb..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/AbstractFormWriterTests.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import org.springframework.http.MediaType; - -/** - * @author Wu Daifu - */ -class AbstractFormWriterTests { - - @Test - void shouldCorrectlyResolveIfApplicableForCollection() { - MockFormWriter formWriter = new MockFormWriter(); - Object object = new Object(); - Assertions.assertFalse(formWriter.isApplicable(object)); - object = new Object[] { new Object(), new Object() }; - Assertions.assertFalse(formWriter.isApplicable(object)); - object = new UserPojo(); - Assertions.assertTrue(formWriter.isApplicable(object)); - object = new UserPojo[] { new UserPojo(), new UserPojo() }; - Assertions.assertTrue(formWriter.isApplicable(object)); - object = new byte[] { '1', '2' }; - Assertions.assertFalse(formWriter.isApplicable(object)); - } - - static class MockFormWriter extends AbstractFormWriter { - - @Override - protected MediaType getContentType() { - return null; - } - - @Override - protected String writeAsString(Object object) { - return null; - } - - } - - static class UserPojo { - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/AbstractSpringMvcContractIntegrationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/AbstractSpringMvcContractIntegrationTests.java deleted file mode 100644 index 994749d62..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/AbstractSpringMvcContractIntegrationTests.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.nio.charset.Charset; - -import feign.Response; -import feign.codec.Decoder; -import feign.codec.Encoder; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; - -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.cloud.test.TestSocketUtils; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.http.HttpHeaders; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * Abstract class for the integration tests for {@link SpringMvcContract}. - * - * @author Ram Anaswara - */ -public class AbstractSpringMvcContractIntegrationTests { - - @BeforeAll - public static void beforeClass() { - System.setProperty("server.port", String.valueOf(TestSocketUtils.findAvailableTcpPort())); - } - - @AfterAll - public static void afterClass() { - System.clearProperty("server.port"); - } - - protected String getUrlQueryParam(Response response) { - return response.request().requestTemplate().queries().get("url").stream().findFirst() - .orElseThrow(IllegalStateException::new); - } - - @FeignClient(name = "test", url = "http://localhost:${server.port}/", - configuration = NoCodecsFeignConfiguration.class) - interface TestClient { - - @PostMapping("/test") - Object sendMessage(@RequestBody String message, @RequestHeader(HttpHeaders.CONTENT_TYPE) String acceptHeader); - - @GetMapping("/get") - Object getMessage(@RequestParam String url); - - } - - @Configuration(proxyBeanMethods = false) - @EnableFeignClients(clients = TestClient.class) - @EnableAutoConfiguration - @RestController - @Import(NoSecurityConfiguration.class) - protected static class Config { - - @PostMapping("/test") - Object sendMessage(@RequestBody String message, @RequestHeader(HttpHeaders.CONTENT_TYPE) String acceptHeader) { - return message; - } - - @GetMapping("/get") - Object getMessage(@RequestParam String url) { - return url; - } - - } - - // Avoid feign.codec.EncodeException - this feature works for users that override - // Encoder - protected static class NoCodecsFeignConfiguration { - - @Bean - public Decoder decoder() { - return (response, type) -> response; - } - - @Bean - public Encoder encoder() { - return (object, bodyType, request) -> request.body(object.toString().getBytes(), Charset.defaultCharset()); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/FeignHttpClientPropertiesTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/FeignHttpClientPropertiesTests.java deleted file mode 100644 index f906fe2c4..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/FeignHttpClientPropertiesTests.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.util.concurrent.TimeUnit; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.cloud.openfeign.support.FeignHttpClientProperties.Hc5Properties.PoolConcurrencyPolicy; -import org.springframework.cloud.openfeign.support.FeignHttpClientProperties.Hc5Properties.PoolReusePolicy; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.annotation.DirtiesContext; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.cloud.openfeign.support.FeignHttpClientProperties.Hc5Properties.DEFAULT_CONNECTION_REQUEST_TIMEOUT; -import static org.springframework.cloud.openfeign.support.FeignHttpClientProperties.Hc5Properties.DEFAULT_CONNECTION_REQUEST_TIMEOUT_UNIT; -import static org.springframework.cloud.openfeign.support.FeignHttpClientProperties.Hc5Properties.DEFAULT_SOCKET_TIMEOUT; -import static org.springframework.cloud.openfeign.support.FeignHttpClientProperties.Hc5Properties.DEFAULT_SOCKET_TIMEOUT_UNIT; - -/** - * @author Ryan Baxter - * @author Nguyen Ky Thanh - * @author changjin wei(魏昌进) - */ -@DirtiesContext -class FeignHttpClientPropertiesTests { - - private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - - @AfterEach - void clear() { - if (this.context != null) { - this.context.close(); - } - } - - @Test - void testDefaults() { - setupContext(); - assertThat(getProperties().getConnectionTimeout()) - .isEqualTo(FeignHttpClientProperties.DEFAULT_CONNECTION_TIMEOUT); - assertThat(getProperties().getMaxConnections()).isEqualTo(FeignHttpClientProperties.DEFAULT_MAX_CONNECTIONS); - assertThat(getProperties().getMaxConnectionsPerRoute()) - .isEqualTo(FeignHttpClientProperties.DEFAULT_MAX_CONNECTIONS_PER_ROUTE); - assertThat(getProperties().getTimeToLive()).isEqualTo(FeignHttpClientProperties.DEFAULT_TIME_TO_LIVE); - assertThat(getProperties().isDisableSslValidation()) - .isEqualTo(FeignHttpClientProperties.DEFAULT_DISABLE_SSL_VALIDATION); - assertThat(getProperties().isFollowRedirects()).isEqualTo(FeignHttpClientProperties.DEFAULT_FOLLOW_REDIRECTS); - assertThat(getProperties().getHc5().getPoolConcurrencyPolicy()).isEqualTo(PoolConcurrencyPolicy.STRICT); - assertThat(getProperties().getHc5().getPoolReusePolicy()).isEqualTo(PoolReusePolicy.FIFO); - assertThat(getProperties().getHc5().getSocketTimeout()).isEqualTo(DEFAULT_SOCKET_TIMEOUT); - assertThat(getProperties().getHc5().getSocketTimeoutUnit()).isEqualTo(DEFAULT_SOCKET_TIMEOUT_UNIT); - assertThat(getProperties().getHc5().getConnectionRequestTimeout()) - .isEqualTo(DEFAULT_CONNECTION_REQUEST_TIMEOUT); - assertThat(getProperties().getHc5().getConnectionRequestTimeoutUnit()) - .isEqualTo(DEFAULT_CONNECTION_REQUEST_TIMEOUT_UNIT); - } - - @Test - void testCustomization() { - TestPropertyValues - .of("spring.cloud.openfeign.httpclient.maxConnections=2", - "spring.cloud.openfeign.httpclient.connectionTimeout=2", - "spring.cloud.openfeign.httpclient.maxConnectionsPerRoute=2", - "spring.cloud.openfeign.httpclient.timeToLive=2", - "spring.cloud.openfeign.httpclient.disableSslValidation=true", - "spring.cloud.openfeign.httpclient.followRedirects=false", - "spring.cloud.openfeign.httpclient.disableSslValidation=true", - "spring.cloud.openfeign.httpclient.followRedirects=false", - "spring.cloud.openfeign.httpclient.hc5.poolConcurrencyPolicy=lax", - "spring.cloud.openfeign.httpclient.hc5.poolReusePolicy=lifo", - "spring.cloud.openfeign.httpclient.hc5.socketTimeout=200", - "spring.cloud.openfeign.httpclient.hc5.socketTimeoutUnit=milliseconds", - "spring.cloud.openfeign.httpclient.hc5.connectionRequestTimeout=200", - "spring.cloud.openfeign.httpclient.hc5.connectionRequestTimeoutUnit=milliseconds") - .applyTo(this.context); - setupContext(); - assertThat(getProperties().getMaxConnections()).isEqualTo(2); - assertThat(getProperties().getConnectionTimeout()).isEqualTo(2); - assertThat(getProperties().getMaxConnectionsPerRoute()).isEqualTo(2); - assertThat(getProperties().getTimeToLive()).isEqualTo(2L); - assertThat(getProperties().isDisableSslValidation()).isTrue(); - assertThat(getProperties().isFollowRedirects()).isFalse(); - assertThat(getProperties().getHc5().getPoolConcurrencyPolicy()).isEqualTo(PoolConcurrencyPolicy.LAX); - assertThat(getProperties().getHc5().getPoolReusePolicy()).isEqualTo(PoolReusePolicy.LIFO); - assertThat(getProperties().getHc5().getSocketTimeout()).isEqualTo(200); - assertThat(getProperties().getHc5().getSocketTimeoutUnit()).isEqualTo(TimeUnit.MILLISECONDS); - assertThat(getProperties().getHc5().getConnectionRequestTimeout()).isEqualTo(200); - assertThat(getProperties().getHc5().getConnectionRequestTimeoutUnit()).isEqualTo(TimeUnit.MILLISECONDS); - } - - private void setupContext() { - this.context.register(PropertyPlaceholderAutoConfiguration.class, TestConfiguration.class); - this.context.refresh(); - } - - private FeignHttpClientProperties getProperties() { - return this.context.getBean(FeignHttpClientProperties.class); - } - - @Configuration(proxyBeanMethods = false) - @EnableConfigurationProperties - protected static class TestConfiguration { - - @Bean - FeignHttpClientProperties zuulProperties() { - return new FeignHttpClientProperties(); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageJacksonModuleTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageJacksonModuleTests.java deleted file mode 100644 index dc8bc7695..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageJacksonModuleTests.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.util.ArrayList; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Test for {@link PageJacksonModule}. - * - * @author Ruben Vervaeke - * @author Olga Maciaszek-Sharma - * @author Pedro Mendes - * @author Nikita Konev - */ -public class PageJacksonModuleTests { - - private static ObjectMapper objectMapper; - - @BeforeAll - public static void initialize() { - objectMapper = new ObjectMapper(); - objectMapper.registerModule(new PageJacksonModule()); - objectMapper.registerModule(new SortJacksonModule()); - } - - @ParameterizedTest - @ValueSource(strings = { "totalElements", "total-elements", "total_elements", "totalelements", "TotalElements" }) - public void deserializePage(String totalElements) throws JsonProcessingException { - // Given - String pageJson = "{\"content\":[\"A name\"], \"number\":1, \"size\":2, \"" + totalElements + "\": 3}"; - // When - Page result = objectMapper.readValue(pageJson, Page.class); - // Then - assertThat(result).isNotNull(); - assertThat(result.getTotalElements()).isEqualTo(3); - assertThat(result.getContent()).hasSize(1); - assertThat(result.getPageable()).isNotNull(); - assertThat(result.getPageable().getPageSize()).isEqualTo(2); - assertThat(result.getPageable().getPageNumber()).isEqualTo(1); - } - - @Test - public void serializeAndDeserializeEmpty() throws JsonProcessingException { - // Given - PageImpl objects = new PageImpl<>(new ArrayList<>(), Pageable.ofSize(1), 0); - String pageJson = objectMapper.writeValueAsString(objects); - // When - Page result = objectMapper.readValue(pageJson, Page.class); - // Then - assertThat(result).isNotNull(); - assertThat(result.getTotalElements()).isEqualTo(0); - assertThat(result.getContent()).hasSize(0); - } - - @Test - public void serializeAndDeserializeFilledMultiple() throws JsonProcessingException { - // Given - ArrayList pageElements = new ArrayList<>(); - pageElements.add("first element"); - pageElements.add("second element"); - PageImpl objects = new PageImpl<>(pageElements, PageRequest.of(6, 2), 100); - assertThat(objects.getContent()).hasSize(2); - assertThat(objects.getPageable().getPageSize()).isEqualTo(2); - - String pageJson = objectMapper.writeValueAsString(objects); - // When - Page result = objectMapper.readValue(pageJson, Page.class); - // Then - assertThat(result).isNotNull(); - assertThat(result.getTotalElements()).isEqualTo(100); - assertThat(result.getContent()).hasSize(2); - assertThat(result.getContent().get(0)).isEqualTo("first element"); - assertThat(result.getContent().get(1)).isEqualTo("second element"); - assertThat(result.getPageable().getPageSize()).isEqualTo(2); - assertThat(result.getPageable().getPageNumber()).isEqualTo(6); - } - - @Test - public void serializeAndDeserializeEmptyCascade() throws JsonProcessingException { - // Given - PageImpl objects = new PageImpl<>(new ArrayList<>(), Pageable.ofSize(1), 0); - String pageJson = objectMapper.writeValueAsString(objects); - // When - Page result = objectMapper.readValue(pageJson, Page.class); - // Then - assertThat(result).isNotNull(); - assertThat(result.getTotalElements()).isEqualTo(0); - assertThat(result.getContent()).hasSize(0); - - String cascadedPageJson = objectMapper.writeValueAsString(result); - Page cascadedResult = objectMapper.readValue(cascadedPageJson, Page.class); - assertThat(cascadedResult).isNotNull(); - assertThat(cascadedResult.getTotalElements()).isEqualTo(0); - assertThat(cascadedResult.getContent()).hasSize(0); - } - - @Test - public void serializeAndDeserializeFilledMultipleCascade() throws JsonProcessingException { - // Given - ArrayList pageElements = new ArrayList<>(); - pageElements.add("first element in cascaded serialization"); - pageElements.add("second element in cascaded serialization"); - PageImpl objects = new PageImpl<>(pageElements, PageRequest.of(6, 2), 100); - assertThat(objects.getContent()).hasSize(2); - assertThat(objects.getPageable().getPageSize()).isEqualTo(2); - - String pageJson = objectMapper.writeValueAsString(objects); - // When - Page result = objectMapper.readValue(pageJson, Page.class); - // Then - assertThat(result).isNotNull(); - assertThat(result.getTotalElements()).isEqualTo(100); - assertThat(result.getContent()).hasSize(2); - assertThat(result.getContent().get(0)).isEqualTo("first element in cascaded serialization"); - assertThat(result.getContent().get(1)).isEqualTo("second element in cascaded serialization"); - assertThat(result.getPageable().getPageSize()).isEqualTo(2); - assertThat(result.getPageable().getPageNumber()).isEqualTo(6); - - String cascadedPageJson = objectMapper.writeValueAsString(result); - Page cascadedResult = objectMapper.readValue(cascadedPageJson, Page.class); - // Then - assertThat(cascadedResult).isNotNull(); - assertThat(cascadedResult.getTotalElements()).isEqualTo(100); - assertThat(cascadedResult.getContent()).hasSize(2); - assertThat(cascadedResult.getContent().get(0)).isEqualTo("first element in cascaded serialization"); - assertThat(cascadedResult.getContent().get(1)).isEqualTo("second element in cascaded serialization"); - assertThat(cascadedResult.getPageable().getPageSize()).isEqualTo(2); - assertThat(cascadedResult.getPageable().getPageNumber()).isEqualTo(6); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableEncoderTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableEncoderTests.java deleted file mode 100644 index 2bbf2710f..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableEncoderTests.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import feign.RequestTemplate; -import feign.codec.Encoder; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.openfeign.FeignClientFactory; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.test.annotation.DirtiesContext; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * Tests the pagination encoding and sorting. - * - * @author Charlie Mordant. - * @author Yanming Zhou - */ -@SpringBootTest(classes = SpringEncoderTests.Application.class, webEnvironment = RANDOM_PORT, - value = { "spring.application.name=springencodertest", "spring.jmx.enabled=false" }) -@DirtiesContext -class PageableEncoderTests { - - public static final int PAGE = 1; - - public static final int SIZE = 10; - - public static final String SORT_2 = "sort2"; - - public static final String SORT_1 = "sort1"; - - @Autowired - private FeignClientFactory context; - - protected String getPageParameter() { - return "page"; - } - - protected String getSizeParameter() { - return "size"; - } - - protected String getSortParameter() { - return "sort"; - } - - @Test - void testPaginationAndSortingRequest() { - Encoder encoder = this.context.getInstance("foo", Encoder.class); - assertThat(encoder).isNotNull(); - RequestTemplate request = new RequestTemplate(); - encoder.encode(createPageAndSortRequest(), null, request); - - // Request queries shall contain three entries - assertThat(request.queries()).hasSize(3); - // Request page shall contain page - assertThat(request.queries().get(getPageParameter())).contains(String.valueOf(PAGE)); - // Request size shall contain size - assertThat(request.queries().get(getSizeParameter())).contains(String.valueOf(SIZE)); - // Request sort size shall contain sort entries - assertThat(request.queries().get(getSortParameter())).hasSize(2); - } - - private Pageable createPageAndSortRequest() { - return PageRequest.of(PAGE, SIZE, Sort.Direction.ASC, SORT_1, SORT_2); - } - - @Test - void testPaginationRequest() { - Encoder encoder = this.context.getInstance("foo", Encoder.class); - assertThat(encoder).isNotNull(); - RequestTemplate request = new RequestTemplate(); - encoder.encode(createPageAndRequest(), null, request); - assertThat(request.queries().size()).isEqualTo(2); - // Request page shall contain page - assertThat(request.queries().get(getPageParameter())).contains(String.valueOf(PAGE)); - // Request size shall contain size - assertThat(request.queries().get(getSizeParameter())).contains(String.valueOf(SIZE)); - // Request sort size shall contain sort entries - assertThat(request.queries()).doesNotContainKey(getSortParameter()); - } - - private Pageable createPageAndRequest() { - return PageRequest.of(PAGE, SIZE); - } - - @Test - void testSortingRequest() { - Encoder encoder = this.context.getInstance("foo", Encoder.class); - assertThat(encoder).isNotNull(); - RequestTemplate request = new RequestTemplate(); - - encoder.encode(createSort(), null, request); - // Request queries shall contain three entries - assertThat(request.queries().size()).isEqualTo(1); - // Request sort size shall contain sort entries - assertThat(request.queries().get(getSortParameter())).hasSize(2); - } - - private Sort createSort() { - return Sort.by(SORT_1, SORT_2).ascending(); - } - - @Test - void testUnpagedRequest() { - Encoder encoder = this.context.getInstance("foo", Encoder.class); - assertThat(encoder).isNotNull(); - RequestTemplate request = new RequestTemplate(); - - encoder.encode(Pageable.unpaged(), null, request); - // Request queries shall contain three entries - assertThat(request.queries()).isEmpty(); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableEncoderWithSpringDataWebTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableEncoderWithSpringDataWebTests.java deleted file mode 100644 index 407f67de1..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableEncoderWithSpringDataWebTests.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import org.springframework.boot.autoconfigure.data.web.SpringDataWebProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.SpringBootTest; - -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * Tests the pagination encoding and sorting. - * - * @author Yanming Zhou - */ -@EnableConfigurationProperties(SpringDataWebProperties.class) -@SpringBootTest(classes = SpringEncoderTests.Application.class, webEnvironment = RANDOM_PORT, - value = { "spring.application.name=springencodertest", "spring.jmx.enabled=false", - "spring.data.web.pageable.pageParameter=pageNo", "spring.data.web.pageable.sizeParameter=pageSize", - "spring.data.web.sort.sortParameter=orderBy" }) -public class PageableEncoderWithSpringDataWebTests extends PageableEncoderTests { - - @Override - protected String getPageParameter() { - return "pageNo"; - } - - @Override - protected String getSizeParameter() { - return "pageSize"; - } - - @Override - protected String getSortParameter() { - return "orderBy"; - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableSpringQueryMapEncoderTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableSpringQueryMapEncoderTests.java deleted file mode 100644 index bb14e7332..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableSpringQueryMapEncoderTests.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.util.List; -import java.util.Map; - -import feign.QueryMapEncoder; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.openfeign.FeignClientFactory; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.test.annotation.DirtiesContext; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * Tests the pagination encoding and sorting. - * - * @author Yanming Zhou - */ -@SpringBootTest(classes = SpringEncoderTests.Application.class, webEnvironment = RANDOM_PORT, - value = { "spring.application.name=springencodertest", "spring.jmx.enabled=false" }) -@DirtiesContext -class PageableSpringQueryMapEncoderTests { - - public static final int PAGE = 1; - - public static final int SIZE = 10; - - public static final String SORT_2 = "sort2"; - - public static final String SORT_1 = "sort1"; - - @Autowired - private FeignClientFactory context; - - protected String getPageParameter() { - return "page"; - } - - protected String getSizeParameter() { - return "size"; - } - - protected String getSortParameter() { - return "sort"; - } - - @Test - void testPaginationAndSortingRequest() { - QueryMapEncoder encoder = this.context.getInstance("foo", QueryMapEncoder.class); - assertThat(encoder).isNotNull(); - - Map map = encoder.encode(createPageAndSortRequest()); - assertThat(map).hasSize(3); - assertThat((Integer) map.get(getPageParameter())).isEqualTo(PAGE); - assertThat((Integer) map.get(getSizeParameter())).isEqualTo(SIZE); - assertThat((List) map.get(getSortParameter())).hasSize(2); - } - - private Pageable createPageAndSortRequest() { - return PageRequest.of(PAGE, SIZE, Sort.Direction.ASC, SORT_1, SORT_2); - } - - @Test - void testPaginationRequest() { - QueryMapEncoder encoder = this.context.getInstance("foo", QueryMapEncoder.class); - assertThat(encoder).isNotNull(); - - Map map = encoder.encode(createPageAndRequest()); - assertThat(map).hasSize(2); - assertThat((Integer) map.get(getPageParameter())).isEqualTo(PAGE); - assertThat((Integer) map.get(getSizeParameter())).isEqualTo(SIZE); - assertThat(map).doesNotContainKey(getSortParameter()); - } - - private Pageable createPageAndRequest() { - return PageRequest.of(PAGE, SIZE); - } - - @Test - void testSortingRequest() { - QueryMapEncoder encoder = this.context.getInstance("foo", QueryMapEncoder.class); - assertThat(encoder).isNotNull(); - - Map map = encoder.encode(createSort()); - assertThat(map).hasSize(1); - assertThat((List) map.get(getSortParameter())).hasSize(2); - } - - private Sort createSort() { - return Sort.by(SORT_1, SORT_2).ascending(); - } - - @Test - void testUnpagedRequest() { - QueryMapEncoder encoder = this.context.getInstance("foo", QueryMapEncoder.class); - assertThat(encoder).isNotNull(); - - Map map = encoder.encode(Pageable.unpaged()); - assertThat(map).isEmpty(); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableSpringQueryMapEncoderWithSpringDataWebTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableSpringQueryMapEncoderWithSpringDataWebTests.java deleted file mode 100644 index d2d13111a..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableSpringQueryMapEncoderWithSpringDataWebTests.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import org.springframework.boot.autoconfigure.data.web.SpringDataWebProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.SpringBootTest; - -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * Tests the pagination encoding and sorting. - * - * @author Yanming Zhou - */ -@EnableConfigurationProperties(SpringDataWebProperties.class) -@SpringBootTest(classes = SpringEncoderTests.Application.class, webEnvironment = RANDOM_PORT, - value = { "spring.application.name=springencodertest", "spring.jmx.enabled=false", - "spring.data.web.pageable.pageParameter=pageNo", "spring.data.web.pageable.sizeParameter=pageSize", - "spring.data.web.sort.sortParameter=orderBy" }) -public class PageableSpringQueryMapEncoderWithSpringDataWebTests extends PageableSpringQueryMapEncoderTests { - - @Override - protected String getPageParameter() { - return "pageNo"; - } - - @Override - protected String getSizeParameter() { - return "pageSize"; - } - - @Override - protected String getSortParameter() { - return "orderBy"; - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableSupportTest.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableSupportTest.java deleted file mode 100644 index e987d4e2b..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/PageableSupportTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient; -import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; -import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; -import org.springframework.cloud.openfeign.CollectionFormat; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(classes = PageableSupportTest.Config.class, webEnvironment = RANDOM_PORT) -public class PageableSupportTest { - - @Autowired - private PageableFeignClient feignClient; - - @Test - void shouldProperlyFormatPageable() { - String direction = feignClient.performRequest(PageRequest.of(1, 10, Sort.by(Sort.Order.desc("property")))); - - assertThat(direction).isEqualTo("DESC"); - } - - @FeignClient("pageable") - protected interface PageableFeignClient { - - @CollectionFormat(feign.CollectionFormat.CSV) - @GetMapping(path = "/page") - String performRequest(Pageable page); - - } - - @SuppressWarnings("ConstantConditions") - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients(clients = PageableFeignClient.class) - @Import(NoSecurityConfiguration.class) - @LoadBalancerClient(name = "pageable", configuration = LocalClientConfiguration.class) - protected static class Config { - - @GetMapping(path = "/page") - String performRequest(Pageable page) { - return page.getSort().getOrderFor("property").getDirection().toString(); - } - - } - - // Load balancer with fixed server list for "local" pointing to localhost - @Configuration(proxyBeanMethods = false) - static class LocalClientConfiguration { - - @LocalServerPort - private int port = 0; - - @Bean - public ServiceInstanceListSupplier staticServiceInstanceListSupplier() { - return ServiceInstanceListSuppliers.from("pageable", - new DefaultServiceInstance("pageable-1", "pageable", "localhost", port, false)); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SortJacksonModuleTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SortJacksonModuleTests.java deleted file mode 100644 index 303eec4ab..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SortJacksonModuleTests.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.io.IOException; -import java.util.Optional; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Spy; -import org.mockito.junit.jupiter.MockitoExtension; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Sort; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.hasProperty; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; - -/** - * @author Can Bezmen - */ -@ExtendWith(MockitoExtension.class) -class SortJacksonModuleTests { - - @Spy - private ObjectMapper objectMapper; - - @BeforeEach - public void setup() { - objectMapper.registerModules(new PageJacksonModule()); - objectMapper.registerModule(new SortJacksonModule()); - } - - @Test - public void deserializePage() throws JsonProcessingException { - // Given - String pageJson = "{\"content\":[\"A name\"],\"number\":1,\"size\":2,\"totalElements\":3,\"sort\":[{\"direction\":\"ASC\",\"property\":\"field\",\"ignoreCase\":false,\"nullHandling\":\"NATIVE\",\"descending\":false,\"ascending\":true}]}"; - // When - Page result = objectMapper.readValue(pageJson, Page.class); - // Then - assertThat(result, notNullValue()); - assertThat(result, hasProperty("totalElements", is(3L))); - assertThat(result.getContent(), hasSize(1)); - assertThat(result.getPageable(), notNullValue()); - assertThat(result.getPageable().getPageNumber(), is(1)); - assertThat(result.getPageable().getPageSize(), is(2)); - assertThat(result.getPageable().getSort(), notNullValue()); - result.getPageable().getSort(); - Optional optionalOrder = result.getPageable().getSort().get().findFirst(); - if (optionalOrder.isPresent()) { - Sort.Order order = optionalOrder.get(); - assertThat(order, hasProperty("property", is("field"))); - assertThat(order, hasProperty("direction", is(Sort.Direction.ASC))); - } - } - - @Test - public void serializePage() throws IOException { - // Given - Sort sort = Sort.by(Sort.Order.by("fieldName")); - // When - String result = objectMapper.writeValueAsString(sort); - // Then - assertThat(result, containsString("\"direction\":\"ASC\"")); - assertThat(result, containsString("\"property\":\"fieldName\"")); - } - -} 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 deleted file mode 100644 index 7e57595a9..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringEncoderTests.java +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.nio.charset.StandardCharsets; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import feign.RequestTemplate; -import feign.codec.EncodeException; -import feign.codec.Encoder; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -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.openfeign.FeignClientFactory; -import org.springframework.cloud.openfeign.encoding.HttpEncoding; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.core.io.Resource; -import org.springframework.http.HttpInputMessage; -import org.springframework.http.HttpOutputMessage; -import org.springframework.http.MediaType; -import org.springframework.http.converter.AbstractGenericHttpMessageConverter; -import org.springframework.http.converter.GenericHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.http.converter.HttpMessageNotWritableException; -import org.springframework.http.converter.ResourceHttpMessageConverter; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.http.HttpHeaders.ACCEPT; -import static org.springframework.http.HttpHeaders.CONTENT_LENGTH; -import static org.springframework.http.HttpHeaders.CONTENT_TYPE; -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; -import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE; -import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE; -import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; - -/** - * @author Spencer Gibb - * @author Olga Maciaszek-Sharma - * @author Ahmad Mozafarnia - * @author Can Bezmen - * @author Szymon Linowski - */ -@SpringBootTest(classes = SpringEncoderTests.Application.class, webEnvironment = WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=springencodertest", "spring.jmx.enabled=false" }) -@DirtiesContext -class SpringEncoderTests { - - @Autowired - private FeignClientFactory context; - - @Autowired - @Qualifier("myHttpMessageConverter") - private HttpMessageConverter myConverter; - - @Autowired - private ApplicationContext applicationContext; - - @Autowired - @Qualifier("myGenericHttpMessageConverter") - private GenericHttpMessageConverter myGenericConverter; - - @Test - void testCustomHttpMessageConverter() { - Encoder encoder = this.context.getInstance("foo", Encoder.class); - assertThat(encoder).isNotNull(); - RequestTemplate request = new RequestTemplate(); - - encoder.encode("hi", MyType.class, request); - - Collection contentTypeHeader = request.headers().get("Content-Type"); - assertThat(contentTypeHeader).as("missing content type header").isNotNull(); - assertThat(contentTypeHeader.isEmpty()).as("missing content type header").isFalse(); - - String header = contentTypeHeader.iterator().next(); - assertThat(header).as("content type header is wrong").isEqualTo("application/mytype"); - - assertThat(request.requestCharset()).as("request charset is null").isNotNull(); - assertThat(request.requestCharset()).as("request charset is wrong").isEqualTo(StandardCharsets.UTF_8); - } - - // gh-225 - @Test - void testCustomGenericHttpMessageConverter() { - Encoder encoder = this.context.getInstance("foo", Encoder.class); - assertThat(encoder).isNotNull(); - RequestTemplate request = new RequestTemplate(); - - ParameterizedTypeReference> stringListType = new ParameterizedTypeReference<>() { - }; - - request.header(HttpEncoding.CONTENT_TYPE, "application/mygenerictype"); - encoder.encode(Collections.singletonList("hi"), stringListType.getType(), request); - - Collection contentTypeHeader = request.headers().get("Content-Type"); - assertThat(contentTypeHeader).as("missing content type header").isNotNull(); - assertThat(contentTypeHeader.isEmpty()).as("missing content type header").isFalse(); - - String header = contentTypeHeader.iterator().next(); - assertThat(header).as("content type header is wrong").isEqualTo("application/mygenerictype"); - - assertThat(request.requestCharset()).as("request charset is null").isNotNull(); - assertThat(request.requestCharset()).as("request charset is wrong").isEqualTo(StandardCharsets.UTF_8); - } - - @Test - void testBinaryData() { - Encoder encoder = this.context.getInstance("foo", Encoder.class); - assertThat(encoder).isNotNull(); - - RequestTemplate request = new RequestTemplate(); - - encoder.encode("hi".getBytes(), null, request); - - assertThat(((List) request.headers().get(CONTENT_TYPE)).get(0)).as("Request Content-Type is not octet-stream") - .isEqualTo(APPLICATION_OCTET_STREAM_VALUE); - } - - @Test - void testMultipartFile1() { - Encoder encoder = this.context.getInstance("foo", Encoder.class); - assertThat(encoder).isNotNull(); - RequestTemplate request = new RequestTemplate(); - - MultipartFile multipartFile = new MockMultipartFile("test_multipart_file", "hi".getBytes()); - - Assertions.assertThatExceptionOfType(EncodeException.class) - .isThrownBy(() -> encoder.encode(multipartFile, MultipartFile.class, request)); - } - - // gh-105, gh-107 - @Test - void testMultipartFile2() { - Encoder encoder = this.context.getInstance("foo", Encoder.class); - assertThat(encoder).isNotNull(); - RequestTemplate request = new RequestTemplate(); - request.header(ACCEPT, MediaType.MULTIPART_FORM_DATA_VALUE); - request.header(CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE); - - MultipartFile multipartFile = new MockMultipartFile("test_multipart_file", "hi".getBytes()); - encoder.encode(multipartFile, MultipartFile.class, request); - - assertThat((String) ((List) request.headers().get(CONTENT_TYPE)).get(0)) - .as("Request Content-Type is not multipart/form-data") - .contains("multipart/form-data; charset=UTF-8; boundary="); - assertThat(request.headers().get(CONTENT_TYPE).size()).as("There is more than one Content-Type request header") - .isEqualTo(1); - assertThat(((List) request.headers().get(ACCEPT)).get(0)).as("Request Accept header is not multipart/form-data") - .isEqualTo(MULTIPART_FORM_DATA_VALUE); - assertThat(((List) request.headers().get(CONTENT_LENGTH)).get(0)) - .as("Request Content-Length is not equal to 186").isEqualTo("186"); - assertThat(new String(request.body())).as("Body content cannot be decoded").contains("hi"); - } - - @Test - void testFromURLEncodedValue() { - Encoder encoder = context.getInstance("formUrlEncoded", Encoder.class); - assertThat(encoder).isNotNull(); - RequestTemplate request = new RequestTemplate(); - request.header(CONTENT_TYPE, APPLICATION_FORM_URLENCODED_VALUE); - String body = "test"; - encoder.encode(body, String.class, request); - assertThat(new String(request.body())).as("Body content cannot be decoded").contains(body); - } - - @Test - void testNoCharsetForBinaryFiles() { - Encoder encoder = context.getInstance("test", Encoder.class); - assertThat(encoder).isNotNull(); - RequestTemplate request = new RequestTemplate(); - request.header(CONTENT_TYPE, APPLICATION_OCTET_STREAM_VALUE); - Resource resource = applicationContext.getResource("classpath:dummy.pdf"); - - encoder.encode(resource, Resource.class, request); - - assertThat(request.requestBody().getEncoding()).isEmpty(); - } - - @Test - void testUTF8CharsetForTextFiles() { - Encoder encoder = context.getInstance("test", Encoder.class); - assertThat(encoder).isNotNull(); - RequestTemplate request = new RequestTemplate(); - request.header(CONTENT_TYPE, TEXT_PLAIN_VALUE); - String test = "test"; - - encoder.encode(test, String.class, request); - - assertThat(request.requestBody().getEncoding().get().name()).isEqualTo("UTF-8"); - } - - protected interface TestClient { - - } - - protected static class MyType { - - private String value; - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.value = value; - } - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - protected static class Application implements TestClient { - - @Bean - HttpMessageConverter myHttpMessageConverter() { - return new MyHttpMessageConverter(); - } - - @Bean - ResourceHttpMessageConverter resourceHttpMessageConverter() { - return new ResourceHttpMessageConverter(); - } - - @Bean - GenericHttpMessageConverter myGenericHttpMessageConverter() { - return new MyGenericHttpMessageConverter(); - } - - private static class MyHttpMessageConverter extends AbstractGenericHttpMessageConverter { - - MyHttpMessageConverter() { - super(new MediaType("application", "mytype")); - } - - @Override - protected boolean supports(Class clazz) { - return false; - } - - @Override - public boolean canRead(Class clazz, MediaType mediaType) { - return true; - } - - @Override - public boolean canWrite(Class clazz, MediaType mediaType) { - return clazz == String.class; - } - - @Override - protected void writeInternal(Object o, Type type, HttpOutputMessage outputMessage) - throws HttpMessageNotWritableException { - - } - - @Override - protected Object readInternal(Class clazz, HttpInputMessage inputMessage) - throws HttpMessageNotReadableException { - return null; - } - - @Override - public Object read(Type type, Class contextClass, HttpInputMessage inputMessage) - throws HttpMessageNotReadableException { - return null; - } - - } - - private static class MyGenericHttpMessageConverter extends AbstractGenericHttpMessageConverter { - - MyGenericHttpMessageConverter() { - super(new MediaType("application", "mygenerictype")); - } - - private boolean isStringList(Type type) { - if (type instanceof ParameterizedType parameterizedType) { - return parameterizedType.getRawType() == List.class - && parameterizedType.getActualTypeArguments()[0] == String.class; - } - else { - return false; - } - } - - @Override - protected boolean supports(Class clazz) { - return clazz == List.class; - } - - @Override - public boolean canWrite(Type type, Class clazz, MediaType mediaType) { - return canWrite(mediaType) && isStringList(type); - } - - @Override - public boolean canRead(Type type, Class contextClass, MediaType mediaType) { - return canRead(mediaType) && isStringList(type); - } - - @Override - protected void writeInternal(Object o, Type type, HttpOutputMessage outputMessage) - throws HttpMessageNotWritableException { - - } - - @Override - public Object read(Type type, Class contextClass, HttpInputMessage inputMessage) - throws HttpMessageNotReadableException { - return null; - } - - @Override - protected Object readInternal(Class clazz, HttpInputMessage inputMessage) - throws HttpMessageNotReadableException { - return null; - } - - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractIntegrationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractIntegrationTests.java deleted file mode 100644 index 3e32649c8..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractIntegrationTests.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import feign.Response; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatCode; - -/** - * Integration tests for {@link SpringMvcContract}. - * - * @author Olga Maciaszek-Sharma - * @author Ram Anaswara - */ -@SpringBootTest(classes = AbstractSpringMvcContractIntegrationTests.Config.class, - webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) -public class SpringMvcContractIntegrationTests extends AbstractSpringMvcContractIntegrationTests { - - @Autowired - private TestClient client; - - @Test - public void shouldNotThrowInvalidMediaTypeExceptionWhenContentTypeTemplateUsed() { - assertThatCode(() -> client.sendMessage("test", "text/markdown")).doesNotThrowAnyException(); - } - - @Test - public void feignClientShouldPreserveSlash() { - Response response = (Response) client.getMessage("https://www.google.com"); - - String urlQueryParam = getUrlQueryParam(response); - assertThat(urlQueryParam).isEqualTo("https%3A//www.google.com"); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractSlashEncodingIntegrationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractSlashEncodingIntegrationTests.java deleted file mode 100644 index c35fa3f75..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractSlashEncodingIntegrationTests.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2013-2022 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.support; - -import feign.Response; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Integration tests for {@link SpringMvcContract}. - * - * @author Ram Anaswara - */ -@SpringBootTest(classes = SpringMvcContractSlashEncodingIntegrationTests.Config.class, - webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, - properties = { "spring.cloud.openfeign.client.decodeSlash=false" }) -public class SpringMvcContractSlashEncodingIntegrationTests extends AbstractSpringMvcContractIntegrationTests { - - @Autowired - private TestClient client; - - @Test - public void feignClientShouldNotDecodeEncodedSlash() { - Response response = (Response) client.getMessage("https://www.google.com"); - - String urlQueryParam = getUrlQueryParam(response); - assertThat(urlQueryParam).isEqualTo("https%3A%2F%2Fwww.google.com"); - } - -} 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 deleted file mode 100644 index 9f95ba515..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java +++ /dev/null @@ -1,923 +0,0 @@ -/* - * Copyright 2013-2023 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.support; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import feign.MethodMetadata; -import feign.Param; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.cloud.openfeign.CollectionFormat; -import org.springframework.cloud.openfeign.SpringQueryMap; -import org.springframework.core.convert.ConversionService; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.format.annotation.NumberFormat; -import org.springframework.format.number.NumberStyleFormatter; -import org.springframework.format.support.FormattingConversionServiceFactoryBean; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.util.MultiValueMap; -import org.springframework.util.ReflectionUtils; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.MatrixVariable; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY; -import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; -import static feign.CollectionFormat.CSV; -import static feign.CollectionFormat.SSV; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.junit.jupiter.api.Assumptions.assumeTrue; - -/** - * @author chadjaros - * @author Halvdan Hoem Grelland - * @author Aram Peres - * @author Aaron Whiteside - * @author Artyom Romanenko - * @author Olga Maciaszek-Sharma - * @author Szymon Linowski - * @author Sam Kruglov - * @author Bhavya Agrawal - **/ - -class SpringMvcContractTests { - - private static final Class EXECUTABLE_TYPE; - - static { - Class executableType; - try { - executableType = Class.forName("java.lang.reflect.Executable"); - } - catch (ClassNotFoundException ex) { - executableType = null; - } - EXECUTABLE_TYPE = executableType; - } - - private SpringMvcContract contract; - - /** - * For abstract (e.g. interface) methods, only Java 8 Parameter names (compiler arg - * -parameters) can supply parameter names; bytecode-based strategies use local - * variable declarations, of which there are none for abstract methods. - * @param m method - * @return whether a parameter name was found - * @throws IllegalArgumentException if method has no parameters - */ - private static boolean hasJava8ParameterNames(Method m) { - org.springframework.util.Assert.isTrue(m.getParameterTypes().length > 0, "method has no parameters"); - if (EXECUTABLE_TYPE != null) { - Method getParameters = ReflectionUtils.findMethod(EXECUTABLE_TYPE, "getParameters"); - try { - Object[] parameters = (Object[]) getParameters.invoke(m); - Method isNamePresent = ReflectionUtils.findMethod(parameters[0].getClass(), "isNamePresent"); - return Boolean.TRUE.equals(isNamePresent.invoke(parameters[0])); - } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) { - } - } - return false; - } - - @BeforeEach - void setup() { - contract = new SpringMvcContract(Collections.emptyList(), getConversionService()); - } - - @Test - void testProcessAnnotationOnMethod_Simple() throws Exception { - Method method = TestTemplate_Simple.class.getDeclaredMethod("getTest", String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test/{id}"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - assertThat(data.template().decodeSlash()).isTrue(); - } - - @Test - void testProcessAnnotationOnMethod_Simple_RegexPathVariable() throws Exception { - Method method = TestTemplate_Simple.class.getDeclaredMethod("getTestWithDigitalId", String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test/{id:\\d+}"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.formParams()).isEmpty(); - } - - @Test - void testProcessAnnotationOnMethod_Simple_SlashEncoded() throws Exception { - contract = new SpringMvcContract(Collections.emptyList(), getConversionService(), false); - - Method method = TestTemplate_Simple.class.getDeclaredMethod("getTest", String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test/{id}"); - - assertThat(data.template().decodeSlash()).isFalse(); - } - - @Test - void testProcessAnnotations_Simple() throws Exception { - Method method = TestTemplate_Simple.class.getDeclaredMethod("getTest", String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test/{id}"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - - assertThat(data.indexToName().get(0).iterator().next()).isEqualTo("id"); - } - - @Test - void testProcessAnnotations_SimpleNoPath() throws Exception { - Method method = TestTemplate_Simple.class.getDeclaredMethod("getTest"); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - } - - @Test - void testProcessAnnotations_SimplePathIsOnlyASlash() throws Exception { - Method method = TestTemplate_Simple.class.getDeclaredMethod("getSlashPath", String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/?id=" + "{id}"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - } - - @Test - void testProcessAnnotations_MissingLeadingSlashInPath() throws Exception { - Method method = TestTemplate_Simple.class.getDeclaredMethod("getTestNoLeadingSlash", String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test?name=" + "{name}"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - } - - @Test - void testProcessAnnotations_SimpleGetMapping() throws Exception { - Method method = TestTemplate_Simple.class.getDeclaredMethod("getMappingTest", String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test/{id}"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - - assertThat(data.indexToName().get(0).iterator().next()).isEqualTo("id"); - } - - @Test - void testProcessAnnotations_Class_Annotations_RequestMapping() { - assertThatIllegalArgumentException().isThrownBy(() -> { - Method method = TestTemplate_Class_RequestMapping.class.getDeclaredMethod("getSpecificTest", String.class, - String.class); - contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - }); - } - - @Test - void testProcessAnnotations_Class_AnnotationsGetAllTests() throws Exception { - Method method = TestTemplate_Class_Annotations.class.getDeclaredMethod("getAllTests", String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/"); - assertThat(data.template().method()).isEqualTo("GET"); - - assertThat(data.indexToName().get(0).iterator().next()).isEqualTo("classId"); - assertThat(data.template().decodeSlash()).isTrue(); - } - - @Test - void testProcessAnnotations_ExtendedInterface() throws Exception { - Method extendedMethod = TestTemplate_Extended.class.getMethod("getAllTests", String.class); - MethodMetadata extendedData = contract.parseAndValidateMetadata(extendedMethod.getDeclaringClass(), - extendedMethod); - - Method method = TestTemplate_Class_Annotations.class.getDeclaredMethod("getAllTests", String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo(extendedData.template().url()); - assertThat(data.template().method()).isEqualTo(extendedData.template().method()); - assertThat(data.indexToName().get(0).iterator().next()).isEqualTo(data.indexToName().get(0).iterator().next()); - assertThat(data.indexToName().get(0).iterator().next()).isEqualTo(data.indexToName().get(0).iterator().next()); - assertThat(data.template().decodeSlash()).isTrue(); - } - - @Test - void testProcessAnnotations_SimplePost() throws Exception { - Method method = TestTemplate_Simple.class.getDeclaredMethod("postTest", TestObject.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/"); - assertThat(data.template().method()).isEqualTo("POST"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - - } - - @Test - void testProcessAnnotations_SimplePostMapping() throws Exception { - Method method = TestTemplate_Simple.class.getDeclaredMethod("postMappingTest", TestObject.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/"); - assertThat(data.template().method()).isEqualTo("POST"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - - } - - @Test - void testProcessAnnotationsOnMethod_Advanced() throws Exception { - Method method = TestTemplate_Advanced.class.getDeclaredMethod("getTest", String.class, String.class, - Integer.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test/{id}?amount=" + "{amount}"); - assertThat(data.template().method()).isEqualTo("PUT"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - } - - @Test - void testProcessAnnotationsOnMethod_Advanced_UnknownAnnotation() throws Exception { - Method method = TestTemplate_Advanced.class.getDeclaredMethod("getTest", String.class, String.class, - Integer.class); - contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - // Don't throw an exception and this passes - } - - @Test - void testProcessAnnotationsOnMethod_CollectionFormat() throws NoSuchMethodException { - Method method = TestTemplate_Advanced.class.getDeclaredMethod("getWithCollectionFormat"); - - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().collectionFormat()).isEqualTo(SSV); - } - - @Test - void processAnnotationOnClass_CollectionFormat() throws NoSuchMethodException { - Method method = TestTemplate_Advanced.class.getDeclaredMethod("getWithoutCollectionFormat"); - - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().collectionFormat()).isEqualTo(CSV); - } - - @Test - void testProcessAnnotations_Advanced() throws Exception { - Method method = TestTemplate_Advanced.class.getDeclaredMethod("getTest", String.class, String.class, - Integer.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test/{id}?amount=" + "{amount}"); - assertThat(data.template().method()).isEqualTo("PUT"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - - assertThat(data.indexToName().get(0).iterator().next()).isEqualTo("Authorization"); - assertThat(data.indexToName().get(1).iterator().next()).isEqualTo("id"); - assertThat(data.indexToName().get(2).iterator().next()).isEqualTo("amount"); - assertThat(data.indexToExpander().get(2)).isNotNull(); - - assertThat(data.template().headers().get("Authorization").iterator().next()).isEqualTo("{Authorization}"); - assertThat(data.template().queries().get("amount").iterator().next()).isEqualTo("{amount}"); - } - - @Test - void testProcessAnnotations_Aliased() throws Exception { - Method method = TestTemplate_Advanced.class.getDeclaredMethod("getTest2", String.class, Integer.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test2?amount=" + "{amount}"); - assertThat(data.template().method()).isEqualTo("PUT"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - - assertThat(data.indexToName().get(0).iterator().next()).isEqualTo("Authorization"); - assertThat(data.indexToName().get(1).iterator().next()).isEqualTo("amount"); - - assertThat(data.template().headers().get("Authorization").iterator().next()).isEqualTo("{Authorization}"); - assertThat(data.template().queries().get("amount").iterator().next()).isEqualTo("{amount}"); - } - - @Test - void testProcessAnnotations_DateTimeFormatParam() throws Exception { - Method method = TestTemplate_DateTimeFormatParameter.class.getDeclaredMethod("getTest", LocalDateTime.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - Param.Expander expander = data.indexToExpander().get(0); - assertThat(expander).isNotNull(); - - LocalDateTime input = LocalDateTime.of(2001, 10, 12, 23, 56, 3); - - DateTimeFormatter formatter = DateTimeFormatter.ofPattern(TestTemplate_DateTimeFormatParameter.CUSTOM_PATTERN); - - String expected = formatter.format(input); - - assertThat(expander.expand(input)).isEqualTo(expected); - } - - @Test - void testProcessAnnotations_NumberFormatParam() throws Exception { - Method method = TestTemplate_NumberFormatParameter.class.getDeclaredMethod("getTest", BigDecimal.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - Param.Expander expander = data.indexToExpander().get(0); - assertThat(expander).isNotNull(); - - NumberStyleFormatter formatter = new NumberStyleFormatter(TestTemplate_NumberFormatParameter.CUSTOM_PATTERN); - - BigDecimal input = BigDecimal.valueOf(1220.345); - - String expected = formatter.print(input, Locale.getDefault()); - String actual = expander.expand(input); - - assertThat(actual).isEqualTo(expected); - } - - @Test - void testProcessAnnotations_Advanced2() throws Exception { - Method method = TestTemplate_Advanced.class.getDeclaredMethod("getTest"); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - } - - @Test - void testProcessAnnotations_Advanced3() throws Exception { - Method method = TestTemplate_Simple.class.getDeclaredMethod("getTest"); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - assertThat(data.template().decodeSlash()).isTrue(); - } - - @Test - void testProcessAnnotations_Advanced3_DecodeSlashFlagNotModified() throws Exception { - contract = new SpringMvcContract(Collections.emptyList(), getConversionService(), false); - - Method method = TestTemplate_Simple.class.getDeclaredMethod("getTest"); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/"); - - assertThat(data.template().decodeSlash()).isTrue(); - } - - @Test - void testProcessAnnotations_ListParams() throws Exception { - Method method = TestTemplate_ListParams.class.getDeclaredMethod("getTest", List.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test?id=" + "{id}"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().queries().get("id").toString()).isEqualTo("[{id}]"); - assertThat(data.indexToExpander().get(0)).isNotNull(); - } - - @Test - void testProcessAnnotations_ListParamsWithoutName() throws Exception { - Method method = TestTemplate_ListParamsWithoutName.class.getDeclaredMethod("getTest", List.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test?id=" + "{id}"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().queries().get("id").toString()).isEqualTo("[{id}]"); - assertThat(data.indexToExpander().get(0)).isNotNull(); - } - - @Test - void testProcessAnnotations_MapParams() throws Exception { - Method method = TestTemplate_MapParams.class.getDeclaredMethod("getTest", Map.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.queryMapIndex()).isNotNull(); - assertThat(data.queryMapIndex().intValue()).isEqualTo(0); - } - - @Test - void testProcessHeaders() throws Exception { - Method method = TestTemplate_Headers.class.getDeclaredMethod("getTest", String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test/{id}"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().headers().get("x-Foo").iterator().next()).isEqualTo("bar"); - } - - @Test - void testProcessHeadersWithoutValues() throws Exception { - Method method = TestTemplate_HeadersWithoutValues.class.getDeclaredMethod("getTest", String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/test/{id}"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().headers().isEmpty()).isTrue(); - } - - @Test - void testProcessAnnotations_Fallback() throws Exception { - Method method = TestTemplate_Advanced.class.getDeclaredMethod("getTestFallback", String.class, String.class, - Integer.class); - - assumeTrue(hasJava8ParameterNames(method), "does not have java 8 parameter names"); - - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/testfallback/{id}?amount=" + "{amount}"); - assertThat(data.template().method()).isEqualTo("PUT"); - assertThat(data.template().headers().get("Accept").iterator().next()) - .isEqualTo(MediaType.APPLICATION_JSON_VALUE); - - assertThat(data.indexToName().get(0).iterator().next()).isEqualTo("Authorization"); - assertThat(data.indexToName().get(1).iterator().next()).isEqualTo("id"); - assertThat(data.indexToName().get(2).iterator().next()).isEqualTo("amount"); - - assertThat(data.template().headers().get("Authorization").iterator().next()).isEqualTo("{Authorization}"); - assertThat(data.template().queries().get("amount").iterator().next()).isEqualTo("{amount}"); - } - - @Test - void testProcessHeaderMap() throws Exception { - Method method = TestTemplate_HeaderMap.class.getDeclaredMethod("headerMap", MultiValueMap.class, String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/headerMap"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.headerMapIndex().intValue()).isEqualTo(0); - Map> headers = data.template().headers(); - assertThat(headers.get("aHeader").iterator().next()).isEqualTo("{aHeader}"); - } - - @Test - void testProcessHeaderMapMoreThanOnce() throws Exception { - Method method = TestTemplate_HeaderMap.class.getDeclaredMethod("headerMapMoreThanOnce", MultiValueMap.class, - MultiValueMap.class); - assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> contract.parseAndValidateMetadata(method.getDeclaringClass(), method)); - } - - @Test - void testProcessQueryMap() throws Exception { - Method method = TestTemplate_QueryMap.class.getDeclaredMethod("queryMap", MultiValueMap.class, String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/queryMap?aParam=" + "{aParam}"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.queryMapIndex().intValue()).isEqualTo(0); - Map> params = data.template().queries(); - assertThat(params.get("aParam").iterator().next()).isEqualTo("{aParam}"); - } - - @Test - void testProcessQueryMapObject() throws Exception { - Method method = TestTemplate_QueryMap.class.getDeclaredMethod("queryMapObject", TestObject.class, String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().url()).isEqualTo("/queryMapObject?aParam=" + "{aParam}"); - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.queryMapIndex().intValue()).isEqualTo(0); - Map> params = data.template().queries(); - assertThat(params.get("aParam").iterator().next()).isEqualTo("{aParam}"); - } - - @Test - void testProcessQueryMapMoreThanOnce() throws Exception { - Method method = TestTemplate_QueryMap.class.getDeclaredMethod("queryMapMoreThanOnce", MultiValueMap.class, - MultiValueMap.class); - assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> contract.parseAndValidateMetadata(method.getDeclaringClass(), method)); - } - - @Test - void testMatrixVariable_MapParam() throws Exception { - Method method = TestTemplate_MatrixVariable.class.getDeclaredMethod("matrixVariable", Map.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - Map testMap = new HashMap<>(); - testMap.put("param", "value"); - - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().url()).isEqualTo("/matrixVariable/{params}"); - assertThat(";param=value").isEqualTo(data.indexToExpander().get(0).expand(testMap)); - } - - @Test - void testMatrixVariable_ObjectParam() throws Exception { - Method method = TestTemplate_MatrixVariable.class.getDeclaredMethod("matrixVariableObject", Object.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().url()).isEqualTo("/matrixVariableObject/{param}"); - assertThat(";param=value").isEqualTo(data.indexToExpander().get(0).expand("value")); - } - - @Test - void testMatrixVariableWithNoName() throws NoSuchMethodException { - Method method = TestTemplate_MatrixVariable.class.getDeclaredMethod("matrixVariableNotNamed", Map.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - Map testMap = new HashMap<>(); - - testMap.put("param", "value"); - - assertThat(data.template().method()).isEqualTo("GET"); - assertThat(data.template().url()).isEqualTo("/matrixVariable/{params}"); - assertThat(";param=value").isEqualTo(data.indexToExpander().get(0).expand(testMap)); - } - - @Test - void testAddingTemplatedParameterWithTheSameKey() throws NoSuchMethodException { - Method method = TestTemplate_Advanced.class.getDeclaredMethod("testAddingTemplatedParamForExistingKey", - String.class); - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - - assertThat(data.template().headers().get("Accept")).contains("application/json", "{Accept}"); - } - - @Test - void testMultipleRequestPartAnnotations() throws NoSuchMethodException { - Method method = TestTemplate_RequestPart.class.getDeclaredMethod("requestWithMultipleParts", - MultipartFile.class, String.class); - - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - assertThat(data.formParams()).contains("file", "id"); - } - - @Test - void testSingleCookieAnnotation() throws NoSuchMethodException { - Method method = TestTemplate_Cookies.class.getDeclaredMethod("singleCookie", String.class, String.class); - - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - assertThat(data.template().headers().get("cookie").iterator().next()).isEqualTo("cookie1={cookie1}"); - } - - @Test - void testMultipleCookiesAnnotation() throws NoSuchMethodException { - Method method = TestTemplate_Cookies.class.getDeclaredMethod("multipleCookies", String.class, String.class, - String.class); - - MethodMetadata data = contract.parseAndValidateMetadata(method.getDeclaringClass(), method); - assertThat(data.template().headers().get("cookie").iterator().next()) - .isEqualTo("cookie1={cookie1}; cookie2={cookie2}"); - } - - @Test - void shouldNotFailWhenBothPageableAndRequestBodyParamsInPostRequest() { - List data = contract.parseAndValidateMetadata(TestTemplate_PageablePost.class); - - assertThat(data.get(0).queryMapIndex()).isEqualTo(0); - assertThat(data.get(0).bodyIndex()).isEqualTo(1); - assertThat(data.get(1).queryMapIndex()).isEqualTo(1); - assertThat(data.get(1).bodyIndex()).isEqualTo(0); - } - - @Test - void shouldSetPageableAsBodyWhenQueryMapParamPresent() { - List data = contract.parseAndValidateMetadata(TestTemplate_PageablePostWithQueryMap.class); - - assertThat(data.get(0).queryMapIndex()).isEqualTo(0); - assertThat(data.get(0).bodyIndex()).isEqualTo(1); - assertThat(data.get(1).queryMapIndex()).isEqualTo(1); - assertThat(data.get(1).bodyIndex()).isEqualTo(0); - } - - private ConversionService getConversionService() { - FormattingConversionServiceFactoryBean conversionServiceFactoryBean = new FormattingConversionServiceFactoryBean(); - conversionServiceFactoryBean.afterPropertiesSet(); - return conversionServiceFactoryBean.getObject(); - } - - public interface TestTemplate_Simple { - - @RequestMapping(value = "/test/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity getTest(@PathVariable("id") String id); - - @GetMapping("/test/{id:\\d+}") - ResponseEntity getTestWithDigitalId(@PathVariable("id") String id); - - @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) - TestObject getTest(); - - @GetMapping(value = "/test/{id}", produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity getMappingTest(@PathVariable("id") String id); - - @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) - TestObject postTest(@RequestBody TestObject object); - - @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) - TestObject postMappingTest(@RequestBody TestObject object); - - @GetMapping(value = "/", produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity getSlashPath(@RequestParam("id") String id); - - @GetMapping(path = "test", produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity getTestNoLeadingSlash(@RequestParam("name") String name); - - } - - @RequestMapping("/prepend/{classId}") - public interface TestTemplate_Class_RequestMapping { - - @RequestMapping(value = "/test/{testId}", method = RequestMethod.GET) - TestObject getSpecificTest(@PathVariable("classId") String classId, @PathVariable("testId") String testId); - - } - - public interface TestTemplate_Class_Annotations { - - @GetMapping("/test/{testId}") - TestObject getSpecificTest(@PathVariable("classId") String classId, @PathVariable("testId") String testId); - - @RequestMapping(method = RequestMethod.GET) - TestObject getAllTests(@PathVariable("classId") String classId); - - } - - public interface TestTemplate_Extended extends TestTemplate_Class_Annotations { - - } - - public interface TestTemplate_Headers { - - @GetMapping(value = "/test/{id}", headers = "X-Foo=bar") - ResponseEntity getTest(@PathVariable("id") String id); - - } - - public interface TestTemplate_Cookies { - - @GetMapping("/test/{id}") - ResponseEntity singleCookie(@PathVariable("id") String id, @CookieValue("cookie1") String cookie1); - - @GetMapping("/test/{id}") - ResponseEntity multipleCookies(@PathVariable("id") String id, - @CookieValue("cookie1") String cookie1, @CookieValue("cookie2") String cookie2); - - } - - public interface TestTemplate_HeadersWithoutValues { - - @GetMapping(value = "/test/{id}", headers = { "X-Foo", "!X-Bar", "X-Baz!=fooBar" }) - ResponseEntity getTest(@PathVariable("id") String id); - - } - - public interface TestTemplate_ListParams { - - @GetMapping("/test") - ResponseEntity getTest(@RequestParam("id") List id); - - } - - public interface TestTemplate_ListParamsWithoutName { - - @GetMapping("/test") - ResponseEntity getTest(@RequestParam List id); - - } - - public interface TestTemplate_MapParams { - - @GetMapping("/test") - ResponseEntity getTest(@RequestParam Map params); - - } - - public interface TestTemplate_HeaderMap { - - @GetMapping("/headerMap") - String headerMap(@RequestHeader MultiValueMap headerMap, - @RequestHeader(name = "aHeader") String aHeader); - - @GetMapping("/headerMapMoreThanOnce") - String headerMapMoreThanOnce(@RequestHeader MultiValueMap headerMap1, - @RequestHeader MultiValueMap headerMap2); - - } - - public interface TestTemplate_QueryMap { - - @GetMapping("/queryMap") - String queryMap(@RequestParam MultiValueMap queryMap, - @RequestParam(name = "aParam") String aParam); - - @GetMapping("/queryMapMoreThanOnce") - String queryMapMoreThanOnce(@RequestParam MultiValueMap queryMap1, - @RequestParam MultiValueMap queryMap2); - - @GetMapping("/queryMapObject") - String queryMapObject(@SpringQueryMap TestObject queryMap, @RequestParam(name = "aParam") String aParam); - - } - - public interface TestTemplate_RequestPart { - - @PostMapping(path = "/requestPart", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - void requestWithMultipleParts(@RequestPart("file") MultipartFile file, @RequestPart("id") String identifier); - - } - - public interface TestTemplate_MatrixVariable { - - @GetMapping("/matrixVariable/{params}") - String matrixVariable(@MatrixVariable("params") Map params); - - @GetMapping("/matrixVariableObject/{param}") - String matrixVariableObject(@MatrixVariable("param") Object object); - - @GetMapping("/matrixVariable/{params}") - String matrixVariableNotNamed(@MatrixVariable Map params); - - } - - @JsonAutoDetect - @CollectionFormat(CSV) - public interface TestTemplate_Advanced { - - @CollectionFormat(SSV) - @GetMapping - ResponseEntity getWithCollectionFormat(); - - @GetMapping - ResponseEntity getWithoutCollectionFormat(); - - @ExceptionHandler - @PutMapping(path = "/test/{id}", produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity getTest(@RequestHeader("Authorization") String auth, @PathVariable("id") String id, - @RequestParam("amount") Integer amount); - - @PutMapping(path = "/test2", produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity getTest2(@RequestHeader(name = "Authorization") String auth, - @RequestParam(name = "amount") Integer amount); - - @ExceptionHandler - @PutMapping(path = "/testfallback/{id}", produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity getTestFallback(@RequestHeader String Authorization, @PathVariable String id, - @RequestParam Integer amount); - - @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) - TestObject getTest(); - - @GetMapping(produces = "application/json") - String testAddingTemplatedParamForExistingKey(@RequestHeader("Accept") String accept); - - } - - public interface TestTemplate_DateTimeFormatParameter { - - String CUSTOM_PATTERN = "dd-MM-yyyy HH:mm"; - - @GetMapping - String getTest(@RequestParam(name = "localDateTime") @DateTimeFormat( - pattern = CUSTOM_PATTERN) LocalDateTime localDateTime); - - } - - public interface TestTemplate_NumberFormatParameter { - - String CUSTOM_PATTERN = "$###,###.###"; - - @GetMapping - String getTest(@RequestParam("amount") @NumberFormat(pattern = CUSTOM_PATTERN) BigDecimal amount); - - } - - interface TestTemplate_PageablePost { - - @PostMapping - Page getPage(Pageable pageable, @RequestBody String body); - - @PostMapping - Page getPage(@RequestBody String body, Pageable pageable); - - } - - interface TestTemplate_PageablePostWithQueryMap { - - @PostMapping - Page getPage(@SpringQueryMap TestObject pojo, Pageable pageable); - - @PostMapping - Page getPage(Pageable pageable, @SpringQueryMap TestObject pojo); - - } - - @JsonAutoDetect(fieldVisibility = ANY, getterVisibility = NONE, setterVisibility = NONE) - public static class TestObject { - - public String something; - - public Double number; - - TestObject() { - } - - TestObject(String something, Double number) { - this.something = something; - this.number = number; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - TestObject that = (TestObject) o; - - if (!Objects.equals(number, that.number)) { - return false; - } - if (!Objects.equals(something, that.something)) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result = (something != null ? something.hashCode() : 0); - result = 31 * result + (number != null ? number.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return new StringBuilder("TestObject{").append("something='").append(something).append("', ") - .append("number=").append(number).append("}").toString(); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/ApacheHttpClient5ConfigurationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/ApacheHttpClient5ConfigurationTests.java deleted file mode 100644 index d2a8176ab..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/ApacheHttpClient5ConfigurationTests.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2013-2022 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; - -// TODO: Bring back when there's corresponding HttpClient 5 support in Commons - -// -// import java.io.IOException; -// import java.lang.reflect.Field; -// import java.util.concurrent.TimeUnit; -// -// import feign.Client; -// import feign.hc5.ApacheHttp5Client; -// -// import org.apache.hc.client5.http.classic.HttpClient; -// import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; -// import org.apache.hc.client5.http.io.HttpClientConnectionManager; -// import org.apache.http.config.RegistryBuilder; -// import org.junit.jupiter.api.Test; -// 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; -// import org.springframework.boot.test.context.SpringBootTest; -// import -// org.springframework.cloud.commons.httpclient.ApacheHttpClientConnectionManagerFactory; -// import org.springframework.cloud.commons.httpclient.ApacheHttpClientFactory; -// import -// org.springframework.cloud.commons.httpclient.DefaultApacheHttpClientConnectionManagerFactory; -// import org.springframework.cloud.commons.httpclient.DefaultApacheHttpClientFactory; -// import org.springframework.cloud.openfeign.EnableFeignClients; -// import org.springframework.cloud.openfeign.FeignClient; -// import -// org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient; -// import org.springframework.context.annotation.Bean; -// import org.springframework.context.annotation.Configuration; -// import org.springframework.test.annotation.DirtiesContext; -// import org.springframework.util.ReflectionUtils; -// -// import static org.assertj.core.api.Assertions.assertThat; -// import static org.mockito.ArgumentMatchers.any; -// import static org.mockito.Mockito.doReturn; -// import static org.mockito.Mockito.mock; -// import static org.mockito.Mockito.mockingDetails; -// -/// ** -// * @author Ryan Baxter -// * @author Olga Maciaszek-Sharma -// */ -// @SpringBootTest(properties = { "spring.cloud.openfeign.okhttp.enabled: false", -// "spring.cloud.loadbalancer.retry.enabled=false" }) -// @DirtiesContext -// class ApacheHttpClient5ConfigurationTests { -// -// @Autowired -// ApacheHttpClientConnectionManagerFactory connectionManagerFactory; -// -// @Autowired -// ApacheHttpClientFactory httpClientFactory; -// -// @Autowired -// FeignBlockingLoadBalancerClient feignClient; -// -// @Test -// void testFactories() { -// assertThat(connectionManagerFactory).isInstanceOf(ApacheHttpClientConnectionManagerFactory.class); -// assertThat(connectionManagerFactory) -// .isInstanceOf(ApacheHttpClientConfigurationTestApp.MyApacheHttpClientConnectionManagerFactory.class); -// assertThat(httpClientFactory).isInstanceOf(ApacheHttpClientFactory.class); -// assertThat(httpClientFactory) -// .isInstanceOf(ApacheHttpClientConfigurationTestApp.MyApacheHttpClientFactory.class); -// } -// -// @Test -// void testHttpClientWithFeign() { -// Client delegate = feignClient.getDelegate(); -// assertThat(delegate instanceof ApacheHttp5Client).isTrue(); -// ApacheHttp5Client apacheHttpClient = (ApacheHttp5Client) delegate; -// HttpClient httpClient = getField(apacheHttpClient, "client"); -// MockingDetails httpClientDetails = mockingDetails(httpClient); -// assertThat(httpClientDetails.isMock()).isTrue(); -// } -// -// @SuppressWarnings("unchecked") -// protected T getField(Object target, String name) { -// Field field = ReflectionUtils.findField(target.getClass(), name); -// ReflectionUtils.makeAccessible(field); -// Object value = ReflectionUtils.getField(field, target); -// return (T) value; -// } -// -// @SpringBootConfiguration -// @EnableAutoConfiguration -// @EnableFeignClients(clients = { ApacheHttpClientConfigurationTestApp.FooClient.class }) -// static class ApacheHttpClientConfigurationTestApp { -// -// @FeignClient(name = "foo") -// interface FooClient { -// -// } -// -// static class MyApacheHttpClientConnectionManagerFactory -// extends DefaultApacheHttpClientConnectionManagerFactory { -// -// @Override -// public HttpClientConnectionManager newConnectionManager(boolean disableSslValidation, -// int maxTotalConnections, int maxConnectionsPerRoute, long timeToLive, TimeUnit -// timeUnit, -// RegistryBuilder registry) { -// return mock(PoolingHttpClientConnectionManager.class); -// } -// -// } -// -// static class MyApacheHttpClientFactory extends DefaultApacheHttpClientFactory { -// -// MyApacheHttpClientFactory(HttpClientBuilder builder) { -// super(builder); -// } -// -// @Override -// public HttpClientBuilder createBuilder() { -// CloseableHttpClient client = mock(CloseableHttpClient.class); -// CloseableHttpResponse response = mock(CloseableHttpResponse.class); -// StatusLine statusLine = mock(StatusLine.class); -// doReturn(200).when(statusLine).getStatusCode(); -// Mockito.doReturn(statusLine).when(response).getStatusLine(); -// Header[] headers = new BasicHeader[0]; -// doReturn(headers).when(response).getAllHeaders(); -// try { -// Mockito.doReturn(response).when(client).execute(any(HttpUriRequest.class)); -// } -// catch (IOException e) { -// e.printStackTrace(); -// } -// HttpClientBuilder builder = mock(HttpClientBuilder.class); -// Mockito.doReturn(client).when(builder).build(); -// return builder; -// } -// -// } -// -// @Configuration(proxyBeanMethods = false) -// static class MyConfig { -// -// @Bean -// public ApacheHttpClientFactory apacheHttpClientFactory(HttpClientBuilder builder) { -// return new MyApacheHttpClientFactory(builder); -// } -// -// @Bean -// public ApacheHttpClientConnectionManagerFactory connectionManagerFactory() { -// return new MyApacheHttpClientConnectionManagerFactory(); -// } -// -// } -// -// } -// -// } diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/EqualsAndHashCodeAssert.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/EqualsAndHashCodeAssert.java deleted file mode 100644 index aedf1c739..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/EqualsAndHashCodeAssert.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2021-2022 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; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * A few assertions to sanity-check equals and hashCode contracts: - * https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html See - * {@link Object#equals(Object)} and {@link Object#hashCode()}. - * - * @author Jonatan Ivanov - * @author Olga Maciaszek-Sharma - */ -public final class EqualsAndHashCodeAssert { - - private EqualsAndHashCodeAssert() { - throw new IllegalStateException("Can't instantiate a utility class"); - } - - /** - * Checks if equals is reflexive: for any non-null reference value x, x.equals(x) - * should return true. - * @param object the reference object to check - */ - public static void assertEqualsReflexivity(Object object) { - assertThat(object.equals(object)).isTrue(); - } - - /** - * Checks if equals is symmetric: for any non-null reference values x and y, - * x.equals(y) should return true if and only if y.equals(x) returns true The user of - * this method should call this at least twice: once with objects that are equal and - * once with objects that are not. - * @param objectOne a reference object to check - * @param objectTwo another reference object to check - */ - public static void assertEqualsSymmetricity(Object objectOne, Object objectTwo) { - assertThat(objectOne.equals(objectTwo)).isEqualTo(objectTwo.equals(objectOne)); - } - - /** - * Checks if equals is transitive: for any non-null reference values x, y, and z, if - * x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should - * return true. - * @param objectOne a reference object to check - * @param objectTwo another reference object to check - * @param objectThree and the third reference object to check - */ - public static void assertEqualsTransitivity(Object objectOne, Object objectTwo, Object objectThree) { - assertThat(objectOne.equals(objectTwo)).isTrue(); - assertThat(objectTwo.equals(objectThree)).isTrue(); - assertThat(objectOne.equals(objectThree)).isTrue(); - } - - /** - * Tries to check if equals is consistent: for any non-null reference values x and y, - * multiple invocations of x.equals(y) consistently return true or consistently return - * false. The user of this method should call this at least twice: once with objects - * that are equal and once with objects that are not. - * @param objectOne a reference object to check - * @param objectTwo another reference object to check - */ - public static void assertEqualsConsistency(Object objectOne, Object objectTwo) { - boolean equality = objectOne.equals(objectTwo); - for (int i = 0; i < 100; i++) { - assertThat(objectOne.equals(objectTwo)).isEqualTo(equality); - } - } - - /** - * Tries to check if hashCode is consistent: whenever it is invoked on the same object - * more than once during an execution of a Java application, the hashCode method must - * consistently return the same integer. - * @param object the reference object to check - */ - public static void assertHashCodeConsistency(Object object) { - int hashCode = object.hashCode(); - for (int i = 0; i < 100; i++) { - assertThat(object.hashCode()).isEqualTo(hashCode); - } - } - - /** - * Checks if equals and hashCode are consistent to each other: if two objects are - * equal according to the equals method, then calling the hashCode method on each of - * the two objects must produce the same integer result. - * @param objectOne a reference object to check - * @param objectTwo another reference object to check - */ - public static void assertEqualsAndHashCodeConsistency(Object objectOne, Object objectTwo) { - assertThat(objectOne.equals(objectTwo)).isTrue(); - assertThat(objectOne).hasSameHashCodeAs(objectTwo); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/Http2ClientConfigurationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/Http2ClientConfigurationTests.java deleted file mode 100644 index d51a0349d..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/Http2ClientConfigurationTests.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2013-2023 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; - -import java.net.http.HttpClient; - -import feign.Client; -import feign.http2client.Http2Client; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient; -import org.springframework.context.annotation.Bean; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.util.ReflectionTestUtils; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author changjin wei(魏昌进) - */ -@SpringBootTest(properties = { "spring.cloud.openfeign.http2client.enabled= true", - "spring.cloud.openfeign.httpclient.hc5.enabled= false", "spring.cloud.loadbalancer.retry.enabled= false" }) -@DirtiesContext -class Http2ClientConfigurationTests { - - @Autowired - FeignBlockingLoadBalancerClient feignClient; - - private static final HttpClient defaultHttpClient = HttpClient.newHttpClient(); - - @Test - void shouldInstantiateFeignHttp2Client() { - Client delegate = feignClient.getDelegate(); - assertThat(delegate instanceof Http2Client).isTrue(); - Http2Client http2Client = (Http2Client) delegate; - HttpClient httpClient = getField(http2Client, "client"); - assertThat(httpClient).isEqualTo(defaultHttpClient); - } - - @SuppressWarnings("unchecked") - protected T getField(Object target, String name) { - Object value = ReflectionTestUtils.getField(target, target.getClass(), name); - return (T) value; - } - - @FeignClient(name = "foo") - interface FooClient { - - } - - @SpringBootConfiguration - @EnableAutoConfiguration - static class TestConfig { - - @Bean - public HttpClient client() { - return defaultHttpClient; - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/NoSecurityConfiguration.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/NoSecurityConfiguration.java deleted file mode 100644 index 4f73cc4d8..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/NoSecurityConfiguration.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration(proxyBeanMethods = false) -public class NoSecurityConfiguration { - - @Bean - SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - http.authorizeRequests().anyRequest().permitAll().and().csrf().disable(); - return http.build(); - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/OkHttpClientConfigurationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/OkHttpClientConfigurationTests.java deleted file mode 100644 index ae21b6f47..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/test/OkHttpClientConfigurationTests.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2013-2022 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; - -import feign.Client; -import okhttp3.OkHttpClient; -import org.junit.jupiter.api.Test; -import org.mockito.MockingDetails; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient; -import org.springframework.context.annotation.Bean; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.util.ReflectionTestUtils; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.mockingDetails; - -/** - * @author Ryan Baxter - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(properties = { "spring.cloud.openfeign.okhttp.enabled: true", - "spring.cloud.httpclientfactories.ok.enabled: true", "spring.cloud.openfeign.okhttp.enabled: true", - "spring.cloud.openfeign.httpclient.hc5.enabled: false", "spring.cloud.loadbalancer.retry.enabled=false" }) -@DirtiesContext -class OkHttpClientConfigurationTests { - - @Autowired - FeignBlockingLoadBalancerClient feignClient; - - @Test - void testHttpClientWithFeign() { - Client delegate = feignClient.getDelegate(); - assertThat(delegate instanceof feign.okhttp.OkHttpClient).isTrue(); - feign.okhttp.OkHttpClient okHttpClient = (feign.okhttp.OkHttpClient) delegate; - OkHttpClient httpClient = getField(okHttpClient, "delegate"); - MockingDetails httpClientDetails = mockingDetails(httpClient); - assertThat(httpClientDetails.isMock()).isTrue(); - } - - @SuppressWarnings("unchecked") - protected T getField(Object target, String name) { - Object value = ReflectionTestUtils.getField(target, target.getClass(), name); - return (T) value; - } - - @FeignClient(name = "foo") - interface FooClient { - - } - - @SpringBootConfiguration - @EnableAutoConfiguration - static class TestConfig { - - @Bean - public OkHttpClient client() { - return mock(OkHttpClient.class); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/testclients/TestClient.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/testclients/TestClient.java deleted file mode 100644 index e1e99857b..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/testclients/TestClient.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2013-2022 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.testclients; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; - -/** - * @author Ryan Baxter - */ -@FeignClient(name = "localapp") -public interface TestClient { - - @GetMapping("/hello") - String getHello(); - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientNotPrimaryTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientNotPrimaryTests.java deleted file mode 100644 index 7c4c1644f..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientNotPrimaryTests.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2013-2022 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.valid; - -import java.util.List; - -import feign.Logger; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient; -import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; -import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * @author Spencer Gibb - * @author Jakub Narloch - */ -@SpringBootTest(classes = FeignClientNotPrimaryTests.Application.class, webEnvironment = RANDOM_PORT, - value = { "spring.application.name=feignclientnotprimarytest", - "spring.cloud.openfeign.httpclient.hc5.enabled=false", "spring.cloud.openfeign.okhttp.enabled=false" }) -@DirtiesContext -class FeignClientNotPrimaryTests { - - public static final String HELLO_WORLD_1 = "hello world 1"; - - @Autowired - private TestClient testClient; - - @Autowired - private List testClients; - - @Test - void testClientType() { - assertThat(this.testClient).as("testClient was of wrong type").isInstanceOf(PrimaryTestClient.class); - } - - @Test - void testClientCount() { - assertThat(this.testClients).as("testClients was wrong").hasSize(2); - } - - @Test - void testSimpleType() { - Hello hello = this.testClient.getHello(); - assertThat(hello).as("hello was null").isNull(); - } - - @FeignClient(name = "localapp", primary = false) - protected interface TestClient { - - @GetMapping("/hello") - Hello getHello(); - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients(clients = { TestClient.class }, defaultConfiguration = TestDefaultFeignConfig.class) - @LoadBalancerClient(name = "localapp", configuration = LocalClientConfiguration.class) - protected static class Application { - - @Bean - @Primary - public PrimaryTestClient primaryTestClient() { - return new PrimaryTestClient(); - } - - @GetMapping("/hello") - public Hello getHello() { - return new Hello(HELLO_WORLD_1); - } - - } - - protected static class PrimaryTestClient implements TestClient { - - @Override - public Hello getHello() { - return null; - } - - } - - public static class Hello { - - private String message; - - Hello() { - } - - Hello(String message) { - this.message = message; - } - - public String getMessage() { - return this.message; - } - - public void setMessage(String message) { - this.message = message; - } - - } - - @Configuration(proxyBeanMethods = false) - public static class TestDefaultFeignConfig { - - @Bean - Logger.Level feignLoggerLevel() { - return Logger.Level.FULL; - } - - } - - // Load balancer with fixed server list for "local" pointing to localhost - @Configuration(proxyBeanMethods = false) - public static class LocalClientConfiguration { - - @LocalServerPort - private int port = 0; - - @Bean - public ServiceInstanceListSupplier staticServiceInstanceListSupplier() { - return ServiceInstanceListSuppliers.from("local", - new DefaultServiceInstance("local-1", "local", "localhost", port, false)); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientValidationTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientValidationTests.java deleted file mode 100644 index 0dae57c6b..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignClientValidationTests.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2013-2022 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.valid; - -import org.junit.jupiter.api.Test; - -import org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignAutoConfiguration; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.loadbalancer.FeignLoadBalancerAutoConfiguration; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Dave Syer - */ -class FeignClientValidationTests { - - @Test - void validNotLoadBalanced() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(GoodUrlConfiguration.class); - assertThat(context.getBean(GoodUrlConfiguration.Client.class)).isNotNull(); - context.close(); - } - - @Test - void validPlaceholder() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( - PlaceholderUrlConfiguration.class); - assertThat(context.getBean(PlaceholderUrlConfiguration.Client.class)).isNotNull(); - context.close(); - } - - @Test - void validLoadBalanced() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( - LoadBalancerAutoConfiguration.class, - org.springframework.cloud.loadbalancer.config.LoadBalancerAutoConfiguration.class, - FeignLoadBalancerAutoConfiguration.class, GoodServiceIdConfiguration.class); - assertThat(context.getBean(GoodServiceIdConfiguration.Client.class)).isNotNull(); - context.close(); - } - - @Configuration(proxyBeanMethods = false) - @Import({ FeignAutoConfiguration.class }) - @EnableFeignClients(clients = GoodUrlConfiguration.Client.class) - protected static class GoodUrlConfiguration { - - @FeignClient(name = "example", url = "https://example.com") - interface Client { - - @GetMapping("/") - @Deprecated - String get(); - - } - - } - - @Configuration(proxyBeanMethods = false) - @Import({ FeignAutoConfiguration.class }) - @EnableFeignClients(clients = PlaceholderUrlConfiguration.Client.class) - protected static class PlaceholderUrlConfiguration { - - @FeignClient(name = "example", url = "${feignClient.url:https://example.com}") - interface Client { - - @GetMapping("/") - @Deprecated - String get(); - - } - - } - - @Configuration(proxyBeanMethods = false) - @Import({ FeignAutoConfiguration.class }) - @EnableFeignClients(clients = GoodServiceIdConfiguration.Client.class) - protected static class GoodServiceIdConfiguration { - - @FeignClient("foo") - interface Client { - - @GetMapping("/") - @Deprecated - String get(); - - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignHttp2ClientTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignHttp2ClientTests.java deleted file mode 100644 index 81c9db69f..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignHttp2ClientTests.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright 2013-2023 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.valid; - -import java.util.Objects; - -import feign.Client; -import feign.http2client.Http2Client; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients; -import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; -import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.http.ResponseEntity; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author changjin wei(魏昌进) - */ -@SpringBootTest(classes = FeignHttp2ClientTests.Application.class, webEnvironment = WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=feignclienttest", "spring.cloud.openfeign.circuitbreaker.enabled=false", - "spring.cloud.openfeign.httpclient.hc5.enabled=false", - "spring.cloud.openfeign.http2client.enabled=true", "spring.cloud.loadbalancer.retry.enabled=false" }) -@DirtiesContext -class FeignHttp2ClientTests { - - @Autowired - private TestClient testClient; - - @Autowired - private Client feignClient; - - @Autowired - private UserClient userClient; - - @Test - void testSimpleType() { - Hello hello = testClient.getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - } - - @Test - void testPatch() { - ResponseEntity response = testClient.patchHello(new Hello("foo")); - assertThat(response).isNotNull(); - String header = response.getHeaders().getFirst("x-hello"); - assertThat(header).isEqualTo("hello world patch"); - } - - @Test - void testFeignClientType() { - assertThat(feignClient).isInstanceOf(FeignBlockingLoadBalancerClient.class); - FeignBlockingLoadBalancerClient client = (FeignBlockingLoadBalancerClient) feignClient; - Client delegate = client.getDelegate(); - assertThat(delegate).isInstanceOf(Http2Client.class); - } - - @Test - void testFeignInheritanceSupport() { - assertThat(userClient).as("UserClient was null").isNotNull(); - final User user = userClient.getUser(1); - assertThat(user).as("Returned user was null").isNotNull(); - assertThat(new User("John Smith")).as("Users were different").isEqualTo(user); - } - - @FeignClient("localapp") - protected interface TestClient extends BaseTestClient { - - } - - protected interface BaseTestClient { - - @GetMapping("/hello") - Hello getHello(); - - @PatchMapping(value = "/hellop", consumes = "application/json") - ResponseEntity patchHello(Hello hello); - - } - - protected interface UserService { - - @GetMapping("/users/{id}") - User getUser(@PathVariable("id") long id); - - } - - @FeignClient("localapp1") - protected interface UserClient extends UserService { - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients(clients = { TestClient.class, UserClient.class }) - @LoadBalancerClients({ - @LoadBalancerClient(name = "localapp", configuration = FeignHttpClientTests.LocalClientConfiguration.class), - @LoadBalancerClient(name = "localapp1", - configuration = FeignHttpClientTests.LocalClientConfiguration.class) }) - @Import(NoSecurityConfiguration.class) - protected static class Application implements UserService { - - @GetMapping("/hello") - public Hello getHello() { - return new Hello("hello world 1"); - } - - @PatchMapping("/hellop") - public ResponseEntity patchHello(@RequestBody Hello hello, - @RequestHeader("Content-Length") int contentLength) { - if (contentLength <= 0) { - throw new IllegalArgumentException("Invalid Content-Length " + contentLength); - } - if (!hello.getMessage().equals("foo")) { - throw new IllegalArgumentException("Invalid Hello: " + hello.getMessage()); - } - return ResponseEntity.ok().header("X-Hello", "hello world patch").build(); - } - - @Override - public User getUser(@PathVariable("id") long id) { - return new User("John Smith"); - } - - } - - public static class Hello { - - private String message; - - Hello() { - } - - Hello(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Hello that = (Hello) o; - return Objects.equals(message, that.message); - } - - @Override - public int hashCode() { - return Objects.hash(message); - } - - } - - public static class User { - - private String name; - - User() { - } - - User(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - User that = (User) o; - return Objects.equals(name, that.name); - } - - @Override - public int hashCode() { - return Objects.hash(name); - } - - } - - // Load balancer with fixed server list for "local" pointing to localhost - @Configuration(proxyBeanMethods = false) - static class LocalClientConfiguration { - - @LocalServerPort - private int port = 0; - - @Bean - public ServiceInstanceListSupplier staticServiceInstanceListSupplier() { - return ServiceInstanceListSuppliers.from("local", - new DefaultServiceInstance("local-1", "local", "localhost", port, false)); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignHttpClientTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignHttpClientTests.java deleted file mode 100644 index 5fbe903f3..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignHttpClientTests.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright 2013-2022 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.valid; - -import java.util.Objects; - -import feign.Client; -import feign.hc5.ApacheHttp5Client; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients; -import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; -import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Spencer Gibb - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(classes = FeignHttpClientTests.Application.class, webEnvironment = WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=feignclienttest", "spring.cloud.openfeign.circuitbreaker.enabled=false", - "spring.cloud.openfeign.okhttp.enabled=false", "spring.cloud.loadbalancer.retry.enabled=false" }) -@DirtiesContext -class FeignHttpClientTests { - - @Autowired - private TestClient testClient; - - @Autowired - private Client feignClient; - - @Autowired - private UserClient userClient; - - @Test - void testSimpleType() { - Hello hello = testClient.getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - } - - @Test - void testPatch() { - ResponseEntity response = testClient.patchHello(new Hello("foo")); - assertThat(response).isNotNull(); - String header = response.getHeaders().getFirst("x-hello"); - assertThat(header).isEqualTo("hello world patch"); - } - - @Test - void testFeignClientType() { - assertThat(feignClient).isInstanceOf(FeignBlockingLoadBalancerClient.class); - FeignBlockingLoadBalancerClient client = (FeignBlockingLoadBalancerClient) feignClient; - Client delegate = client.getDelegate(); - assertThat(delegate).isInstanceOf(ApacheHttp5Client.class); - } - - @Test - void testFeignInheritanceSupport() { - assertThat(userClient).as("UserClient was null").isNotNull(); - final User user = userClient.getUser(1); - assertThat(user).as("Returned user was null").isNotNull(); - assertThat(new User("John Smith")).as("Users were different").isEqualTo(user); - } - - @FeignClient("localapp") - protected interface TestClient extends BaseTestClient { - - } - - protected interface BaseTestClient { - - @GetMapping(value = "/hello", produces = MediaType.APPLICATION_JSON_VALUE) - Hello getHello(); - - @PatchMapping(value = "/hellop", consumes = "application/json") - ResponseEntity patchHello(Hello hello); - - } - - protected interface UserService { - - @GetMapping(value = "/users/{id}", produces = MediaType.APPLICATION_JSON_VALUE) - User getUser(@PathVariable("id") long id); - - } - - @FeignClient("localapp1") - protected interface UserClient extends UserService { - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients(clients = { TestClient.class, UserClient.class }) - @LoadBalancerClients({ @LoadBalancerClient(name = "localapp", configuration = LocalClientConfiguration.class), - @LoadBalancerClient(name = "localapp1", configuration = LocalClientConfiguration.class) }) - @Import(NoSecurityConfiguration.class) - protected static class Application implements UserService { - - @GetMapping("/hello") - public Hello getHello() { - return new Hello("hello world 1"); - } - - @PatchMapping("/hellop") - public ResponseEntity patchHello(@RequestBody Hello hello, - @RequestHeader("Content-Length") int contentLength) { - if (contentLength <= 0) { - throw new IllegalArgumentException("Invalid Content-Length " + contentLength); - } - if (!hello.getMessage().equals("foo")) { - throw new IllegalArgumentException("Invalid Hello: " + hello.getMessage()); - } - return ResponseEntity.ok().header("X-Hello", "hello world patch").build(); - } - - @Override - public User getUser(@PathVariable("id") long id) { - return new User("John Smith"); - } - - } - - public static class Hello { - - private String message; - - Hello() { - } - - Hello(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Hello that = (Hello) o; - return Objects.equals(message, that.message); - } - - @Override - public int hashCode() { - return Objects.hash(message); - } - - } - - public static class User { - - private String name; - - User() { - } - - User(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - User that = (User) o; - return Objects.equals(name, that.name); - } - - @Override - public int hashCode() { - return Objects.hash(name); - } - - } - - // Load balancer with fixed server list for "local" pointing to localhost - @Configuration(proxyBeanMethods = false) - static class LocalClientConfiguration { - - @LocalServerPort - private int port = 0; - - @Bean - public ServiceInstanceListSupplier staticServiceInstanceListSupplier() { - return ServiceInstanceListSuppliers.from("local", - new DefaultServiceInstance("local-1", "local", "localhost", port, false)); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignOkHttpTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignOkHttpTests.java deleted file mode 100644 index 7785002f0..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/FeignOkHttpTests.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright 2013-2022 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.valid; - -import java.util.Objects; - -import feign.Client; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients; -import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; -import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.http.ResponseEntity; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Spencer Gibb - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(classes = FeignOkHttpTests.Application.class, webEnvironment = WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=feignclienttest", "spring.cloud.openfeign.circuitbreaker.enabled=false", - "spring.cloud.openfeign.httpclient.hc5.enabled=false", "spring.cloud.openfeign.okhttp.enabled=true", - "spring.cloud.httpclientfactories.ok.enabled=true", "spring.cloud.loadbalancer.retry.enabled=false" }) -@DirtiesContext -class FeignOkHttpTests { - - @Autowired - private TestClient testClient; - - @Autowired - private Client feignClient; - - @Autowired - private UserClient userClient; - - @Test - void testSimpleType() { - Hello hello = testClient.getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello("hello world 1")); - } - - @Test - void testPatch() { - ResponseEntity response = testClient.patchHello(new Hello("foo")); - assertThat(response).isNotNull(); - String header = response.getHeaders().getFirst("x-hello"); - assertThat(header).isEqualTo("hello world patch"); - } - - @Test - void testFeignClientType() { - assertThat(feignClient).isInstanceOf(FeignBlockingLoadBalancerClient.class); - FeignBlockingLoadBalancerClient client = (FeignBlockingLoadBalancerClient) feignClient; - Client delegate = client.getDelegate(); - assertThat(delegate).isInstanceOf(feign.okhttp.OkHttpClient.class); - } - - @Test - void testFeignInheritanceSupport() { - assertThat(userClient).as("UserClient was null").isNotNull(); - final User user = userClient.getUser(1); - assertThat(user).as("Returned user was null").isNotNull(); - assertThat(new User("John Smith")).as("Users were different").isEqualTo(user); - } - - @FeignClient("localapp") - protected interface TestClient extends BaseTestClient { - - } - - protected interface BaseTestClient { - - @GetMapping("/hello") - Hello getHello(); - - @PatchMapping(value = "/hellop", consumes = "application/json") - ResponseEntity patchHello(Hello hello); - - } - - protected interface UserService { - - @GetMapping("/users/{id}") - User getUser(@PathVariable("id") long id); - - } - - @FeignClient("localapp1") - protected interface UserClient extends UserService { - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients(clients = { TestClient.class, UserClient.class }) - @LoadBalancerClients({ - @LoadBalancerClient(name = "localapp", configuration = FeignHttpClientTests.LocalClientConfiguration.class), - @LoadBalancerClient(name = "localapp1", - configuration = FeignHttpClientTests.LocalClientConfiguration.class) }) - @Import(NoSecurityConfiguration.class) - protected static class Application implements UserService { - - @GetMapping("/hello") - public Hello getHello() { - return new Hello("hello world 1"); - } - - @PatchMapping("/hellop") - public ResponseEntity patchHello(@RequestBody Hello hello, - @RequestHeader("Content-Length") int contentLength) { - if (contentLength <= 0) { - throw new IllegalArgumentException("Invalid Content-Length " + contentLength); - } - if (!hello.getMessage().equals("foo")) { - throw new IllegalArgumentException("Invalid Hello: " + hello.getMessage()); - } - return ResponseEntity.ok().header("X-Hello", "hello world patch").build(); - } - - @Override - public User getUser(@PathVariable("id") long id) { - return new User("John Smith"); - } - - } - - public static class Hello { - - private String message; - - Hello() { - } - - Hello(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Hello that = (Hello) o; - return Objects.equals(message, that.message); - } - - @Override - public int hashCode() { - return Objects.hash(message); - } - - } - - public static class User { - - private String name; - - User() { - } - - User(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - User that = (User) o; - return Objects.equals(name, that.name); - } - - @Override - public int hashCode() { - return Objects.hash(name); - } - - } - - // Load balancer with fixed server list for "local" pointing to localhost - @Configuration(proxyBeanMethods = false) - static class LocalClientConfiguration { - - @LocalServerPort - private int port = 0; - - @Bean - public ServiceInstanceListSupplier staticServiceInstanceListSupplier() { - return ServiceInstanceListSuppliers.from("local", - new DefaultServiceInstance("local-1", "local", "localhost", port, false)); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/IterableParameterTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/IterableParameterTests.java deleted file mode 100644 index fbb2b73ae..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/IterableParameterTests.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2013-2022 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.valid; - -import io.vavr.collection.HashSet; -import io.vavr.collection.Set; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient; -import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; -import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Spencer Gibb - */ -@SpringBootTest(classes = IterableParameterTests.Application.class, webEnvironment = WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=iterableparametertest", - "spring.cloud.openfeign.httpclient.hc5.enabled=false", "spring.cloud.openfeign.okhttp.enabled=false", - "spring.cloud.openfeign.circuitbreaker.enabled=false" }) -@DirtiesContext -class IterableParameterTests { - - @Autowired - private TestClient testClient; - - @Test - void testClient() { - assertThat(this.testClient).as("testClient was null").isNotNull(); - String results = this.testClient.echo(HashSet.of("a", "b")); - assertThat(results).isEqualTo("a,b"); - } - - @FeignClient(name = "localapp") - protected interface TestClient { - - @GetMapping("/echo") - String echo(@RequestParam Set set); - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients(clients = TestClient.class) - @LoadBalancerClient(name = "localapp", configuration = LocalLoadBalancerConfiguration.class) - @Import(NoSecurityConfiguration.class) - protected static class Application { - - @GetMapping("/echo") - public String echo(@RequestParam String set) { - return set; - } - - } - - // Load balancer with fixed server list for "local" pointing to localhost - public static class LocalLoadBalancerConfiguration { - - @LocalServerPort - private int port = 0; - - @Bean - public ServiceInstanceListSupplier staticServiceInstanceListSupplier() { - return ServiceInstanceListSuppliers.from("local", - new DefaultServiceInstance("local-1", "local", "localhost", port, false)); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/ValidFeignClientTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/ValidFeignClientTests.java deleted file mode 100644 index a8369f19e..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/ValidFeignClientTests.java +++ /dev/null @@ -1,801 +0,0 @@ -/* - * Copyright 2013-2022 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.valid; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Proxy; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; -import java.util.stream.Collectors; - -import feign.Client; -import feign.Logger; -import feign.RequestInterceptor; -import feign.codec.EncodeException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.Part; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients; -import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; -import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.FeignFormatterRegistrar; -import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient; -import org.springframework.cloud.openfeign.support.AbstractFormWriter; -import org.springframework.cloud.openfeign.support.JsonFormWriter; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.format.Formatter; -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; -import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE; -import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; - -/** - * @author Spencer Gibb - * @author Jakub Narloch - * @author Erik Kringen - * @author Halvdan Hoem Grelland - * @author Aaron Whiteside - * @author Darren Foong - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(classes = ValidFeignClientTests.Application.class, webEnvironment = WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=feignclienttest", "spring.cloud.openfeign.httpclient.hc5.enabled=false", - "spring.cloud.openfeign.okhttp.enabled=false", "spring.cloud.openfeign.circuitbreaker.enabled=true", - "spring.cloud.loadbalancer.retry.enabled=false" }) -@DirtiesContext -class ValidFeignClientTests { - - public static final String HELLO_WORLD_1 = "hello world 1"; - - public static final String OI_TERRA_2 = "oi terra 2"; - - public static final String MYHEADER1 = "myheader1"; - - public static final String MYHEADER2 = "myheader2"; - - @Autowired - private TestClient testClient; - - @Autowired - private TestClientServiceId testClientServiceId; - - @Autowired - private DecodingTestClient decodingTestClient; - - @Autowired - @Qualifier("localapp2FeignClient") - private DecodingTestClient namedFeignClient; - - @Autowired - private Client feignClient; - - @Autowired - private MultipartClient multipartClient; - - private static ArrayList getHelloList() { - ArrayList hellos = new ArrayList<>(); - hellos.add(new Hello(HELLO_WORLD_1)); - hellos.add(new Hello(OI_TERRA_2)); - return hellos; - } - - @Test - void testClient() { - assertThat(testClient).as("testClient was null").isNotNull(); - assertThat(Proxy.isProxyClass(testClient.getClass())).as("testClient is not a java Proxy").isTrue(); - InvocationHandler invocationHandler = Proxy.getInvocationHandler(testClient); - assertThat(invocationHandler).as("invocationHandler was null").isNotNull(); - } - - @Test - void testRequestMappingClassLevelPropertyReplacement() { - Hello hello = testClient.getHelloUsingPropertyPlaceHolder(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello(OI_TERRA_2)); - } - - @Test - public void testSimpleType() { - Hello hello = testClient.getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello(HELLO_WORLD_1)); - } - - @Test - void testOptional() { - Optional hello = testClient.getOptionalHello(); - assertThat(hello).isNotNull().isPresent().contains(new Hello(HELLO_WORLD_1)); - } - - @Test - void testGenericType() { - List hellos = testClient.getHellos(); - assertThat(hellos).as("hellos was null").isNotNull(); - assertThat(getHelloList()).as("hellos didn't match").isEqualTo(hellos); - } - - @Test - void testRequestInterceptors() { - List headers = testClient.getHelloHeaders(); - assertThat(headers).as("headers was null").isNotNull(); - assertThat(headers.contains("myheader1value")).as("headers didn't contain myheader1value").isTrue(); - assertThat(headers.contains("myheader2value")).as("headers didn't contain myheader2value").isTrue(); - } - - @Test - void testHeaderPlaceholders() { - String header = testClient.getHelloHeadersPlaceholders(); - assertThat(header).as("header was null").isNotNull(); - assertThat(header).as("header was wrong").isEqualTo("myPlaceholderHeaderValue"); - } - - @Test - void testFeignClientType() { - assertThat(feignClient).isInstanceOf(FeignBlockingLoadBalancerClient.class); - FeignBlockingLoadBalancerClient client = (FeignBlockingLoadBalancerClient) feignClient; - Client delegate = client.getDelegate(); - assertThat(delegate).isInstanceOf(Client.Default.class); - } - - @Test - void testServiceId() { - assertThat(testClientServiceId).as("testClientServiceId was null").isNotNull(); - final Hello hello = testClientServiceId.getHello(); - assertThat(hello).as("The hello response was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello(HELLO_WORLD_1)); - } - - @Test - void testParams() { - List list = Arrays.asList("a", "1", "test"); - List params = testClient.getParams(list); - assertThat(params).as("params was null").isNotNull(); - assertThat(params.size()).as("params size was wrong").isEqualTo(list.size()); - } - - @Test - void testFormattedParams() { - List list = Arrays.asList(LocalDate.of(2001, 1, 1), LocalDate.of(2018, 6, 10)); - List params = testClient.getFormattedParams(list); - assertThat(params).as("params was null").isNotNull(); - assertThat(params).as("params not converted correctly").isEqualTo(list); - } - - @Test - void testNoContentResponse() { - ResponseEntity response = testClient.noContent(); - assertThat(response).as("response was null").isNotNull(); - assertThat(response.getStatusCode()).as("status code was wrong").isEqualTo(HttpStatus.NO_CONTENT); - } - - @Test - void testHeadResponse() { - ResponseEntity response = testClient.head(); - assertThat(response).as("response was null").isNotNull(); - assertThat(response.getStatusCode()).as("status code was wrong").isEqualTo(HttpStatus.OK); - } - - @Test - void testHttpEntity() { - HttpEntity entity = testClient.getHelloEntity(); - assertThat(entity).as("entity was null").isNotNull(); - Hello hello = entity.getBody(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo(new Hello(HELLO_WORLD_1)); - } - - @Test - void testMoreComplexHeader() { - String response = testClient.moreComplexContentType("{\"value\":\"OK\"}"); - assertThat(response).as("response was null").isNotNull(); - assertThat(response).as("didn't respond with {\"value\":\"OK\"}").isEqualTo("{\"value\":\"OK\"}"); - } - - @Test - void testDecodeNotFound() { - ResponseEntity response = decodingTestClient.notFound(); - assertThat(response).as("response was null").isNotNull(); - assertThat(response.getStatusCode()).as("status code was wrong").isEqualTo(HttpStatus.NOT_FOUND); - assertThat(response.getBody()).as("response body was not null").isNull(); - } - - @Test - void testOptionalNotFound() { - Optional s = decodingTestClient.optional(); - assertThat(s).isNotPresent(); - } - - @Test - void testConvertingExpander() { - assertThat(testClient.getToString(Arg.A)).isEqualTo(Arg.A.toString()); - assertThat(testClient.getToString(Arg.B)).isEqualTo(Arg.B.toString()); - - assertThat(testClient.getToString(new OtherArg("foo"))).isEqualTo("bar"); - List args = new ArrayList<>(); - args.add(new OtherArg("foo")); - args.add(new OtherArg("goo")); - List expectedResult = new ArrayList<>(); - expectedResult.add("bar"); - expectedResult.add("goo"); - assertThat(testClient.getToString(args)).isEqualTo(expectedResult); - } - - @Test - void testFormURLEncoded() { - Hello hello = new Hello(HELLO_WORLD_1); - Hello response = testClient.postFormUrlEncoded(hello); - assertThat(response).isEqualTo(hello); - } - - @Test - void namedFeignClientWorks() { - assertThat(namedFeignClient).as("namedFeignClient was null").isNotNull(); - } - - @Test - void testSingleRequestPart() { - String response = multipartClient.singlePart("abc"); - assertThat(response).isEqualTo("abc"); - } - - @Test - void testSinglePojoRequestPart() { - String response = multipartClient.singlePojoPart(new Hello(HELLO_WORLD_1)); - assertThat(response).isEqualTo(HELLO_WORLD_1); - } - - @Test - void testMultipleRequestParts() { - MockMultipartFile file = new MockMultipartFile("file", "hello.bin", null, "hello".getBytes()); - String response = multipartClient.multipart("abc", "123", file); - assertThat(response).isEqualTo("abc123hello.bin"); - } - - @Test - void testMultiplePojoRequestParts() { - Hello pojo1 = new Hello(HELLO_WORLD_1); - Hello pojo2 = new Hello(OI_TERRA_2); - MockMultipartFile file = new MockMultipartFile("file", "hello.bin", null, "hello".getBytes()); - String response = multipartClient.multipartPojo("abc", "123", pojo1, pojo2, file); - assertThat(response).isEqualTo("abc123hello world 1oi terra 2hello.bin"); - } - - @Test - void testRequestPartWithListOfMultipartFiles() { - List multipartFiles = Arrays.asList( - new MockMultipartFile("file1", "hello1.bin", null, "hello".getBytes()), - new MockMultipartFile("file2", "hello2.bin", null, "hello".getBytes())); - String partNames = multipartClient.requestPartListOfMultipartFilesReturnsPartNames(multipartFiles); - assertThat(partNames).isEqualTo("files,files"); - String fileNames = multipartClient.requestPartListOfMultipartFilesReturnsFileNames(multipartFiles); - assertThat(fileNames).contains("hello1.bin", "hello2.bin"); - } - - @Test - void testRequestPartWithListOfPojosAndListOfMultipartFiles() { - Hello pojo1 = new Hello(HELLO_WORLD_1); - Hello pojo2 = new Hello(OI_TERRA_2); - MockMultipartFile file1 = new MockMultipartFile("file1", "hello1.bin", null, "hello".getBytes()); - MockMultipartFile file2 = new MockMultipartFile("file2", "hello2.bin", null, "hello".getBytes()); - String response = multipartClient.requestPartListOfPojosAndListOfMultipartFiles(Arrays.asList(pojo1, pojo2), - Arrays.asList(file1, file2)); - assertThat(response).isEqualTo("hello world 1oi terra 2hello1.binhello2.bin"); - } - - @Test - void testRequestBodyWithSingleMultipartFile() { - String partName = UUID.randomUUID().toString(); - MockMultipartFile file1 = new MockMultipartFile(partName, "hello1.bin", null, "hello".getBytes()); - String response = multipartClient.requestBodySingleMultipartFile(file1); - assertThat(response).isEqualTo(partName); - } - - @Test - void testRequestBodyWithListOfMultipartFiles() { - MockMultipartFile file1 = new MockMultipartFile("file1", "hello1.bin", null, "hello".getBytes()); - MockMultipartFile file2 = new MockMultipartFile("file2", "hello2.bin", null, "hello".getBytes()); - String response = multipartClient.requestBodyListOfMultipartFiles(Arrays.asList(file1, file2)); - assertThat(response).contains("file1", "file2"); - } - - @Test - void testRequestBodyWithMap() { - MockMultipartFile file1 = new MockMultipartFile("file1", "hello1.bin", null, "hello".getBytes()); - MockMultipartFile file2 = new MockMultipartFile("file2", "hello2.bin", null, "hello".getBytes()); - Map form = new HashMap<>(); - form.put("file1", file1); - form.put("file2", file2); - form.put("hello", "world"); - String response = multipartClient.requestBodyMap(form); - assertThat(response).contains("file1", "file2", "hello"); - } - - @Test - void testInvalidMultipartFile() { - assertThatExceptionOfType(EncodeException.class).isThrownBy(() -> { - MockMultipartFile file = new MockMultipartFile("file1", "hello1.bin", null, "hello".getBytes()); - multipartClient.invalid(file); - }); - } - - protected enum Arg { - - A, B; - - @Override - public String toString() { - return name().toLowerCase(Locale.ENGLISH); - } - - } - - @FeignClient(name = "localapp8") - protected interface MultipartClient { - - @PostMapping(path = "/singlePart", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String singlePart(@RequestPart("hello") String hello); - - @PostMapping(path = "/singlePojoPart", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String singlePojoPart(@RequestPart("hello") Hello hello); - - @PostMapping(path = "/multipart", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String multipart(@RequestPart("hello") String hello, @RequestPart("world") String world, - @RequestPart("file") MultipartFile file); - - @PostMapping(path = "/multipartPojo", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String multipartPojo(@RequestPart("hello") String hello, @RequestPart("world") String world, - @RequestPart("pojo1") Hello pojo1, @RequestPart("pojo2") Hello pojo2, - @RequestPart("file") MultipartFile file); - - @PostMapping(path = "/multipartNames", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String requestPartListOfMultipartFilesReturnsPartNames(@RequestPart("files") List files); - - @PostMapping(path = "/multipartFilenames", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String requestPartListOfMultipartFilesReturnsFileNames(@RequestPart("files") List files); - - @PostMapping(path = "/multipartPojosFiles", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String requestPartListOfPojosAndListOfMultipartFiles(@RequestPart("pojos") List pojos, - @RequestPart("files") List files); - - @PostMapping(path = "/multipartNames", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String requestBodyListOfMultipartFiles(@RequestBody List files); - - @PostMapping(path = "/multipartNames", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String requestBodySingleMultipartFile(@RequestBody MultipartFile file); - - @PostMapping(path = "/multipartNames", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String requestBodyMap(@RequestBody Map form); - - @PostMapping(path = "/invalid", consumes = MediaType.APPLICATION_OCTET_STREAM_VALUE, - produces = TEXT_PLAIN_VALUE) - String invalid(@RequestBody MultipartFile file); - - } - - @FeignClient(name = "localapp", configuration = TestClientConfig.class) - protected interface TestClient { - - @GetMapping("/hello") - Hello getHello(); - - @GetMapping("/hello") - Optional getOptionalHello(); - - @GetMapping("${feignClient.methodLevelRequestMappingPath}") - Hello getHelloUsingPropertyPlaceHolder(); - - @GetMapping("/hellos") - List getHellos(); - - @GetMapping("/hellostrings") - List getHelloStrings(); - - @GetMapping("/helloheaders") - List getHelloHeaders(); - - @GetMapping(path = "/helloheadersplaceholders", - headers = "myPlaceholderHeader=${feignClient.myPlaceholderHeader}") - String getHelloHeadersPlaceholders(); - - @GetMapping("/helloparams") - List getParams(@RequestParam("params") List params); - - @GetMapping("/formattedparams") - List getFormattedParams( - @RequestParam("params") @DateTimeFormat(pattern = "dd-MM-yyyy") List params); - - @GetMapping("/noContent") - ResponseEntity noContent(); - - @RequestMapping(method = RequestMethod.HEAD, path = "/head") - ResponseEntity head(); - - @RequestMapping(method = RequestMethod.GET, path = "/hello") - HttpEntity getHelloEntity(); - - @RequestMapping(method = RequestMethod.POST, consumes = "application/vnd.io.spring.cloud.test.v1+json", - produces = "application/vnd.io.spring.cloud.test.v1+json", path = "/complex") - String moreComplexContentType(String body); - - @GetMapping("/tostring") - String getToString(@RequestParam("arg") Arg arg); - - @GetMapping("/tostring2") - String getToString(@RequestParam("arg") OtherArg arg); - - @GetMapping("/tostringcollection") - Collection getToString(@RequestParam("arg") Collection args); - - @PostMapping(path = "/form-urlencoded", consumes = APPLICATION_FORM_URLENCODED_VALUE) - Hello postFormUrlEncoded(Hello hello); - - } - - @FeignClient(name = "localapp1") - protected interface TestClientServiceId { - - @GetMapping("/hello") - Hello getHello(); - - } - - @FeignClient(name = "localapp2", dismiss404 = true) - protected interface DecodingTestClient { - - @GetMapping("/notFound") - ResponseEntity notFound(); - - @GetMapping("/notFound") - Optional optional(); - - } - - protected static class OtherArg { - - public final String value; - - public OtherArg(String value) { - this.value = value; - } - - @Override - public String toString() { - return value; - } - - } - - public static class TestClientConfig { - - @Bean - public RequestInterceptor interceptor1() { - return template -> template.header(MYHEADER1, "myheader1value"); - } - - @Bean - public RequestInterceptor interceptor2() { - return template -> template.header(MYHEADER2, "myheader2value"); - } - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients( - clients = { TestClientServiceId.class, TestClient.class, DecodingTestClient.class, MultipartClient.class }, - defaultConfiguration = TestDefaultFeignConfig.class) - @LoadBalancerClients({ - - @LoadBalancerClient(name = "localapp", configuration = LocalLoadBalancerClientConfiguration.class), - - @LoadBalancerClient(name = "localapp1", configuration = LocalLoadBalancerClientConfiguration.class), - - @LoadBalancerClient(name = "localapp2", configuration = LocalLoadBalancerClientConfiguration.class), - @LoadBalancerClient(name = "localapp8", configuration = LocalLoadBalancerClientConfiguration.class) }) - @Import(NoSecurityConfiguration.class) - protected static class Application { - - public static void main(String[] args) { - new SpringApplicationBuilder(Application.class) - .properties("spring.application.name=feignclienttest", "management.contextPath=/admin").run(args); - } - - @Bean - FeignFormatterRegistrar feignFormatterRegistrar() { - return registry -> registry.addFormatter(new Formatter() { - - @Override - public String print(OtherArg object, Locale locale) { - if ("foo".equals(object.value)) { - return "bar"; - } - return object.value; - } - - @Override - public OtherArg parse(String text, Locale locale) { - return new OtherArg(text); - } - }); - } - - @Bean - public AbstractFormWriter jsonFormWriter() { - return new JsonFormWriter(); - } - - @GetMapping("/hello") - public Hello getHello() { - return new Hello(HELLO_WORLD_1); - } - - @GetMapping("/hello2") - public Hello getHello2() { - return new Hello(OI_TERRA_2); - } - - @GetMapping("/hellos") - public List getHellos() { - ArrayList hellos = getHelloList(); - return hellos; - } - - @GetMapping("/hellostrings") - public List getHelloStrings() { - ArrayList hellos = new ArrayList<>(); - hellos.add(HELLO_WORLD_1); - hellos.add(OI_TERRA_2); - return hellos; - } - - @GetMapping("/helloheaders") - public List getHelloHeaders(@RequestHeader(MYHEADER1) String myheader1, - @RequestHeader(MYHEADER2) String myheader2) { - ArrayList headers = new ArrayList<>(); - headers.add(myheader1); - headers.add(myheader2); - return headers; - } - - @GetMapping("/helloheadersplaceholders") - public String getHelloHeadersPlaceholders(@RequestHeader("myPlaceholderHeader") String myPlaceholderHeader) { - return myPlaceholderHeader; - } - - @GetMapping("/helloparams") - public List getParams(@RequestParam("params") List params) { - return params; - } - - @GetMapping("/formattedparams") - public List getFormattedParams( - @RequestParam("params") @DateTimeFormat(pattern = "dd-MM-yyyy") List params) { - return params; - } - - @GetMapping("/noContent") - ResponseEntity noContent() { - return ResponseEntity.noContent().build(); - } - - @RequestMapping(method = RequestMethod.HEAD, path = "/head") - ResponseEntity head() { - return ResponseEntity.ok().build(); - } - - @RequestMapping(method = RequestMethod.GET, path = "/fail") - String fail() { - throw new RuntimeException("always fails"); - } - - @GetMapping("/notFound") - ResponseEntity notFound() { - return ResponseEntity.status(HttpStatus.NOT_FOUND).body((String) null); - } - - @RequestMapping(method = RequestMethod.POST, consumes = "application/vnd.io.spring.cloud.test.v1+json", - produces = "application/vnd.io.spring.cloud.test.v1+json", path = "/complex") - String complex(@RequestBody String body, @RequestHeader("Content-Length") int contentLength) { - if (contentLength <= 0) { - throw new IllegalArgumentException("Invalid Content-Length " + contentLength); - } - return body; - } - - @GetMapping("/tostring") - String getToString(@RequestParam("arg") Arg arg) { - return arg.toString(); - } - - @GetMapping("/tostring2") - String getToString(@RequestParam("arg") OtherArg arg) { - return arg.value; - } - - @GetMapping("/tostringcollection") - Collection getToString(@RequestParam("arg") Collection args) { - List result = new ArrayList<>(); - for (OtherArg arg : args) { - result.add(arg.value); - } - return result; - } - - @PostMapping(path = "/singlePart", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String singlePart(@RequestPart("hello") String hello) { - return hello; - } - - @PostMapping(path = "/singlePojoPart", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String singlePojoPart(@RequestPart("hello") Hello hello) { - return hello.getMessage(); - } - - @PostMapping(path = "/multipart", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String multipart(@RequestPart("hello") String hello, @RequestPart("world") String world, - @RequestPart("file") MultipartFile file) { - return hello + world + file.getOriginalFilename(); - } - - @PostMapping(path = "/multipartPojo", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String multipartPojo(@RequestPart("hello") String hello, @RequestPart("world") String world, - @RequestPart("pojo1") Hello pojo1, @RequestPart("pojo2") Hello pojo2, - @RequestPart("file") MultipartFile file) { - return hello + world + pojo1.getMessage() + pojo2.getMessage() + file.getOriginalFilename(); - } - - @PostMapping(path = "/multipartNames", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String multipartNames(HttpServletRequest request) throws Exception { - return request.getParts().stream().map(Part::getName).collect(Collectors.joining(",")); - } - - @PostMapping(path = "/multipartFilenames", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String multipartFilenames(HttpServletRequest request) throws Exception { - return request.getParts().stream().map(Part::getSubmittedFileName).collect(Collectors.joining(",")); - } - - @PostMapping(path = "/multipartPojosFiles", consumes = MULTIPART_FORM_DATA_VALUE, produces = TEXT_PLAIN_VALUE) - String requestPartListOfPojosAndListOfMultipartFiles(@RequestPart("pojos") List pojos, - @RequestPart("files") List files) { - StringBuilder result = new StringBuilder(); - - for (Hello pojo : pojos) { - result.append(pojo.getMessage()); - } - - for (MultipartFile file : files) { - result.append(file.getOriginalFilename()); - } - - return result.toString(); - } - - @PostMapping(path = "/form-urlencoded", consumes = APPLICATION_FORM_URLENCODED_VALUE) - Hello postFormUrlEncoded(Hello hello) { - return hello; - } - - } - - public static class Hello { - - private String message; - - Hello() { - } - - Hello(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Hello that = (Hello) o; - return Objects.equals(message, that.message); - } - - @Override - public int hashCode() { - return Objects.hash(message); - } - - } - - @Configuration(proxyBeanMethods = false) - public static class TestDefaultFeignConfig { - - @Bean - Logger.Level feignLoggerLevel() { - return Logger.Level.FULL; - } - - } - - // Load balancer with fixed server list for "local" pointing to localhost - @Configuration(proxyBeanMethods = false) - public static class LocalLoadBalancerClientConfiguration { - - @LocalServerPort - private int port = 0; - - @Bean - public ServiceInstanceListSupplier staticServiceInstanceListSupplier() { - return ServiceInstanceListSuppliers.from("local", - new DefaultServiceInstance("local-1", "local", "localhost", port, false)); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientEnvVarTests.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientEnvVarTests.java deleted file mode 100644 index fd42d0144..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientEnvVarTests.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2013-2022 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.valid.scanning; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient; -import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; -import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.cloud.openfeign.testclients.TestClient; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * @author Ryan Baxter - */ -@SpringBootTest(classes = FeignClientEnvVarTests.Application.class, webEnvironment = RANDOM_PORT, - value = { "spring.application.name=feignclienttest", "spring.cloud.openfeign.httpclient.hc5.enabled=false", - "basepackage=org.springframework.cloud.openfeign.testclients" }) -@DirtiesContext -class FeignClientEnvVarTests { - - @Autowired - private TestClient testClient; - - @Test - void testSimpleType() { - String hello = this.testClient.getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo("hello world 1"); - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients(basePackages = { "${basepackage}" }) - @LoadBalancerClient(name = "localapp", configuration = LocalClientConfiguration.class) - @Import(NoSecurityConfiguration.class) - protected static class Application { - - @GetMapping("/hello") - public String getHello() { - return "hello world 1"; - } - - } - - // Load balancer with fixed server list for "local" pointing to localhost - @Configuration(proxyBeanMethods = false) - public static class LocalClientConfiguration { - - @LocalServerPort - private int port = 0; - - @Bean - public ServiceInstanceListSupplier staticServiceInstanceListSupplier() { - return ServiceInstanceListSuppliers.from("localapp", - new DefaultServiceInstance("localapp-1", "localapp", "localhost", port, false)); - } - - } - -} 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 deleted file mode 100644 index 00c895157..000000000 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/valid/scanning/FeignClientScanningTests.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2013-2022 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.valid.scanning; - -import feign.Client; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients; -import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; -import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.test.NoSecurityConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * @author Spencer Gibb - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(classes = FeignClientScanningTests.Application.class, webEnvironment = RANDOM_PORT, - value = { "spring.application.name=feignclienttest", "spring.cloud.openfeign.httpclient.hc5.enabled=false" }) -@DirtiesContext -class FeignClientScanningTests { - - @Autowired - private TestClient testClient; - - @Autowired - private TestClientByKey testClientByKey; - - @Autowired - @SuppressWarnings("unused") - private Client feignClient; - - @Test - void testSimpleType() { - String hello = this.testClient.getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo("hello world 1"); - } - - @Test - void testSimpleTypeByKey() { - String hello = this.testClientByKey.getHello(); - assertThat(hello).as("hello was null").isNotNull(); - assertThat(hello).as("first hello didn't match").isEqualTo("hello world 1"); - } - - @FeignClient("localapp123") - protected interface TestClient { - - @GetMapping("/hello") - String getHello(); - - } - - @FeignClient("${feignClient.localappName}") - protected interface TestClientByKey { - - @GetMapping("/hello") - String getHello(); - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @RestController - @EnableFeignClients // NO clients attribute. That's what this class is testing! - @LoadBalancerClients(defaultConfiguration = LocalClientConfiguration.class) - @Import(NoSecurityConfiguration.class) - protected static class Application { - - @GetMapping("/hello") - public String getHello() { - return "hello world 1"; - } - - } - - // Load balancer with fixed server list for "local" pointing to localhost - @Configuration(proxyBeanMethods = false) - static class LocalClientConfiguration { - - @LocalServerPort - private int port = 0; - - @Bean - public ServiceInstanceListSupplier staticServiceInstanceListSupplier() { - return ServiceInstanceListSuppliers.from("local", - new DefaultServiceInstance("local-1", "local", "localhost", port, false)); - } - - } - -} diff --git a/spring-cloud-openfeign-core/src/test/resources/application.yml b/spring-cloud-openfeign-core/src/test/resources/application.yml deleted file mode 100644 index fcb7c398f..000000000 --- a/spring-cloud-openfeign-core/src/test/resources/application.yml +++ /dev/null @@ -1,31 +0,0 @@ -server: - port: 9999 - compression: - enabled: true - min-response-size: 1024 - mime-types: application/xml,application/json -spring: - application: - name: testclient -eureka: - server: - enabled: false - client: - registerWithEureka: false - fetchRegistry: false -endpoints: - health: - sensitive: false -feignClient: - localappName: localapp - methodLevelRequestMappingPath: /hello2 - myPlaceholderHeader: myPlaceholderHeaderValue -management.endpoints.web.expose: '*' - ---- -spring.config.activate.on-profile: no-micrometer -spring.cloud.openfeign.micrometer.enabled: false - ---- -spring.config.activate.on-profile: no-foo-micrometer -spring.cloud.openfeign.client.config.foo.micrometer.enabled: false diff --git a/spring-cloud-openfeign-core/src/test/resources/dummy.pdf b/spring-cloud-openfeign-core/src/test/resources/dummy.pdf deleted file mode 100644 index 774c2ea70c55104973794121eae56bcad918da97..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13264 zcmaibWmsIxvUW%|5FkJZ7A&~y%m9Oj;I6>~WPrgfxD$eVfZ*=#?hsspJHa(bATYRn zGueBev(G*EKHr+BrK+pDs^6;aH9u<6Dv3$30@ygwX}fZ|TDt1G($Rqw927PN=I8~c_R69-cY5S*jJE@5Wr0JUS6u!J~3#h`{ZMo=LkbbALoD8vfgB}Fh|2>mhOnfS$3 zNV5}8Ox=$fj;C0=UKy*{myZZPRVS|0mqr-HxZAy;()@wxQ}MN`QWAZTXb3Z&Om9W2 zbnA^OWoQbAW|3W^fw#J;YzDato8*`rHQs+@W70D&SyT{wb`SN*3nI z5G%$wJlq932=n{60Eii*9H8dFih2ks?QY=>nAFL=5g^P@#b{YUEHt0S$D7WbX zx%TzvzIK%zpvzLEd9LNr0ch#LFf_(9 zEGt0C9v~%b54vynAc{~;v&2?S(-sTTft@9CABMNFZHtY1W0-99CEbUNfp_yu{LDBz z@8z^$LPN$wX4Hi+dZQs6K3QiKKF0}Nme@EII;;F}IplC(YvT*C3-Oh#(A}e5pIz01 zyR}D2|ftBF0T=1moHZy}$wS*PSCmSzHQ%x z2tCQQCx4jt7w1cuhY69~eH`31KC4)ZZJ^)f=IabocAkBPa zEeg25yPX&9-i_N(Qiq!I3RDrfx&0t^i)&MSQ1D(w%|%#LTNr>1cPiltAYO;6kBn(B?r11c^Bz~#)z5~~V+*`U)lDFtKbZ|;? z&4wTUtK=KE&uQIWUQv1mDE;LIhXXgx44PMa@%Z<7a& zx45^oYSnei^~%}`?!O-+cgfSmn_c?`=Gmm*Z^I(96ve&$zDs|)r84)IEEiE1kfQ$q zm3km*m1)PjdU9nkk9BTlidI1~M|O~WfP7AUu2T}d>5is9l$<%;7r2&Re06w>W$KM~ zqITBTd=Ln>^crw`_N?{ z;2d_=E0n!*NisQ|XY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~oUj5Zv+q!Gl}N`CoDX0N4M*gTIpgb1nb?;)Y)s|FIqb0Ot6gw!m#h zTnhg~j+YZ2)c?r?0yzIm4hZ1=FTFrc;D6}=a`OJeW(PY6{AFi{I1;L6ZcsR+>?$@k z@FNVDLEL!K*2XpzfZwk|I3Y%%Lm?mm76XGtKw?0k2(JV$kO#;s#>p!o!6gRf5#f;l j@(7{-|3%=32kuUL2Z)`+Z(jm{U>-0!Ev>ks1p5C2Hj`#V diff --git a/spring-cloud-openfeign-core/src/test/resources/feign-properties.properties b/spring-cloud-openfeign-core/src/test/resources/feign-properties.properties deleted file mode 100644 index b4c6e9ef8..000000000 --- a/spring-cloud-openfeign-core/src/test/resources/feign-properties.properties +++ /dev/null @@ -1,30 +0,0 @@ -# This configuration used by test class FeignClientUsingPropertiesTests -logging.level.org.springframework.cloud.openfeign=debug -spring.cloud.openfeign.client.default-to-properties=true -spring.cloud.openfeign.client.default-config=default -spring.cloud.openfeign.client.config.default.connectTimeout=5000 -spring.cloud.openfeign.client.config.default.readTimeout=5000 -spring.cloud.openfeign.client.config.default.loggerLevel=full -spring.cloud.openfeign.client.config.default.errorDecoder=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.DefaultErrorDecoder -spring.cloud.openfeign.client.config.default.retryer=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.NoRetryer -spring.cloud.openfeign.client.config.default.dismiss404=true -spring.cloud.openfeign.client.config.default.capabilities=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.NoOpCapability -spring.cloud.openfeign.client.config.default.queryMapEncoder=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.NoOpQueryMapEncoder -spring.cloud.openfeign.client.config.foo.requestInterceptors[0]=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.FooRequestInterceptor -spring.cloud.openfeign.client.config.foo.requestInterceptors[1]=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.BarRequestInterceptor -spring.cloud.openfeign.client.config.baz.responseInterceptor=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.BazResponseInterceptor -spring.cloud.openfeign.client.config.singleValue.defaultRequestHeaders[singleValueHeaders]=header -spring.cloud.openfeign.client.config.singleValue.defaultQueryParameters[singleValueParameters]=parameter -spring.cloud.openfeign.client.config.multipleValue.defaultRequestHeaders[multipleValueHeaders]=header1,header2 -spring.cloud.openfeign.client.config.multipleValue.defaultQueryParameters[multipleValueParameters]=parameter1,parameter2 -spring.cloud.openfeign.client.config.bar.connectTimeout=1000 -spring.cloud.openfeign.client.config.bar.readTimeout=1000 -spring.cloud.openfeign.client.config.form.encoder=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.FormEncoder -spring.cloud.openfeign.client.config.unwrap.connectTimeout=1000 -spring.cloud.openfeign.client.config.unwrap.readTimeout=1000 -spring.cloud.openfeign.client.config.unwrap.exceptionPropagationPolicy=unwrap -spring.cloud.openfeign.client.config.readTimeout.readTimeout=1000 -spring.cloud.openfeign.client.config.connectTimeout.connectTimeout=1000 -spring.cloud.openfeign.client.config.default.followRedirects=false -spring.cloud.openfeign.client.config.feignClientWithFixUrl.url=http://localhost:8888 -spring.cloud.openfeign.client.config.configBasedClient.url=http://localhost:9999 diff --git a/spring-cloud-openfeign-core/src/test/resources/feign-refreshable-properties.properties b/spring-cloud-openfeign-core/src/test/resources/feign-refreshable-properties.properties deleted file mode 100644 index e79a9a6e0..000000000 --- a/spring-cloud-openfeign-core/src/test/resources/feign-refreshable-properties.properties +++ /dev/null @@ -1,13 +0,0 @@ -# This configuration used by test class FeignClientWithRefreshableOptionsTest -logging.level.org.springframework.cloud.openfeign=debug -spring.cloud.openfeign.client.default-to-properties=true -spring.cloud.openfeign.client.default-config=default -spring.cloud.openfeign.client.refresh-enabled=true -spring.cloud.openfeign.client.config.default.connectTimeout=5000 -spring.cloud.openfeign.client.config.default.readTimeout=5000 -spring.cloud.openfeign.client.config.default.loggerLevel=full -spring.cloud.openfeign.client.config.connectTimeout.connectTimeout=2000 -spring.cloud.openfeign.client.config.readTimeout.readTimeout=2000 -spring.cloud.openfeign.client.config.refreshableClient.url=http://localhost:8082 -spring.cloud.openfeign.client.config.refreshableClientWithFixUrl.url=http://localhost:8888 -spring.cloud.openfeign.client.config.refreshableClientForContextRefreshCase.url=http://localhost:8080 diff --git a/spring-cloud-openfeign-core/src/test/resources/logback-test.xml b/spring-cloud-openfeign-core/src/test/resources/logback-test.xml deleted file mode 100644 index 6531f0e6e..000000000 --- a/spring-cloud-openfeign-core/src/test/resources/logback-test.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - \ No newline at end of file diff --git a/spring-cloud-openfeign-dependencies/pom.xml b/spring-cloud-openfeign-dependencies/pom.xml deleted file mode 100644 index 59bcc33e9..000000000 --- a/spring-cloud-openfeign-dependencies/pom.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - 4.0.0 - - spring-cloud-dependencies-parent - org.springframework.cloud - 4.1.0-SNAPSHOT - - - spring-cloud-openfeign-dependencies - 4.1.0-SNAPSHOT - pom - spring-cloud-openfeign-dependencies - Spring Cloud OpenFeign Dependencies - - 12.4 - 3.8.0 - - - - - org.springframework.cloud - spring-cloud-openfeign-core - ${project.version} - - - org.springframework.cloud - spring-cloud-starter-openfeign - ${project.version} - - - io.github.openfeign - feign-bom - ${feign.version} - pom - import - - - io.github.openfeign.form - feign-form-spring - ${feign-form.version} - - - commons-fileupload - commons-fileupload - - - - - commons-fileupload - commons-fileupload - 1.5 - - - - - - spring - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - diff --git a/spring-cloud-starter-openfeign/.flattened-pom.xml b/spring-cloud-starter-openfeign/.flattened-pom.xml new file mode 100644 index 000000000..4ba9deefd --- /dev/null +++ b/spring-cloud-starter-openfeign/.flattened-pom.xml @@ -0,0 +1,144 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-openfeign + 4.1.0-SNAPSHOT + .. + + org.springframework.cloud + spring-cloud-starter-openfeign + 4.1.0-SNAPSHOT + Spring Cloud Starter OpenFeign + Spring Cloud Starter OpenFeign + https://projects.spring.io/spring-cloud + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 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. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-openfeign.git/spring-cloud-starter-openfeign + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-openfeign.git/spring-cloud-starter-openfeign + https://github.com/spring-cloud/spring-cloud-openfeign + + + + org.springframework.cloud + spring-cloud-starter + 4.1.0-SNAPSHOT + compile + + + org.springframework.cloud + spring-cloud-openfeign-core + 4.1.0-SNAPSHOT + compile + + + org.springframework + spring-web + 6.1.0-SNAPSHOT + compile + + + org.springframework.cloud + spring-cloud-commons + 4.1.0-SNAPSHOT + compile + + + io.github.openfeign + feign-core + 12.4 + compile + + + io.github.openfeign + feign-slf4j + 12.4 + compile + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + 4.1.0-SNAPSHOT + compile + true + + + diff --git a/spring-cloud-starter-openfeign/pom.xml b/spring-cloud-starter-openfeign/pom.xml deleted file mode 100644 index 8b0eebfe8..000000000 --- a/spring-cloud-starter-openfeign/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - 4.0.0 - - org.springframework.cloud - spring-cloud-openfeign - 4.1.0-SNAPSHOT - .. - - - https://github.com/spring-cloud/spring-cloud-openfeign - - spring-cloud-starter-openfeign - Spring Cloud Starter OpenFeign - Spring Cloud Starter OpenFeign - https://projects.spring.io/spring-cloud - - Pivotal Software, Inc. - https://www.spring.io - - - ${basedir}/../.. - - - - org.springframework.cloud - spring-cloud-starter - - - org.springframework.cloud - spring-cloud-openfeign-core - - - org.springframework - spring-web - - - org.springframework.cloud - spring-cloud-commons - - - io.github.openfeign - feign-core - - - io.github.openfeign - feign-slf4j - - - org.springframework.cloud - spring-cloud-starter-loadbalancer - true - - - diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml deleted file mode 100644 index e3cf17bb3..000000000 --- a/src/checkstyle/checkstyle-suppressions.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/supplemental-ui/partials/nav-search.hbs b/supplemental-ui/partials/nav-search.hbs new file mode 100644 index 000000000..5e3795528 --- /dev/null +++ b/supplemental-ui/partials/nav-search.hbs @@ -0,0 +1,11 @@ +{{#if env.ALGOLIA_API_KEY}} + +{{/if}} diff --git a/supplemental-ui/partials/search.hbs b/supplemental-ui/partials/search.hbs new file mode 100644 index 000000000..384e505f6 --- /dev/null +++ b/supplemental-ui/partials/search.hbs @@ -0,0 +1,27 @@ + +{{#if env.ALGOLIA_API_KEY}} + + + + + + + + +{{/if}}