diff --git a/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java b/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java index b6c2440c4e9..02d3aaace8f 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java @@ -189,12 +189,7 @@ final class ArchitectureRules { } private static ArchRule allPackagesShouldBeFreeOfTangles() { - return SlicesRuleDefinition.slices() - .matching("(**)") - .should() - .beFreeOfCycles() - .ignoreDependency("org.springframework.boot.env.EnvironmentPostProcessor", - "org.springframework.boot.SpringApplication"); + return SlicesRuleDefinition.slices().matching("(**)").should().beFreeOfCycles(); } private static ArchRule allBeanPostProcessorBeanMethodsShouldBeStaticAndNotCausePrematureInitialization() { diff --git a/core/spring-boot/src/main/java/org/springframework/boot/env/EnvironmentPostProcessor.java b/core/spring-boot/src/main/java/org/springframework/boot/env/EnvironmentPostProcessor.java deleted file mode 100644 index 08ccbaf1d7a..00000000000 --- a/core/spring-boot/src/main/java/org/springframework/boot/env/EnvironmentPostProcessor.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.env; - -import org.springframework.boot.bootstrap.BootstrapContext; -import org.springframework.boot.bootstrap.BootstrapRegistry; -import org.springframework.boot.bootstrap.ConfigurableBootstrapContext; -import org.springframework.boot.logging.DeferredLogFactory; -import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.env.Environment; - -/** - * Allows for customization of the application's {@link Environment} prior to the - * application context being refreshed. - *

- * EnvironmentPostProcessor implementations have to be registered in - * {@code META-INF/spring.factories}, using the fully qualified name of this class as the - * key. Implementations may implement the {@link org.springframework.core.Ordered Ordered} - * interface or use an {@link org.springframework.core.annotation.Order @Order} annotation - * if they wish to be invoked in specific order. - *

- * Since Spring Boot 2.4, {@code EnvironmentPostProcessor} implementations may optionally - * take the following constructor parameters: - *

- * - * @author Andy Wilkinson - * @author Stephane Nicoll - * @since 1.3.0 - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link org.springframework.boot.EnvironmentPostProcessor} - */ -@FunctionalInterface -@Deprecated(since = "4.0.0", forRemoval = true) -public interface EnvironmentPostProcessor { - - /** - * Post-process the given {@code environment}. - * @param environment the environment to post-process - * @param application the application to which the environment belongs - */ - void postProcessEnvironment(ConfigurableEnvironment environment, - org.springframework.boot.SpringApplication application); - -} diff --git a/core/spring-boot/src/main/java/org/springframework/boot/support/SpringFactoriesEnvironmentPostProcessorsFactory.java b/core/spring-boot/src/main/java/org/springframework/boot/support/SpringFactoriesEnvironmentPostProcessorsFactory.java index 745686055cf..f0bc7310540 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/support/SpringFactoriesEnvironmentPostProcessorsFactory.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/support/SpringFactoriesEnvironmentPostProcessorsFactory.java @@ -16,18 +16,13 @@ package org.springframework.boot.support; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import org.springframework.boot.EnvironmentPostProcessor; -import org.springframework.boot.SpringApplication; import org.springframework.boot.bootstrap.BootstrapContext; import org.springframework.boot.bootstrap.BootstrapRegistry; import org.springframework.boot.bootstrap.ConfigurableBootstrapContext; import org.springframework.boot.logging.DeferredLogFactory; -import org.springframework.core.annotation.AnnotationAwareOrderComparator; -import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.io.support.SpringFactoriesLoader; import org.springframework.core.io.support.SpringFactoriesLoader.ArgumentResolver; @@ -51,35 +46,7 @@ class SpringFactoriesEnvironmentPostProcessorsFactory implements EnvironmentPost argumentResolver = argumentResolver.and(ConfigurableBootstrapContext.class, bootstrapContext); argumentResolver = argumentResolver.and(BootstrapContext.class, bootstrapContext); argumentResolver = argumentResolver.and(BootstrapRegistry.class, bootstrapContext); - List postProcessors = new ArrayList<>(); - postProcessors.addAll(this.loader.load(EnvironmentPostProcessor.class, argumentResolver)); - postProcessors.addAll(loadDeprecatedPostProcessors(argumentResolver)); - AnnotationAwareOrderComparator.sort(postProcessors); - return postProcessors.stream().map(Adapter::apply).collect(Collectors.toCollection(ArrayList::new)); - } - - @SuppressWarnings("removal") - private List loadDeprecatedPostProcessors( - ArgumentResolver argumentResolver) { - return this.loader.load(org.springframework.boot.env.EnvironmentPostProcessor.class, argumentResolver); - } - - @SuppressWarnings("removal") - record Adapter( - org.springframework.boot.env.EnvironmentPostProcessor postProcessor) implements EnvironmentPostProcessor { - - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - this.postProcessor.postProcessEnvironment(environment, application); - } - - static EnvironmentPostProcessor apply(Object source) { - if (source instanceof EnvironmentPostProcessor environmentPostProcessor) { - return environmentPostProcessor; - } - return new Adapter((org.springframework.boot.env.EnvironmentPostProcessor) source); - } - + return this.loader.load(EnvironmentPostProcessor.class, argumentResolver); } } diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/ROOT/pages/redirect.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/ROOT/pages/redirect.adoc index f5de88d29eb..393ca0ded32 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/ROOT/pages/redirect.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/ROOT/pages/redirect.adoc @@ -1200,7 +1200,6 @@ * xref:reference:actuator/tracing.adoc#actuator.micrometer-tracing.tests[#actuator.micrometer-tracing.tests] * xref:reference:actuator/tracing.adoc#actuator.micrometer-tracing.tracer-implementations.brave-zipkin[#actuator.micrometer-tracing.tracer-implementations.brave-zipkin] * xref:reference:actuator/tracing.adoc#actuator.micrometer-tracing.tracer-implementations.otel-otlp[#actuator.micrometer-tracing.tracer-implementations.otel-otlp] -* xref:reference:actuator/tracing.adoc#actuator.micrometer-tracing.tracer-implementations.otel-zipkin[#actuator.micrometer-tracing.tracer-implementations.otel-zipkin] * xref:reference:actuator/tracing.adoc#actuator.micrometer-tracing.tracer-implementations[#actuator.micrometer-tracing.tracer-implementations] * xref:reference:actuator/tracing.adoc#actuator.micrometer-tracing.tracers[#actuator.micrometer-tracing.tracers] * xref:reference:actuator/tracing.adoc#actuator.micrometer-tracing[#actuator.micrometer-tracing] diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/tracing.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/tracing.adoc index 744e6fab240..1d270ff91cf 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/tracing.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/tracing.adoc @@ -125,24 +125,6 @@ The customizers take precedence over anything applied by the auto-configuration. -[[actuator.micrometer-tracing.tracer-implementations.otel-zipkin]] -=== OpenTelemetry With Zipkin - -WARNING: OpenTelemetry has https://opentelemetry.io/docs/specs/otel/trace/sdk_exporters/zipkin/[deprecated their Zipkin support]. -The auto-configuration for it will be removed in Spring Boot 4.2. -Either switch to Brave or consider using https://github.com/openzipkin-contrib/zipkin-otel[the Zipkin OTel module] for ingesting OTLP directly. - -Tracing with OpenTelemetry and reporting to Zipkin requires the following dependencies: - -* `org.springframework.boot:spring-boot-micrometer-tracing-opentelemetry` - Spring Boot's support for Micrometer Tracing over OpenTelemetry. -* `io.micrometer:micrometer-tracing-bridge-otel` - bridges the Micrometer Observation API to OpenTelemetry. -* `org.springframework.boot:spring-boot-zipkin` - Spring Boot's support for Zipkin. -* `io.opentelemetry:opentelemetry-exporter-zipkin` - OpenTelemetry exporter that reports traces to Zipkin. - -Use the `management.tracing.export.zipkin.*` configuration properties to configure reporting to Zipkin. - - - [[actuator.micrometer-tracing.tracer-implementations.brave-zipkin]] === OpenZipkin Brave With Zipkin diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/web/servlet.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/web/servlet.adoc index 5a01011474c..f4d095471a0 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/web/servlet.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/web/servlet.adoc @@ -278,22 +278,10 @@ spring: markdown: "text/markdown" ---- -As of Spring Framework 5.3, Spring MVC supports two strategies for matching request paths to controllers. -By default, Spring Boot uses the javadoc:org.springframework.web.util.pattern.PathPatternParser[] strategy. -javadoc:org.springframework.web.util.pattern.PathPatternParser[] is an https://spring.io/blog/2020/06/30/url-matching-with-pathpattern-in-spring-mvc[optimized implementation] but comes with some restrictions compared to the javadoc:org.springframework.util.AntPathMatcher[] strategy. -javadoc:org.springframework.web.util.pattern.PathPatternParser[] restricts usage of {url-spring-framework-docs}/web/webmvc/mvc-controller/ann-requestmapping.html#mvc-ann-requestmapping-uri-templates[some path pattern variants]. +Spring Boot uses the javadoc:org.springframework.web.util.pattern.PathPatternParser[] strategy for matching request paths to controllers. +javadoc:org.springframework.web.util.pattern.PathPatternParser[] is an https://spring.io/blog/2020/06/30/url-matching-with-pathpattern-in-spring-mvc[optimized implementation] but restricts usage of {url-spring-framework-docs}/web/webmvc/mvc-controller/ann-requestmapping.html#mvc-ann-requestmapping-uri-templates[some path pattern variants]. It is also incompatible with configuring the javadoc:org.springframework.web.servlet.DispatcherServlet[] with a path prefix (configprop:spring.mvc.servlet.path[]). -The strategy can be configured using the configprop:spring.mvc.pathmatch.matching-strategy[] configuration property, as shown in the following example: - -[configprops,yaml] ----- -spring: - mvc: - pathmatch: - matching-strategy: "ant-path-matcher" ----- - Spring MVC will throw a javadoc:org.springframework.web.servlet.NoHandlerFoundException[] if a handler is not found for a request. Note that, by default, the xref:web/servlet.adoc#web.servlet.spring-mvc.static-content[serving of static content] is mapped to `+/**+` and will, therefore, provide a handler for all requests. If no static content is available, javadoc:org.springframework.web.servlet.resource.ResourceHttpRequestHandler[] will throw a javadoc:org.springframework.web.servlet.resource.NoResourceFoundException[]. diff --git a/module/spring-boot-micrometer-tracing-opentelemetry/build.gradle b/module/spring-boot-micrometer-tracing-opentelemetry/build.gradle index 22f1cca8643..379b51490ee 100644 --- a/module/spring-boot-micrometer-tracing-opentelemetry/build.gradle +++ b/module/spring-boot-micrometer-tracing-opentelemetry/build.gradle @@ -37,9 +37,7 @@ dependencies { optional(project(":core:spring-boot-autoconfigure")) optional(project(":core:spring-boot-docker-compose")) optional(project(":core:spring-boot-testcontainers")) - optional(project(":module:spring-boot-zipkin")) optional("io.micrometer:micrometer-tracing-bridge-otel") - optional("io.opentelemetry:opentelemetry-exporter-zipkin") optional("io.opentelemetry:opentelemetry-exporter-otlp") optional("org.junit.platform:junit-platform-launcher") optional("org.testcontainers:testcontainers-grafana") diff --git a/module/spring-boot-micrometer-tracing-opentelemetry/src/main/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/ZipkinWithOpenTelemetryTracingAutoConfiguration.java b/module/spring-boot-micrometer-tracing-opentelemetry/src/main/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/ZipkinWithOpenTelemetryTracingAutoConfiguration.java deleted file mode 100644 index 2968cac5727..00000000000 --- a/module/spring-boot-micrometer-tracing-opentelemetry/src/main/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/ZipkinWithOpenTelemetryTracingAutoConfiguration.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.micrometer.tracing.opentelemetry.autoconfigure.zipkin; - -import io.opentelemetry.exporter.zipkin.ZipkinSpanExporter; -import zipkin2.Span; -import zipkin2.reporter.BytesEncoder; -import zipkin2.reporter.BytesMessageSender; -import zipkin2.reporter.Encoding; -import zipkin2.reporter.SpanBytesEncoder; - -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -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.micrometer.tracing.autoconfigure.ConditionalOnEnabledTracingExport; -import org.springframework.context.annotation.Bean; - -/** - * {@link EnableAutoConfiguration Auto-configuration} for Zipkin tracing with - * OpenTelemetry. - * - * @author Moritz Halbritter - * @author Stefan Bratanov - * @author Wick Dynex - * @author Phillip Webb - * @since 4.0.0 - * @deprecated since 4.0.4 for removal in 4.2.0 - */ -@SuppressWarnings("deprecation") -@AutoConfiguration(afterName = "org.springframework.boot.zipkin.autoconfigure.ZipkinAutoConfiguration") -@ConditionalOnClass({ ZipkinSpanExporter.class, Span.class }) -@Deprecated(since = "4.0.4", forRemoval = true) -public final class ZipkinWithOpenTelemetryTracingAutoConfiguration { - - @Bean - @ConditionalOnBean(Encoding.class) - @ConditionalOnMissingBean(value = Span.class, parameterizedContainer = BytesEncoder.class) - BytesEncoder spanBytesEncoder(Encoding encoding) { - return SpanBytesEncoder.forEncoding(encoding); - } - - @Bean - @ConditionalOnMissingBean - @ConditionalOnBean(BytesMessageSender.class) - @ConditionalOnEnabledTracingExport("zipkin") - ZipkinSpanExporter zipkinSpanExporter(BytesMessageSender sender, BytesEncoder spanBytesEncoder) { - return ZipkinSpanExporter.builder().setSender(sender).setEncoder(spanBytesEncoder).build(); - } - -} diff --git a/module/spring-boot-micrometer-tracing-opentelemetry/src/main/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/package-info.java b/module/spring-boot-micrometer-tracing-opentelemetry/src/main/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/package-info.java deleted file mode 100644 index 3b758c0e247..00000000000 --- a/module/spring-boot-micrometer-tracing-opentelemetry/src/main/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Auto-configuration for tracing with Zipkin. - */ -@NullMarked -package org.springframework.boot.micrometer.tracing.opentelemetry.autoconfigure.zipkin; - -import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-micrometer-tracing-opentelemetry/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/module/spring-boot-micrometer-tracing-opentelemetry/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 7eb042722d8..b7824e841fc 100644 --- a/module/spring-boot-micrometer-tracing-opentelemetry/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/module/spring-boot-micrometer-tracing-opentelemetry/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,3 +1,2 @@ org.springframework.boot.micrometer.tracing.opentelemetry.autoconfigure.OpenTelemetryTracingAutoConfiguration org.springframework.boot.micrometer.tracing.opentelemetry.autoconfigure.otlp.OtlpTracingAutoConfiguration -org.springframework.boot.micrometer.tracing.opentelemetry.autoconfigure.zipkin.ZipkinWithOpenTelemetryTracingAutoConfiguration diff --git a/module/spring-boot-micrometer-tracing-opentelemetry/src/test/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/DefaultEncodingConfiguration.java b/module/spring-boot-micrometer-tracing-opentelemetry/src/test/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/DefaultEncodingConfiguration.java deleted file mode 100644 index 55363dd1b51..00000000000 --- a/module/spring-boot-micrometer-tracing-opentelemetry/src/test/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/DefaultEncodingConfiguration.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.micrometer.tracing.opentelemetry.autoconfigure.zipkin; - -import zipkin2.reporter.Encoding; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.zipkin.autoconfigure.ZipkinAutoConfiguration; -import org.springframework.context.annotation.Bean; - -/** - * Configures the bean {@linkplain ZipkinAutoConfiguration} would from properties. - */ -@TestConfiguration(proxyBeanMethods = false) -class DefaultEncodingConfiguration { - - @Bean - @ConditionalOnMissingBean - Encoding zipkinReporterEncoding() { - return Encoding.JSON; - } - -} diff --git a/module/spring-boot-micrometer-tracing-opentelemetry/src/test/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/NoopSender.java b/module/spring-boot-micrometer-tracing-opentelemetry/src/test/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/NoopSender.java deleted file mode 100644 index 655f6282eba..00000000000 --- a/module/spring-boot-micrometer-tracing-opentelemetry/src/test/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/NoopSender.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.micrometer.tracing.opentelemetry.autoconfigure.zipkin; - -import java.io.IOException; -import java.util.List; - -import zipkin2.reporter.BytesMessageSender; -import zipkin2.reporter.Encoding; - -class NoopSender extends BytesMessageSender.Base { - - NoopSender(Encoding encoding) { - super(encoding); - } - - @Override - public int messageMaxBytes() { - return 1024; - } - - @Override - public void send(List encodedSpans) { - } - - @Override - public void close() throws IOException { - } - -} diff --git a/module/spring-boot-micrometer-tracing-opentelemetry/src/test/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/ZipkinWithOpenTelemetryTracingAutoConfigurationTests.java b/module/spring-boot-micrometer-tracing-opentelemetry/src/test/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/ZipkinWithOpenTelemetryTracingAutoConfigurationTests.java deleted file mode 100644 index e423baff4ed..00000000000 --- a/module/spring-boot-micrometer-tracing-opentelemetry/src/test/java/org/springframework/boot/micrometer/tracing/opentelemetry/autoconfigure/zipkin/ZipkinWithOpenTelemetryTracingAutoConfigurationTests.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.micrometer.tracing.opentelemetry.autoconfigure.zipkin; - -import io.opentelemetry.exporter.zipkin.ZipkinSpanExporter; -import io.opentelemetry.sdk.trace.export.SpanExporter; -import org.junit.jupiter.api.Test; -import zipkin2.Span; -import zipkin2.reporter.BytesEncoder; -import zipkin2.reporter.BytesMessageSender; -import zipkin2.reporter.Encoding; - -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.context.FilteredClassLoader; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.boot.zipkin.autoconfigure.ZipkinAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link ZipkinWithOpenTelemetryTracingAutoConfiguration}. - * - * @author Moritz Halbritter - */ -@SuppressWarnings({ "removal", "deprecation" }) -class ZipkinWithOpenTelemetryTracingAutoConfigurationTests { - - private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(ZipkinWithOpenTelemetryTracingAutoConfiguration.class, - DefaultEncodingConfiguration.class)); - - @Test - void shouldNotSupplyBeansIfInfrastructureIsNotAvailable() { - new ApplicationContextRunner().withUserConfiguration(ZipkinWithOpenTelemetryTracingAutoConfiguration.class) - .run((context) -> assertThat(context).doesNotHaveBean(BytesEncoder.class) - .doesNotHaveBean(SpanExporter.class) - .doesNotHaveBean(ZipkinSpanExporter.class)); - } - - @Test - void shouldSupplyBeansIfInfrastructureIsAvailable() { - this.contextRunner.withConfiguration(AutoConfigurations.of(ZipkinAutoConfiguration.class)).run((context) -> { - assertThat(context).hasSingleBean(SpanExporter.class); - assertThat(context).hasSingleBean(ZipkinSpanExporter.class); - }); - } - - @Test - void shouldNotSupplyBeansIfTracingIsDisabled() { - this.contextRunner.withPropertyValues("management.tracing.export.enabled=false") - .withConfiguration(AutoConfigurations.of(ZipkinAutoConfiguration.class)) - .run((context) -> { - assertThat(context).doesNotHaveBean(SpanExporter.class); - assertThat(context).doesNotHaveBean(ZipkinSpanExporter.class); - }); - } - - @Test - void backsOffWithoutEncoding() { - new ApplicationContextRunner().withUserConfiguration(ZipkinWithOpenTelemetryTracingAutoConfiguration.class) - .run((context) -> { - assertThat(context).hasNotFailed(); - assertThat(context).doesNotHaveBean(ZipkinSpanExporter.class); - assertThat(context).doesNotHaveBean(BytesEncoder.class); - }); - } - - @Test - void shouldSupplyBeans() { - this.contextRunner.withUserConfiguration(SenderConfiguration.class, CustomEncoderConfiguration.class) - .run((context) -> { - assertThat(context).hasSingleBean(ZipkinSpanExporter.class); - assertThat(context).hasBean("customSpanEncoder"); - }); - } - - @Test - void shouldNotSupplyZipkinSpanExporterIfSenderIsMissing() { - this.contextRunner.run((context) -> { - assertThat(context).doesNotHaveBean(ZipkinSpanExporter.class); - assertThat(context).hasBean("spanBytesEncoder"); - }); - } - - @Test - void shouldNotSupplyZipkinSpanExporterIfNotOnClasspath() { - this.contextRunner.withClassLoader(new FilteredClassLoader("io.opentelemetry.exporter.zipkin")) - .withUserConfiguration(SenderConfiguration.class) - .run((context) -> { - assertThat(context).doesNotHaveBean(ZipkinSpanExporter.class); - assertThat(context).doesNotHaveBean("spanBytesEncoder"); - }); - - } - - @Test - void shouldBackOffIfZipkinIsNotOnClasspath() { - this.contextRunner.withClassLoader(new FilteredClassLoader("zipkin2.Span")) - .withUserConfiguration(SenderConfiguration.class) - .run((context) -> { - assertThat(context).doesNotHaveBean(ZipkinSpanExporter.class); - assertThat(context).doesNotHaveBean("spanBytesEncoder"); - }); - } - - @Test - void shouldBackOffOnCustomBeans() { - this.contextRunner.withUserConfiguration(CustomConfiguration.class).run((context) -> { - assertThat(context).hasBean("customZipkinSpanExporter"); - assertThat(context).hasSingleBean(ZipkinSpanExporter.class); - }); - } - - @Test - void shouldNotSupplyZipkinSpanExporterIfGlobalTracingIsDisabled() { - this.contextRunner.withPropertyValues("management.tracing.export.enabled=false") - .withUserConfiguration(SenderConfiguration.class) - .run((context) -> assertThat(context).doesNotHaveBean(ZipkinSpanExporter.class)); - } - - @Test - void shouldNotSupplyZipkinSpanExporterIfZipkinTracingIsDisabled() { - this.contextRunner.withPropertyValues("management.tracing.export.zipkin.enabled=false") - .withUserConfiguration(SenderConfiguration.class) - .run((context) -> assertThat(context).doesNotHaveBean(ZipkinSpanExporter.class)); - } - - @Test - void shouldUseCustomEncoderBean() { - this.contextRunner.withUserConfiguration(SenderConfiguration.class, CustomEncoderConfiguration.class) - .run((context) -> { - assertThat(context).hasSingleBean(ZipkinSpanExporter.class); - assertThat(context).hasBean("customSpanEncoder"); - assertThat(context.getBean(ZipkinSpanExporter.class)).extracting("encoder") - .isInstanceOf(CustomSpanEncoder.class) - .extracting("encoding") - .isEqualTo(Encoding.JSON); - }); - } - - @Test - void shouldUseCustomEncodingBean() { - this.contextRunner - .withUserConfiguration(SenderConfiguration.class, CustomEncodingConfiguration.class, - CustomEncoderConfiguration.class) - .run((context) -> { - assertThat(context).hasSingleBean(ZipkinSpanExporter.class); - assertThat(context).hasBean("customSpanEncoder"); - assertThat(context.getBean(ZipkinSpanExporter.class)).extracting("encoder") - .isInstanceOf(CustomSpanEncoder.class) - .extracting("encoding") - .isEqualTo(Encoding.PROTO3); - }); - } - - @Configuration(proxyBeanMethods = false) - private static final class CustomEncodingConfiguration { - - @Bean - Encoding encoding() { - return Encoding.PROTO3; - } - - } - - @Configuration(proxyBeanMethods = false) - private static final class SenderConfiguration { - - @Bean - BytesMessageSender sender(Encoding encoding) { - return new NoopSender(encoding); - } - - } - - @Configuration(proxyBeanMethods = false) - private static final class CustomConfiguration { - - @Bean - ZipkinSpanExporter customZipkinSpanExporter() { - return ZipkinSpanExporter.builder().build(); - } - - } - - @Configuration(proxyBeanMethods = false) - private static final class CustomEncoderConfiguration { - - @Bean - BytesEncoder customSpanEncoder(Encoding encoding) { - return new CustomSpanEncoder(encoding); - } - - } - - record CustomSpanEncoder(Encoding encoding) implements BytesEncoder { - - @Override - public int sizeInBytes(Span span) { - throw new UnsupportedOperationException(); - } - - @Override - public byte[] encode(Span span) { - throw new UnsupportedOperationException(); - } - - } - -} diff --git a/module/spring-boot-mongodb/src/dockerTest/java/org/springframework/boot/mongodb/testcontainers/DeprecatedMongoDbContainerConnectionDetailsFactoryTests.java b/module/spring-boot-mongodb/src/dockerTest/java/org/springframework/boot/mongodb/testcontainers/DeprecatedMongoDbContainerConnectionDetailsFactoryTests.java deleted file mode 100644 index 3f2f433632d..00000000000 --- a/module/spring-boot-mongodb/src/dockerTest/java/org/springframework/boot/mongodb/testcontainers/DeprecatedMongoDbContainerConnectionDetailsFactoryTests.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.mongodb.testcontainers; - -import com.mongodb.client.MongoClient; -import com.mongodb.client.MongoClients; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.MongoDBContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.mongodb.autoconfigure.MongoConnectionDetails; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; -import org.springframework.boot.testsupport.container.TestImage; -import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Integration tests for {@link DeprecatedMongoDbContainerConnectionDetailsFactory}. - * - * @author Andy Wilkinson - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link MongoDbContainerConnectionDetailsFactory}. - */ -@SpringJUnitConfig -@Testcontainers(disabledWithoutDocker = true) -@Deprecated(since = "4.0.0", forRemoval = true) -class DeprecatedMongoDbContainerConnectionDetailsFactoryTests { - - @Container - @ServiceConnection - static final MongoDBContainer mongoDb = TestImage.container(MongoDBContainer.class); - - @Autowired(required = false) - private MongoConnectionDetails connectionDetails; - - @Test - void connectionCanBeMadeToContainer() { - assertThat(this.connectionDetails).isNotNull(); - MongoClient client = MongoClients.create(this.connectionDetails.getConnectionString()); - assertThat(client.listDatabaseNames()).containsExactly("admin", "config", "local"); - } - -} diff --git a/module/spring-boot-mongodb/src/main/java/org/springframework/boot/mongodb/testcontainers/DeprecatedMongoDbContainerConnectionDetailsFactory.java b/module/spring-boot-mongodb/src/main/java/org/springframework/boot/mongodb/testcontainers/DeprecatedMongoDbContainerConnectionDetailsFactory.java deleted file mode 100644 index 1f4084270e4..00000000000 --- a/module/spring-boot-mongodb/src/main/java/org/springframework/boot/mongodb/testcontainers/DeprecatedMongoDbContainerConnectionDetailsFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.mongodb.testcontainers; - -import org.testcontainers.containers.MongoDBContainer; - -import org.springframework.boot.mongodb.autoconfigure.MongoConnectionDetails; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; - -/** - * {@link ContainerConnectionDetailsFactory} to create {@link MongoConnectionDetails} from - * a {@link ServiceConnection @ServiceConnection}-annotated {@link MongoDBContainer}. - * - * @author Moritz Halbritter - * @author Andy Wilkinson - * @author Phillip Webb - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link MongoDbContainerConnectionDetailsFactory}. - */ -@Deprecated(since = "4.0.0", forRemoval = true) -class DeprecatedMongoDbContainerConnectionDetailsFactory - extends AbstractMongoContainerConnectionDetailsFactory { - - DeprecatedMongoDbContainerConnectionDetailsFactory() { - super(MongoDBContainer::getReplicaSetUrl); - } - -} diff --git a/module/spring-boot-mongodb/src/main/resources/META-INF/spring.factories b/module/spring-boot-mongodb/src/main/resources/META-INF/spring.factories index a772684516f..189e62c27c3 100644 --- a/module/spring-boot-mongodb/src/main/resources/META-INF/spring.factories +++ b/module/spring-boot-mongodb/src/main/resources/META-INF/spring.factories @@ -1,6 +1,5 @@ # Connection Details Factories org.springframework.boot.autoconfigure.service.connection.ConnectionDetailsFactory=\ org.springframework.boot.mongodb.docker.compose.MongoDockerComposeConnectionDetailsFactory,\ -org.springframework.boot.mongodb.testcontainers.DeprecatedMongoDbContainerConnectionDetailsFactory,\ org.springframework.boot.mongodb.testcontainers.MongoDbAtlasLocalContainerConnectionDetailsFactory,\ org.springframework.boot.mongodb.testcontainers.MongoDbContainerConnectionDetailsFactory diff --git a/module/spring-boot-neo4j/src/dockerTest/java/org/springframework/boot/neo4j/testcontainers/DeprecatedNeo4jContainerConnectionDetailsFactoryIntegrationTests.java b/module/spring-boot-neo4j/src/dockerTest/java/org/springframework/boot/neo4j/testcontainers/DeprecatedNeo4jContainerConnectionDetailsFactoryIntegrationTests.java deleted file mode 100644 index feeb6ad630d..00000000000 --- a/module/spring-boot-neo4j/src/dockerTest/java/org/springframework/boot/neo4j/testcontainers/DeprecatedNeo4jContainerConnectionDetailsFactoryIntegrationTests.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.neo4j.testcontainers; - -import org.junit.jupiter.api.Test; -import org.neo4j.driver.Driver; -import org.neo4j.driver.GraphDatabase; -import org.testcontainers.containers.Neo4jContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.neo4j.autoconfigure.Neo4jConnectionDetails; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; -import org.springframework.boot.testsupport.container.TestImage; -import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Integration tests for {@link DeprecatedNeo4jContainerConnectionDetailsFactory}. - * - * @author Stephane Nicoll - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link Neo4jContainerConnectionDetailsFactory}. - */ -@SpringJUnitConfig -@Testcontainers(disabledWithoutDocker = true) -@Deprecated(since = "4.0.0", forRemoval = true) -class DeprecatedNeo4jContainerConnectionDetailsFactoryIntegrationTests { - - @Container - @ServiceConnection - static final Neo4jContainer container = TestImage.container(Neo4jContainer.class); - - @Autowired(required = false) - private Neo4jConnectionDetails connectionDetails; - - @Test - void connectionCanBeMadeToContainer() { - assertThat(this.connectionDetails).isNotNull(); - try (Driver driver = GraphDatabase.driver(this.connectionDetails.getUri(), - this.connectionDetails.getAuthToken())) { - driver.verifyConnectivity(); - } - } - -} diff --git a/module/spring-boot-neo4j/src/main/java/org/springframework/boot/neo4j/testcontainers/DeprecatedNeo4jContainerConnectionDetailsFactory.java b/module/spring-boot-neo4j/src/main/java/org/springframework/boot/neo4j/testcontainers/DeprecatedNeo4jContainerConnectionDetailsFactory.java deleted file mode 100644 index d762b04fa7c..00000000000 --- a/module/spring-boot-neo4j/src/main/java/org/springframework/boot/neo4j/testcontainers/DeprecatedNeo4jContainerConnectionDetailsFactory.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.neo4j.testcontainers; - -import java.net.URI; - -import org.neo4j.driver.AuthToken; -import org.neo4j.driver.AuthTokens; -import org.testcontainers.containers.Neo4jContainer; - -import org.springframework.boot.neo4j.autoconfigure.Neo4jConnectionDetails; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionSource; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; - -/** - * {@link ContainerConnectionDetailsFactory} to create {@link Neo4jConnectionDetails} from - * a {@link ServiceConnection @ServiceConnection}-annotated {@link Neo4jContainer}. - * - * @author Moritz Halbritter - * @author Andy Wilkinson - * @author Phillip Webb - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link Neo4jContainerConnectionDetailsFactory}. - */ -@Deprecated(since = "4.0.0", forRemoval = true) -class DeprecatedNeo4jContainerConnectionDetailsFactory - extends ContainerConnectionDetailsFactory, Neo4jConnectionDetails> { - - DeprecatedNeo4jContainerConnectionDetailsFactory() { - super(ANY_CONNECTION_NAME, "org.neo4j.driver.AuthToken"); - } - - @Override - protected Neo4jConnectionDetails getContainerConnectionDetails( - ContainerConnectionSource> source) { - return new Neo4jContainerConnectionDetails(source); - } - - /** - * {@link Neo4jConnectionDetails} backed by a {@link ContainerConnectionSource}. - */ - private static final class Neo4jContainerConnectionDetails extends ContainerConnectionDetails> - implements Neo4jConnectionDetails { - - private Neo4jContainerConnectionDetails(ContainerConnectionSource> source) { - super(source); - } - - @Override - public URI getUri() { - return URI.create(getContainer().getBoltUrl()); - } - - @Override - public AuthToken getAuthToken() { - String password = getContainer().getAdminPassword(); - return (password != null) ? AuthTokens.basic("neo4j", password) : AuthTokens.none(); - } - - } - -} diff --git a/module/spring-boot-neo4j/src/main/resources/META-INF/spring.factories b/module/spring-boot-neo4j/src/main/resources/META-INF/spring.factories index 70daabc504b..98d3b5dfdbe 100644 --- a/module/spring-boot-neo4j/src/main/resources/META-INF/spring.factories +++ b/module/spring-boot-neo4j/src/main/resources/META-INF/spring.factories @@ -1,5 +1,4 @@ # Connection Details Factories org.springframework.boot.autoconfigure.service.connection.ConnectionDetailsFactory=\ org.springframework.boot.neo4j.docker.compose.Neo4jDockerComposeConnectionDetailsFactory,\ -org.springframework.boot.neo4j.testcontainers.DeprecatedNeo4jContainerConnectionDetailsFactory,\ org.springframework.boot.neo4j.testcontainers.Neo4jContainerConnectionDetailsFactory diff --git a/module/spring-boot-pulsar/src/dockerTest/java/org/springframework/boot/pulsar/testcontainers/DeprecatedPulsarContainerConnectionDetailsFactoryIntegrationTests.java b/module/spring-boot-pulsar/src/dockerTest/java/org/springframework/boot/pulsar/testcontainers/DeprecatedPulsarContainerConnectionDetailsFactoryIntegrationTests.java deleted file mode 100644 index ec1edb553b3..00000000000 --- a/module/spring-boot-pulsar/src/dockerTest/java/org/springframework/boot/pulsar/testcontainers/DeprecatedPulsarContainerConnectionDetailsFactoryIntegrationTests.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.pulsar.testcontainers; - -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; - -import org.awaitility.Awaitility; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.PulsarContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.pulsar.autoconfigure.PulsarAutoConfiguration; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; -import org.springframework.boot.testsupport.container.TestImage; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.pulsar.annotation.PulsarListener; -import org.springframework.pulsar.core.PulsarTemplate; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link DeprecatedPulsarContainerConnectionDetailsFactory}. - * - * @author Chris Bono - * @author Stephane Nicoll - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link PulsarContainerConnectionDetailsFactory}. - */ -@SpringJUnitConfig -@Testcontainers(disabledWithoutDocker = true) -@TestPropertySource(properties = { "spring.pulsar.consumer.subscription.initial-position=earliest" }) -@Deprecated(since = "4.0.0", forRemoval = true) -class DeprecatedPulsarContainerConnectionDetailsFactoryIntegrationTests { - - @Container - @ServiceConnection - @SuppressWarnings("unused") - static final PulsarContainer pulsar = TestImage.container(PulsarContainer.class); - - @Autowired - private PulsarTemplate pulsarTemplate; - - @Autowired - private TestListener listener; - - @Test - void connectionCanBeMadeToPulsarContainer() { - this.pulsarTemplate.send("test-topic", "test-data"); - Awaitility.waitAtMost(Duration.ofSeconds(30)) - .untilAsserted(() -> assertThat(this.listener.messages).containsExactly("test-data")); - } - - @Configuration(proxyBeanMethods = false) - @ImportAutoConfiguration(PulsarAutoConfiguration.class) - static class TestConfiguration { - - @Bean - TestListener testListener() { - return new TestListener(); - } - - } - - static class TestListener { - - private final List messages = new ArrayList<>(); - - @PulsarListener(topics = "test-topic") - void processMessage(String message) { - this.messages.add(message); - } - - } - -} diff --git a/module/spring-boot-pulsar/src/main/java/org/springframework/boot/pulsar/testcontainers/DeprecatedPulsarContainerConnectionDetailsFactory.java b/module/spring-boot-pulsar/src/main/java/org/springframework/boot/pulsar/testcontainers/DeprecatedPulsarContainerConnectionDetailsFactory.java deleted file mode 100644 index 46ba6a8a2e7..00000000000 --- a/module/spring-boot-pulsar/src/main/java/org/springframework/boot/pulsar/testcontainers/DeprecatedPulsarContainerConnectionDetailsFactory.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.pulsar.testcontainers; - -import org.testcontainers.containers.PulsarContainer; - -import org.springframework.boot.pulsar.autoconfigure.PulsarConnectionDetails; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionSource; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; - -/** - * {@link ContainerConnectionDetailsFactory} to create {@link PulsarConnectionDetails} - * from a {@link ServiceConnection @ServiceConnection}-annotated {@link PulsarContainer}. - * - * @author Chris Bono - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link PulsarContainerConnectionDetailsFactory}. - */ -@Deprecated(since = "4.0.0", forRemoval = true) -class DeprecatedPulsarContainerConnectionDetailsFactory - extends ContainerConnectionDetailsFactory { - - @Override - protected PulsarConnectionDetails getContainerConnectionDetails(ContainerConnectionSource source) { - return new PulsarContainerConnectionDetails(source); - } - - /** - * {@link PulsarConnectionDetails} backed by a {@link ContainerConnectionSource}. - */ - private static final class PulsarContainerConnectionDetails extends ContainerConnectionDetails - implements PulsarConnectionDetails { - - private PulsarContainerConnectionDetails(ContainerConnectionSource source) { - super(source); - } - - @Override - public String getBrokerUrl() { - return getContainer().getPulsarBrokerUrl(); - } - - @Override - public String getAdminUrl() { - return getContainer().getHttpServiceUrl(); - } - - } - -} diff --git a/module/spring-boot-pulsar/src/main/resources/META-INF/spring.factories b/module/spring-boot-pulsar/src/main/resources/META-INF/spring.factories index b04e3949dce..ceb868e08f0 100644 --- a/module/spring-boot-pulsar/src/main/resources/META-INF/spring.factories +++ b/module/spring-boot-pulsar/src/main/resources/META-INF/spring.factories @@ -1,5 +1,4 @@ # Connection Details Factories org.springframework.boot.autoconfigure.service.connection.ConnectionDetailsFactory=\ org.springframework.boot.pulsar.docker.compose.PulsarDockerComposeConnectionDetailsFactory,\ -org.springframework.boot.pulsar.testcontainers.DeprecatedPulsarContainerConnectionDetailsFactory,\ org.springframework.boot.pulsar.testcontainers.PulsarContainerConnectionDetailsFactory diff --git a/module/spring-boot-r2dbc/src/main/java/org/springframework/boot/r2dbc/testcontainers/DeprecatedMariaDbR2dbcContainerConnectionDetailsFactory.java b/module/spring-boot-r2dbc/src/main/java/org/springframework/boot/r2dbc/testcontainers/DeprecatedMariaDbR2dbcContainerConnectionDetailsFactory.java deleted file mode 100644 index f25f4f27347..00000000000 --- a/module/spring-boot-r2dbc/src/main/java/org/springframework/boot/r2dbc/testcontainers/DeprecatedMariaDbR2dbcContainerConnectionDetailsFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.r2dbc.testcontainers; - -import io.r2dbc.spi.ConnectionFactoryOptions; -import org.testcontainers.containers.MariaDBContainer; -import org.testcontainers.containers.MariaDBR2DBCDatabaseContainer; - -import org.springframework.boot.r2dbc.autoconfigure.R2dbcConnectionDetails; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionSource; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; - -/** - * {@link ContainerConnectionDetailsFactory} to create {@link R2dbcConnectionDetails} from - * a {@link ServiceConnection @ServiceConnection}-annotated {@link MariaDBContainer}. - * - * @author Moritz Halbritter - * @author Andy Wilkinson - * @author Phillip Webb - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link MariaDbR2dbcContainerConnectionDetailsFactory}. - */ -@Deprecated(since = "4.0.0", forRemoval = true) -class DeprecatedMariaDbR2dbcContainerConnectionDetailsFactory - extends ContainerConnectionDetailsFactory, R2dbcConnectionDetails> { - - DeprecatedMariaDbR2dbcContainerConnectionDetailsFactory() { - super(ANY_CONNECTION_NAME, "io.r2dbc.spi.ConnectionFactoryOptions"); - } - - @Override - public R2dbcConnectionDetails getContainerConnectionDetails(ContainerConnectionSource> source) { - return new MariaDbR2dbcDatabaseContainerConnectionDetails(source); - } - - /** - * {@link R2dbcConnectionDetails} backed by a {@link ContainerConnectionSource}. - */ - private static final class MariaDbR2dbcDatabaseContainerConnectionDetails - extends ContainerConnectionDetails> implements R2dbcConnectionDetails { - - private MariaDbR2dbcDatabaseContainerConnectionDetails(ContainerConnectionSource> source) { - super(source); - } - - @Override - public ConnectionFactoryOptions getConnectionFactoryOptions() { - return MariaDBR2DBCDatabaseContainer.getOptions(getContainer()); - } - - } - -} diff --git a/module/spring-boot-r2dbc/src/main/java/org/springframework/boot/r2dbc/testcontainers/DeprecatedMySqlR2dbcContainerConnectionDetailsFactory.java b/module/spring-boot-r2dbc/src/main/java/org/springframework/boot/r2dbc/testcontainers/DeprecatedMySqlR2dbcContainerConnectionDetailsFactory.java deleted file mode 100644 index f926b5bc6dc..00000000000 --- a/module/spring-boot-r2dbc/src/main/java/org/springframework/boot/r2dbc/testcontainers/DeprecatedMySqlR2dbcContainerConnectionDetailsFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.r2dbc.testcontainers; - -import io.r2dbc.spi.ConnectionFactoryOptions; -import org.testcontainers.containers.MySQLContainer; -import org.testcontainers.containers.MySQLR2DBCDatabaseContainer; - -import org.springframework.boot.r2dbc.autoconfigure.R2dbcConnectionDetails; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionSource; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; - -/** - * {@link ContainerConnectionDetailsFactory} to create {@link R2dbcConnectionDetails} from - * a {@link ServiceConnection @ServiceConnection}-annotated {@link MySQLContainer}. - * - * @author Moritz Halbritter - * @author Andy Wilkinson - * @author Phillip Webb - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link MySqlR2dbcContainerConnectionDetailsFactory}. - */ -@Deprecated(since = "4.0.0", forRemoval = true) -class DeprecatedMySqlR2dbcContainerConnectionDetailsFactory - extends ContainerConnectionDetailsFactory, R2dbcConnectionDetails> { - - DeprecatedMySqlR2dbcContainerConnectionDetailsFactory() { - super(ANY_CONNECTION_NAME, "io.r2dbc.spi.ConnectionFactoryOptions"); - } - - @Override - public R2dbcConnectionDetails getContainerConnectionDetails(ContainerConnectionSource> source) { - return new MySqlR2dbcDatabaseContainerConnectionDetails(source); - } - - /** - * {@link R2dbcConnectionDetails} backed by a {@link ContainerConnectionSource}. - */ - private static final class MySqlR2dbcDatabaseContainerConnectionDetails - extends ContainerConnectionDetails> implements R2dbcConnectionDetails { - - private MySqlR2dbcDatabaseContainerConnectionDetails(ContainerConnectionSource> source) { - super(source); - } - - @Override - public ConnectionFactoryOptions getConnectionFactoryOptions() { - return MySQLR2DBCDatabaseContainer.getOptions(getContainer()); - } - - } - -} diff --git a/module/spring-boot-r2dbc/src/main/java/org/springframework/boot/r2dbc/testcontainers/DeprecatedPostgresR2dbcContainerConnectionDetailsFactory.java b/module/spring-boot-r2dbc/src/main/java/org/springframework/boot/r2dbc/testcontainers/DeprecatedPostgresR2dbcContainerConnectionDetailsFactory.java deleted file mode 100644 index d8ee6ba41f4..00000000000 --- a/module/spring-boot-r2dbc/src/main/java/org/springframework/boot/r2dbc/testcontainers/DeprecatedPostgresR2dbcContainerConnectionDetailsFactory.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.r2dbc.testcontainers; - -import io.r2dbc.spi.ConnectionFactoryOptions; -import org.testcontainers.containers.PostgreSQLContainer; -import org.testcontainers.containers.PostgreSQLR2DBCDatabaseContainer; - -import org.springframework.boot.r2dbc.autoconfigure.R2dbcConnectionDetails; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionSource; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; - -/** - * {@link ContainerConnectionDetailsFactory} to create {@link R2dbcConnectionDetails} from - * a {@link ServiceConnection @ServiceConnection}-annotated {@link PostgreSQLContainer}. - * - * @author Moritz Halbritter - * @author Andy Wilkinson - * @author Phillip Webb - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link PostgresR2dbcContainerConnectionDetailsFactory}. - */ -@Deprecated(since = "4.0.0", forRemoval = true) -class DeprecatedPostgresR2dbcContainerConnectionDetailsFactory - extends ContainerConnectionDetailsFactory, R2dbcConnectionDetails> { - - DeprecatedPostgresR2dbcContainerConnectionDetailsFactory() { - super(ANY_CONNECTION_NAME, "io.r2dbc.spi.ConnectionFactoryOptions"); - } - - @Override - public R2dbcConnectionDetails getContainerConnectionDetails( - ContainerConnectionSource> source) { - return new PostgresR2dbcDatabaseContainerConnectionDetails(source); - } - - /** - * {@link R2dbcConnectionDetails} backed by a {@link ContainerConnectionSource}. - */ - private static final class PostgresR2dbcDatabaseContainerConnectionDetails - extends ContainerConnectionDetails> implements R2dbcConnectionDetails { - - PostgresR2dbcDatabaseContainerConnectionDetails(ContainerConnectionSource> source) { - super(source); - } - - @Override - public ConnectionFactoryOptions getConnectionFactoryOptions() { - return PostgreSQLR2DBCDatabaseContainer.getOptions(getContainer()); - } - - } - -} diff --git a/module/spring-boot-r2dbc/src/main/java/org/springframework/boot/r2dbc/testcontainers/DeprecatedSqlServerR2dbcContainerConnectionDetailsFactory.java b/module/spring-boot-r2dbc/src/main/java/org/springframework/boot/r2dbc/testcontainers/DeprecatedSqlServerR2dbcContainerConnectionDetailsFactory.java deleted file mode 100644 index b9efcc9457a..00000000000 --- a/module/spring-boot-r2dbc/src/main/java/org/springframework/boot/r2dbc/testcontainers/DeprecatedSqlServerR2dbcContainerConnectionDetailsFactory.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.r2dbc.testcontainers; - -import io.r2dbc.spi.ConnectionFactoryOptions; -import org.testcontainers.containers.MSSQLR2DBCDatabaseContainer; -import org.testcontainers.containers.MSSQLServerContainer; - -import org.springframework.boot.r2dbc.autoconfigure.R2dbcConnectionDetails; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionSource; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; - -/** - * {@link ContainerConnectionDetailsFactory} to create {@link R2dbcConnectionDetails} from - * a {@link ServiceConnection @ServiceConnection}-annotated {@link MSSQLServerContainer}. - * - * @author Moritz Halbritter - * @author Andy Wilkinson - * @author Phillip Webb - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link SqlServerR2dbcContainerConnectionDetailsFactory}. - */ -@Deprecated(since = "4.0.0", forRemoval = true) -class DeprecatedSqlServerR2dbcContainerConnectionDetailsFactory - extends ContainerConnectionDetailsFactory, R2dbcConnectionDetails> { - - DeprecatedSqlServerR2dbcContainerConnectionDetailsFactory() { - super(ANY_CONNECTION_NAME, "io.r2dbc.spi.ConnectionFactoryOptions"); - } - - @Override - public R2dbcConnectionDetails getContainerConnectionDetails( - ContainerConnectionSource> source) { - return new MsSqlServerR2dbcDatabaseContainerConnectionDetails(source); - } - - /** - * {@link R2dbcConnectionDetails} backed by a {@link ContainerConnectionSource}. - */ - private static final class MsSqlServerR2dbcDatabaseContainerConnectionDetails - extends ContainerConnectionDetails> implements R2dbcConnectionDetails { - - private MsSqlServerR2dbcDatabaseContainerConnectionDetails( - ContainerConnectionSource> source) { - super(source); - } - - @Override - public ConnectionFactoryOptions getConnectionFactoryOptions() { - return MSSQLR2DBCDatabaseContainer.getOptions(getContainer()); - } - - } - -} diff --git a/module/spring-boot-r2dbc/src/main/resources/META-INF/spring.factories b/module/spring-boot-r2dbc/src/main/resources/META-INF/spring.factories index b71026ca9c7..92eacd6c66f 100644 --- a/module/spring-boot-r2dbc/src/main/resources/META-INF/spring.factories +++ b/module/spring-boot-r2dbc/src/main/resources/META-INF/spring.factories @@ -8,10 +8,6 @@ org.springframework.boot.r2dbc.docker.compose.OracleXeR2dbcDockerComposeConnecti org.springframework.boot.r2dbc.docker.compose.PostgresR2dbcDockerComposeConnectionDetailsFactory,\ org.springframework.boot.r2dbc.docker.compose.SqlServerR2dbcDockerComposeConnectionDetailsFactory,\ org.springframework.boot.r2dbc.testcontainers.ClickHouseR2dbcContainerConnectionDetailsFactory,\ -org.springframework.boot.r2dbc.testcontainers.DeprecatedMariaDbR2dbcContainerConnectionDetailsFactory,\ -org.springframework.boot.r2dbc.testcontainers.DeprecatedMySqlR2dbcContainerConnectionDetailsFactory,\ -org.springframework.boot.r2dbc.testcontainers.DeprecatedPostgresR2dbcContainerConnectionDetailsFactory,\ -org.springframework.boot.r2dbc.testcontainers.DeprecatedSqlServerR2dbcContainerConnectionDetailsFactory,\ org.springframework.boot.r2dbc.testcontainers.MariaDbR2dbcContainerConnectionDetailsFactory,\ org.springframework.boot.r2dbc.testcontainers.MySqlR2dbcContainerConnectionDetailsFactory,\ org.springframework.boot.r2dbc.testcontainers.OracleFreeR2dbcContainerConnectionDetailsFactory,\ diff --git a/module/spring-boot-rabbitmq/src/dockerTest/java/org/springframework/boot/rabbitmq/testcontainers/DeprecatedRabbitContainerConnectionDetailsFactoryIntegrationTests.java b/module/spring-boot-rabbitmq/src/dockerTest/java/org/springframework/boot/rabbitmq/testcontainers/DeprecatedRabbitContainerConnectionDetailsFactoryIntegrationTests.java deleted file mode 100644 index 61b0a43c531..00000000000 --- a/module/spring-boot-rabbitmq/src/dockerTest/java/org/springframework/boot/rabbitmq/testcontainers/DeprecatedRabbitContainerConnectionDetailsFactoryIntegrationTests.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.rabbitmq.testcontainers; - -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; - -import org.awaitility.Awaitility; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.RabbitMQContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; - -import org.springframework.amqp.rabbit.annotation.Queue; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.rabbitmq.autoconfigure.RabbitAutoConfiguration; -import org.springframework.boot.rabbitmq.autoconfigure.RabbitConnectionDetails; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; -import org.springframework.boot.testsupport.container.TestImage; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link DeprecatedRabbitContainerConnectionDetailsFactory}. - * - * @author Moritz Halbritter - * @author Andy Wilkinson - * @author Phillip Webb - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link RabbitMqContainerConnectionDetailsFactoryIntegrationTests}. - */ -@SpringJUnitConfig -@Testcontainers(disabledWithoutDocker = true) -@Deprecated(since = "4.0.0", forRemoval = true) -class DeprecatedRabbitContainerConnectionDetailsFactoryIntegrationTests { - - @Container - @ServiceConnection - static final RabbitMQContainer rabbit = TestImage.container(RabbitMQContainer.class); - - @Autowired(required = false) - private RabbitConnectionDetails connectionDetails; - - @Autowired - private RabbitTemplate rabbitTemplate; - - @Autowired - private TestListener listener; - - @Test - void connectionCanBeMadeToRabbitContainer() { - assertThat(this.connectionDetails).isNotNull(); - this.rabbitTemplate.convertAndSend("test", "message"); - Awaitility.waitAtMost(Duration.ofMinutes(4)) - .untilAsserted(() -> assertThat(this.listener.messages).containsExactly("message")); - - } - - @Configuration(proxyBeanMethods = false) - @ImportAutoConfiguration(RabbitAutoConfiguration.class) - static class TestConfiguration { - - @Bean - TestListener testListener() { - return new TestListener(); - } - - } - - static class TestListener { - - private final List messages = new ArrayList<>(); - - @RabbitListener(queuesToDeclare = @Queue("test")) - void processMessage(String message) { - this.messages.add(message); - } - - } - -} diff --git a/module/spring-boot-rabbitmq/src/main/java/org/springframework/boot/rabbitmq/testcontainers/DeprecatedRabbitContainerConnectionDetailsFactory.java b/module/spring-boot-rabbitmq/src/main/java/org/springframework/boot/rabbitmq/testcontainers/DeprecatedRabbitContainerConnectionDetailsFactory.java deleted file mode 100644 index 750d611deb6..00000000000 --- a/module/spring-boot-rabbitmq/src/main/java/org/springframework/boot/rabbitmq/testcontainers/DeprecatedRabbitContainerConnectionDetailsFactory.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.rabbitmq.testcontainers; - -import java.net.URI; -import java.util.List; - -import org.jspecify.annotations.Nullable; -import org.testcontainers.containers.RabbitMQContainer; - -import org.springframework.boot.rabbitmq.autoconfigure.RabbitConnectionDetails; -import org.springframework.boot.ssl.SslBundle; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory; -import org.springframework.boot.testcontainers.service.connection.ContainerConnectionSource; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; - -/** - * {@link ContainerConnectionDetailsFactory} to create {@link RabbitConnectionDetails} - * from a {@link ServiceConnection @ServiceConnection}-annotated - * {@link RabbitMQContainer}. - * - * @author Moritz Halbritter - * @author Andy Wilkinson - * @author Phillip Webb - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link RabbitMqContainerConnectionDetailsFactory}. - */ -@Deprecated(since = "4.0.0", forRemoval = true) -class DeprecatedRabbitContainerConnectionDetailsFactory - extends ContainerConnectionDetailsFactory { - - @Override - protected RabbitConnectionDetails getContainerConnectionDetails( - ContainerConnectionSource source) { - return new RabbitMqContainerConnectionDetails(source); - } - - /** - * {@link RabbitConnectionDetails} backed by a {@link ContainerConnectionSource}. - */ - private static final class RabbitMqContainerConnectionDetails extends ContainerConnectionDetails - implements RabbitConnectionDetails { - - private RabbitMqContainerConnectionDetails(ContainerConnectionSource source) { - super(source); - } - - @Override - public String getUsername() { - return getContainer().getAdminUsername(); - } - - @Override - public String getPassword() { - return getContainer().getAdminPassword(); - } - - @Override - public List
getAddresses() { - URI uri = URI.create((getSslBundle() != null) ? getContainer().getAmqpsUrl() : getContainer().getAmqpUrl()); - return List.of(new Address(uri.getHost(), uri.getPort())); - } - - @Override - public @Nullable SslBundle getSslBundle() { - return super.getSslBundle(); - } - - } - -} diff --git a/module/spring-boot-rabbitmq/src/main/resources/META-INF/spring.factories b/module/spring-boot-rabbitmq/src/main/resources/META-INF/spring.factories index a7a1d458e73..8ed1fd222c4 100644 --- a/module/spring-boot-rabbitmq/src/main/resources/META-INF/spring.factories +++ b/module/spring-boot-rabbitmq/src/main/resources/META-INF/spring.factories @@ -2,7 +2,6 @@ org.springframework.boot.autoconfigure.service.connection.ConnectionDetailsFactory=\ org.springframework.boot.rabbitmq.docker.compose.RabbitMqDockerComposeConnectionDetailsFactory,\ org.springframework.boot.rabbitmq.docker.compose.RabbitMqStreamDockerComposeConnectionDetailsFactory,\ -org.springframework.boot.rabbitmq.testcontainers.DeprecatedRabbitContainerConnectionDetailsFactory,\ org.springframework.boot.rabbitmq.testcontainers.RabbitMqContainerConnectionDetailsFactory,\ org.springframework.boot.rabbitmq.testcontainers.RabbitMqStreamContainerConnectionDetailsFactory diff --git a/module/spring-boot-session/src/main/java/org/springframework/boot/session/autoconfigure/SessionProperties.java b/module/spring-boot-session/src/main/java/org/springframework/boot/session/autoconfigure/SessionProperties.java index 30216c894ab..c4d6784e504 100644 --- a/module/spring-boot-session/src/main/java/org/springframework/boot/session/autoconfigure/SessionProperties.java +++ b/module/spring-boot-session/src/main/java/org/springframework/boot/session/autoconfigure/SessionProperties.java @@ -21,7 +21,6 @@ import java.time.temporal.ChronoUnit; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.Set; -import java.util.function.Supplier; import org.jspecify.annotations.Nullable; @@ -65,18 +64,6 @@ public class SessionProperties { this.servlet = servlet; } - /** - * Determine the session timeout. If no timeout is configured, the - * {@code fallbackTimeout} is used. - * @param fallbackTimeout a fallback timeout value if the timeout isn't configured - * @return the session timeout - * @deprecated since 4.0.1 for removal in 4.2.0 in favor of {@link SessionTimeout} - */ - @Deprecated(since = "4.0.1", forRemoval = true) - public Duration determineTimeout(Supplier fallbackTimeout) { - return (this.timeout != null) ? this.timeout : fallbackTimeout.get(); - } - /** * Servlet-related properties. */ diff --git a/module/spring-boot-session/src/test/java/org/springframework/boot/session/autoconfigure/SessionPropertiesTests.java b/module/spring-boot-session/src/test/java/org/springframework/boot/session/autoconfigure/SessionPropertiesTests.java index 797381e58b0..d9ebd9076b5 100644 --- a/module/spring-boot-session/src/test/java/org/springframework/boot/session/autoconfigure/SessionPropertiesTests.java +++ b/module/spring-boot-session/src/test/java/org/springframework/boot/session/autoconfigure/SessionPropertiesTests.java @@ -16,17 +16,12 @@ package org.springframework.boot.session.autoconfigure; -import java.time.Duration; -import java.util.function.Supplier; - import org.junit.jupiter.api.Test; import org.springframework.core.Ordered; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; -import static org.mockito.BDDMockito.then; -import static org.mockito.Mockito.mock; /** * Tests for {@link SessionProperties}. @@ -37,25 +32,6 @@ class SessionPropertiesTests { private final SessionProperties properties = new SessionProperties(); - @Test - @SuppressWarnings({ "unchecked", "removal" }) - @Deprecated(since = "4.0.1", forRemoval = true) - void determineTimeoutWithTimeoutIgnoreFallback() { - this.properties.setTimeout(Duration.ofMinutes(1)); - Supplier fallback = mock(Supplier.class); - assertThat(this.properties.determineTimeout(fallback)).isEqualTo(Duration.ofMinutes(1)); - then(fallback).shouldHaveNoInteractions(); - } - - @Test - @SuppressWarnings("removal") - @Deprecated(since = "4.0.1", forRemoval = true) - void determineTimeoutWithNoTimeoutUseFallback() { - this.properties.setTimeout(null); - Duration fallback = Duration.ofMinutes(2); - assertThat(this.properties.determineTimeout(() -> fallback)).isSameAs(fallback); - } - @Test void defaultFilterOrderIsCloseToHighestPrecedence() { assertThat(this.properties.getServlet().getFilterOrder()).isCloseTo(Ordered.HIGHEST_PRECEDENCE, within(50)); diff --git a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java index 281b124124a..fbcb80ae259 100644 --- a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java +++ b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java @@ -84,7 +84,6 @@ import org.springframework.http.CacheControl; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverters.ServerBuilder; import org.springframework.lang.Contract; -import org.springframework.util.AntPathMatcher; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.CollectionUtils; @@ -116,7 +115,6 @@ import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer; import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; import org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.ResourceChainRegistration; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistration; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; @@ -137,7 +135,6 @@ import org.springframework.web.servlet.resource.VersionResourceResolver; import org.springframework.web.servlet.view.BeanNameViewResolver; import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.util.UrlPathHelper; /** * {@link EnableAutoConfiguration Auto-configuration} for {@link EnableWebMvc Web MVC}. @@ -268,30 +265,6 @@ public final class WebMvcAutoConfiguration { } } - @Override - @SuppressWarnings("removal") - public void configurePathMatch(PathMatchConfigurer configurer) { - if (this.mvcProperties.getPathmatch() - .getMatchingStrategy() == WebMvcProperties.MatchingStrategy.ANT_PATH_MATCHER) { - configurer.setPathMatcher(new AntPathMatcher()); - this.dispatcherServletPath.ifAvailable((dispatcherPath) -> { - String servletUrlMapping = dispatcherPath.getServletUrlMapping(); - if (servletUrlMapping.equals("/") && singleDispatcherServlet()) { - UrlPathHelper urlPathHelper = new UrlPathHelper(); - urlPathHelper.setAlwaysUseFullPath(true); - configurer.setUrlPathHelper(urlPathHelper); - } - }); - } - } - - private boolean singleDispatcherServlet() { - return this.servletRegistrations.stream() - .map(ServletRegistrationBean::getServlet) - .filter(DispatcherServlet.class::isInstance) - .count() == 1; - } - @Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { WebMvcProperties.Contentnegotiation contentnegotiation = this.mvcProperties.getContentnegotiation(); diff --git a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcProperties.java b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcProperties.java index a95ff9b2231..aa7486556b0 100644 --- a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcProperties.java +++ b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/WebMvcProperties.java @@ -25,6 +25,7 @@ import java.util.Map; import org.jspecify.annotations.Nullable; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.boot.context.properties.bind.Name; import org.springframework.http.MediaType; import org.springframework.util.Assert; @@ -96,6 +97,7 @@ public class WebMvcProperties { private final Contentnegotiation contentnegotiation = new Contentnegotiation(); + @Deprecated(since = "4.2.0", forRemoval = true) private final Pathmatch pathmatch = new Pathmatch(); private final Problemdetails problemdetails = new Problemdetails(); @@ -186,6 +188,7 @@ public class WebMvcProperties { return this.contentnegotiation; } + @Deprecated(since = "4.2.0", forRemoval = true) public Pathmatch getPathmatch() { return this.pathmatch; } @@ -368,6 +371,7 @@ public class WebMvcProperties { } + @Deprecated(since = "4.2.0", forRemoval = true) public static class Pathmatch { /** @@ -375,6 +379,7 @@ public class WebMvcProperties { */ private MatchingStrategy matchingStrategy = MatchingStrategy.PATH_PATTERN_PARSER; + @DeprecatedConfigurationProperty(reason = "Path matching is no longer configurable", since = "4.2.0") public MatchingStrategy getMatchingStrategy() { return this.matchingStrategy; } @@ -436,14 +441,6 @@ public class WebMvcProperties { */ public enum MatchingStrategy { - /** - * Use the {@code AntPathMatcher} implementation. - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of - * {@link #PATH_PATTERN_PARSER} - */ - @Deprecated(since = "4.0.0", forRemoval = true) - ANT_PATH_MATCHER, - /** * Use the {@code PathPatternParser} implementation. */ diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java index 2629ccbd010..4d9661126a1 100644 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WebMvcAutoConfigurationTests.java @@ -947,25 +947,6 @@ class WebMvcAutoConfigurationTests { }); } - @Test - void urlPathHelperUsesFullPathByDefaultWhenAntPathMatchingIsUsed() { - this.contextRunner.withPropertyValues("spring.mvc.pathmatch.matching-strategy:ant-path-matcher") - .run((context) -> { - UrlPathHelper urlPathHelper = context.getBean(UrlPathHelper.class); - assertThat(urlPathHelper).extracting("alwaysUseFullPath").isEqualTo(true); - }); - } - - @Test - void urlPathHelperDoesNotUseFullPathWithServletMapping() { - this.contextRunner.withPropertyValues("spring.mvc.pathmatch.matching-strategy:ant-path-matcher") - .withPropertyValues("spring.mvc.servlet.path=/test/") - .run((context) -> { - UrlPathHelper urlPathHelper = context.getBean(UrlPathHelper.class); - assertThat(urlPathHelper).extracting("alwaysUseFullPath").isEqualTo(false); - }); - } - @Test void urlPathHelperDoesNotUseFullPathWithAdditionalDispatcherServlet() { this.contextRunner.withUserConfiguration(AdditionalDispatcherServletConfiguration.class).run((context) -> { diff --git a/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/TestImage.java b/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/TestImage.java index a47e4aefde2..ef81e9bb520 100644 --- a/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/TestImage.java +++ b/test-support/spring-boot-docker-test-support/src/main/java/org/springframework/boot/testsupport/container/TestImage.java @@ -174,17 +174,6 @@ public enum TestImage { (container) -> ((MongoDBContainer) container).withStartupAttempts(5) .withStartupTimeout(Duration.ofMinutes(5))), - /** - * A container image suitable for testing MongoDB using the deprecated - * {@link org.testcontainers.containers.MongoDBContainer}. - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of {@link #MONGODB} - */ - @SuppressWarnings("deprecation") - @Deprecated(since = "3.4.0", forRemoval = true) - MONGODB_DEPRECATED("mongo", "5.0.17", () -> org.testcontainers.containers.MongoDBContainer.class, - (container) -> ((org.testcontainers.containers.MongoDBContainer) container).withStartupAttempts(5) - .withStartupTimeout(Duration.ofMinutes(5))), - /** * A container image suitable for testing MongoDB Atlas. */ @@ -204,17 +193,6 @@ public enum TestImage { (container) -> ((Neo4jContainer) container).withStartupAttempts(5) .withStartupTimeout(Duration.ofMinutes(10))), - /** - * A container image suitable for testing Neo4j using the deprecated - * {@link org.testcontainers.containers.Neo4jContainer}. - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of {@link #NEO4J} - */ - @SuppressWarnings({ "deprecation", "rawtypes" }) - @Deprecated(since = "3.4.0", forRemoval = true) - NEO4J_DEPRECATED("neo4j", "5.26.11", () -> org.testcontainers.containers.Neo4jContainer.class, - (container) -> ((org.testcontainers.containers.Neo4jContainer) container).withStartupAttempts(5) - .withStartupTimeout(Duration.ofMinutes(10))), - /** * A container image suitable for testing Oracle Free. */ @@ -248,17 +226,6 @@ public enum TestImage { .withStartupTimeout(Duration.ofMinutes(3)) .withEnv("PULSAR_PREFIX_advertisedAddress", "localhost")), - /** - * A container image suitable for testing Pulsar using the deprecated - * {@link org.testcontainers.containers.PulsarContainer}. - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of {@link #PULSAR} - */ - @SuppressWarnings("deprecation") - @Deprecated(since = "3.4.0", forRemoval = true) - PULSAR_DEPRECATED("apachepulsar/pulsar", "3.3.3", () -> org.testcontainers.containers.PulsarContainer.class, - (container) -> ((org.testcontainers.containers.PulsarContainer) container).withStartupAttempts(2) - .withStartupTimeout(Duration.ofMinutes(3))), - /** * A container image suitable for testing RabbitMQ with support for both AMQP 0.9 and * 1.0. Queues can be declared using {@code rabbitmqadmin}. @@ -266,17 +233,6 @@ public enum TestImage { RABBITMQ("rabbitmq", "4.2-management", () -> RabbitMQContainer.class, (container) -> ((RabbitMQContainer) container).withStartupTimeout(Duration.ofMinutes(4))), - /** - * A container image suitable for testing RabbitMQ using the deprecated - * {@link org.testcontainers.containers.RabbitMQContainer}. - * @deprecated since 4.0.0 for removal in 4.2.0 in favor of {@link #RABBITMQ} - */ - @SuppressWarnings("deprecation") - @Deprecated(since = "3.4.0", forRemoval = true) - RABBITMQ_DEPRECATED("rabbitmq", "3.11-alpine", () -> org.testcontainers.containers.RabbitMQContainer.class, - (container) -> ((org.testcontainers.containers.RabbitMQContainer) container) - .withStartupTimeout(Duration.ofMinutes(4))), - /** * A container image suitable for testing Redis. */