diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/InvocationContext.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/InvocationContext.java index dc90f501105..3686d592de4 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/InvocationContext.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/InvocationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-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. @@ -38,33 +38,6 @@ public class InvocationContext { private final List argumentResolvers; - /** - * Creates a new context for an operation being invoked by the given - * {@code securityContext} with the given available {@code arguments}. - * @param securityContext the current security context. Never {@code null} - * @param arguments the arguments available to the operation. Never {@code null} - */ - public InvocationContext(SecurityContext securityContext, Map arguments) { - this(null, securityContext, arguments); - } - - /** - * Creates a new context for an operation being invoked by the given - * {@code securityContext} with the given available {@code arguments}. - * @param apiVersion the API version or {@code null} to use the latest - * @param securityContext the current security context. Never {@code null} - * @param arguments the arguments available to the operation. Never {@code null} - * @since 2.2.0 - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link #InvocationContext(SecurityContext, Map, OperationArgumentResolver[])} - */ - @Deprecated - public InvocationContext(org.springframework.boot.actuate.endpoint.http.ApiVersion apiVersion, - SecurityContext securityContext, Map arguments) { - this(securityContext, arguments, OperationArgumentResolver.of(ApiVersion.class, - () -> (apiVersion != null) ? ApiVersion.valueOf(apiVersion.name()) : null)); - } - /** * Creates a new context for an operation being invoked by the given * {@code securityContext} with the given available {@code arguments}. @@ -87,32 +60,6 @@ public class InvocationContext { this.argumentResolvers.add(OperationArgumentResolver.of(ApiVersion.class, () -> ApiVersion.LATEST)); } - /** - * Return the API version in use. - * @return the apiVersion the API version - * @since 2.2.0 - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link #resolveArgument(Class)} using - * {@link org.springframework.boot.actuate.endpoint.ApiVersion} - */ - @Deprecated - public org.springframework.boot.actuate.endpoint.http.ApiVersion getApiVersion() { - ApiVersion version = resolveArgument(ApiVersion.class); - return (version != null) ? org.springframework.boot.actuate.endpoint.http.ApiVersion.valueOf(version.name()) - : org.springframework.boot.actuate.endpoint.http.ApiVersion.LATEST; - } - - /** - * Return the security context to use for the invocation. - * @return the security context - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link #resolveArgument(Class)} - */ - @Deprecated - public SecurityContext getSecurityContext() { - return resolveArgument(SecurityContext.class); - } - /** * Return the invocation arguments. * @return the arguments diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ActuatorMediaType.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ActuatorMediaType.java deleted file mode 100644 index e31892f2a28..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ActuatorMediaType.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.actuate.endpoint.http; - -/** - * Media types that can be consumed and produced by Actuator endpoints. - * - * @author Andy Wilkinson - * @author Madhura Bhave - * @since 2.0.0 - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link org.springframework.boot.actuate.endpoint.ApiVersion#getProducedMimeType()} - */ -@Deprecated -public final class ActuatorMediaType { - - /** - * Constant for the Actuator {@link ApiVersion#V2 v2} media type. - */ - public static final String V2_JSON = "application/vnd.spring-boot.actuator.v2+json"; - - /** - * Constant for the Actuator {@link ApiVersion#V3 v3} media type. - */ - public static final String V3_JSON = "application/vnd.spring-boot.actuator.v3+json"; - - private ActuatorMediaType() { - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ApiVersion.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ApiVersion.java deleted file mode 100644 index 2b4a4d36083..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/ApiVersion.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.actuate.endpoint.http; - -import java.util.List; -import java.util.Map; - -import org.springframework.boot.actuate.endpoint.ProducibleOperationArgumentResolver; -import org.springframework.util.CollectionUtils; -import org.springframework.util.MimeTypeUtils; - -/** - * API versions supported for the actuator HTTP API. This enum may be injected into - * actuator endpoints in order to return a response compatible with the requested version. - * - * @author Phillip Webb - * @since 2.2.0 - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link org.springframework.boot.actuate.endpoint.ApiVersion} - */ -@Deprecated -public enum ApiVersion { - - /** - * Version 2 (supported by Spring Boot 2.0+). - */ - V2, - - /** - * Version 3 (supported by Spring Boot 2.2+). - */ - V3; - - private static final String MEDIA_TYPE_PREFIX = "application/vnd.spring-boot.actuator."; - - /** - * The latest API version. - */ - public static final ApiVersion LATEST = ApiVersion.V3; - - /** - * Return the {@link ApiVersion} to use based on the HTTP request headers. The version - * will be deduced based on the {@code Accept} header. - * @param headers the HTTP headers - * @return the API version to use - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of direct injection with - * resolution via the {@link ProducibleOperationArgumentResolver}. - */ - @Deprecated - public static ApiVersion fromHttpHeaders(Map> headers) { - ApiVersion version = null; - List accepts = headers.get("Accept"); - if (!CollectionUtils.isEmpty(accepts)) { - for (String accept : accepts) { - for (String type : MimeTypeUtils.tokenize(accept)) { - version = mostRecent(version, forType(type)); - } - } - } - return (version != null) ? version : LATEST; - } - - private static ApiVersion forType(String type) { - if (type.startsWith(MEDIA_TYPE_PREFIX)) { - type = type.substring(MEDIA_TYPE_PREFIX.length()); - int suffixIndex = type.indexOf('+'); - type = (suffixIndex != -1) ? type.substring(0, suffixIndex) : type; - try { - return valueOf(type.toUpperCase()); - } - catch (IllegalArgumentException ex) { - } - } - return null; - } - - private static ApiVersion mostRecent(ApiVersion existing, ApiVersion candidate) { - int existingOrdinal = (existing != null) ? existing.ordinal() : -1; - int candidateOrdinal = (candidate != null) ? candidate.ordinal() : -1; - return (candidateOrdinal > existingOrdinal) ? candidate : existing; - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/package-info.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/package-info.java deleted file mode 100644 index c6e8536a650..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/http/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2012-2019 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. - */ - -/** - * Actuator endpoint HTTP concerns (not tied to any specific implementation). - */ -package org.springframework.boot.actuate.endpoint.http; diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/data/MetricsRepositoryMethodInvocationListener.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/data/MetricsRepositoryMethodInvocationListener.java index add03dc6917..c269a05d358 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/data/MetricsRepositoryMethodInvocationListener.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/data/MetricsRepositoryMethodInvocationListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-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. @@ -46,21 +46,6 @@ public class MetricsRepositoryMethodInvocationListener implements RepositoryMeth private final AutoTimer autoTimer; - /** - * Create a new {@code MetricsRepositoryMethodInvocationListener}. - * @param registry the registry to which metrics are recorded - * @param tagsProvider provider for metrics tags - * @param metricName name of the metric to record - * @param autoTimer the auto-timers to apply or {@code null} to disable auto-timing - * @deprecated since 2.5.4 for removal in 2.7.0 in favor of - * {@link #MetricsRepositoryMethodInvocationListener(Supplier, RepositoryTagsProvider, String, AutoTimer)} - */ - @Deprecated - public MetricsRepositoryMethodInvocationListener(MeterRegistry registry, RepositoryTagsProvider tagsProvider, - String metricName, AutoTimer autoTimer) { - this(SingletonSupplier.of(registry), tagsProvider, metricName, autoTimer); - } - /** * Create a new {@code MetricsRepositoryMethodInvocationListener}. * @param registrySupplier a supplier for the registry to which metrics are recorded diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java index 7ae68adcab4..622877ca533 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-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. @@ -166,20 +166,6 @@ public final class WebFluxTags { return EXCEPTION_NONE; } - /** - * Creates an {@code outcome} tag based on the response status of the given - * {@code exchange}. - * @param exchange the exchange - * @return the outcome tag derived from the response status - * @since 2.1.0 - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link #outcome(ServerWebExchange, Throwable)} - */ - @Deprecated - public static Tag outcome(ServerWebExchange exchange) { - return outcome(exchange, null); - } - /** * Creates an {@code outcome} tag based on the response status of the given * {@code exchange} and the exception thrown during request processing. diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/InvocationContextTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/InvocationContextTests.java index 1a265cd77fd..e4465feb489 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/InvocationContextTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/InvocationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-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. @@ -36,20 +36,6 @@ class InvocationContextTests { private final Map arguments = Collections.singletonMap("test", "value"); - @Test - @SuppressWarnings("deprecation") - void createWhenApiVersionIsNullUsesLatestVersion() { - InvocationContext context = new InvocationContext(null, this.securityContext, this.arguments); - assertThat(context.getApiVersion()).isEqualTo(org.springframework.boot.actuate.endpoint.http.ApiVersion.LATEST); - } - - @Test - @Deprecated - void whenCreatedWithoutApiVersionThenGetApiVersionReturnsLatestVersion() { - InvocationContext context = new InvocationContext(this.securityContext, this.arguments); - assertThat(context.getApiVersion()).isEqualTo(org.springframework.boot.actuate.endpoint.http.ApiVersion.LATEST); - } - @Test void whenCreatedWithoutApiVersionThenResolveApiVersionReturnsLatestVersion() { InvocationContext context = new InvocationContext(this.securityContext, this.arguments); @@ -68,21 +54,6 @@ class InvocationContextTests { .withMessage("Arguments must not be null"); } - @Test - @SuppressWarnings("deprecation") - void getApiVersionReturnsApiVersion() { - InvocationContext context = new InvocationContext(org.springframework.boot.actuate.endpoint.http.ApiVersion.V2, - this.securityContext, this.arguments); - assertThat(context.getApiVersion()).isEqualTo(org.springframework.boot.actuate.endpoint.http.ApiVersion.V2); - } - - @Test - @SuppressWarnings("deprecation") - void getSecurityContextReturnsSecurityContext() { - InvocationContext context = new InvocationContext(this.securityContext, this.arguments); - assertThat(context.getSecurityContext()).isEqualTo(this.securityContext); - } - @Test void resolveSecurityContextReturnsSecurityContext() { InvocationContext context = new InvocationContext(this.securityContext, this.arguments); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/http/ApiVersionTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/http/ApiVersionTests.java deleted file mode 100644 index d7bf34f5675..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/http/ApiVersionTests.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.actuate.endpoint.http; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Test for {@link ApiVersion}. - * - * @author Phillip Webb - */ -@Deprecated -class ApiVersionTests { - - @Test - void latestIsLatestVersion() { - ApiVersion[] values = ApiVersion.values(); - assertThat(ApiVersion.LATEST).isEqualTo(values[values.length - 1]); - } - - @Test - @Deprecated - void fromHttpHeadersWhenEmptyReturnsLatest() { - ApiVersion version = ApiVersion.fromHttpHeaders(Collections.emptyMap()); - assertThat(version).isEqualTo(ApiVersion.V3); - } - - @Test - @Deprecated - void fromHttpHeadersWhenHasSingleV2HeaderReturnsV2() { - ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader(ActuatorMediaType.V2_JSON)); - assertThat(version).isEqualTo(ApiVersion.V2); - } - - @Test - @Deprecated - void fromHttpHeadersWhenHasSingleV3HeaderReturnsV3() { - ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader(ActuatorMediaType.V3_JSON)); - assertThat(version).isEqualTo(ApiVersion.V3); - } - - @Test - @Deprecated - void fromHttpHeadersWhenHasV2AndV3HeaderReturnsV3() { - ApiVersion version = ApiVersion - .fromHttpHeaders(acceptHeader(ActuatorMediaType.V2_JSON, ActuatorMediaType.V3_JSON)); - assertThat(version).isEqualTo(ApiVersion.V3); - } - - @Test - @Deprecated - void fromHttpHeadersWhenHasV2AndV3AsOneHeaderReturnsV3() { - ApiVersion version = ApiVersion - .fromHttpHeaders(acceptHeader(ActuatorMediaType.V2_JSON + "," + ActuatorMediaType.V3_JSON)); - assertThat(version).isEqualTo(ApiVersion.V3); - } - - @Test - @Deprecated - void fromHttpHeadersWhenHasSingleHeaderWithoutJsonReturnsHeader() { - ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader("application/vnd.spring-boot.actuator.v2")); - assertThat(version).isEqualTo(ApiVersion.V2); - } - - @Test - @Deprecated - void fromHttpHeadersWhenHasUnknownVersionReturnsLatest() { - ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader("application/vnd.spring-boot.actuator.v200")); - assertThat(version).isEqualTo(ApiVersion.V3); - } - - @Test - @Deprecated - void fromHttpHeadersWhenAcceptsEverythingReturnsLatest() { - ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader("*/*")); - assertThat(version).isEqualTo(ApiVersion.V3); - } - - private Map> acceptHeader(String... types) { - List value = Arrays.asList(types); - return value.isEmpty() ? Collections.emptyMap() : Collections.singletonMap("Accept", value); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchProperties.java index 2a5669306b0..08e7c1e6b52 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-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. @@ -17,7 +17,6 @@ package org.springframework.boot.autoconfigure.batch; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.boot.sql.init.DatabaseInitializationMode; /** @@ -36,56 +35,6 @@ public class BatchProperties { private final Jdbc jdbc = new Jdbc(); - /** - * Return the datasource schema. - * @return the schema - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of {@link Jdbc#getSchema()} - */ - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.batch.jdbc.schema") - public String getSchema() { - return this.jdbc.getSchema(); - } - - @Deprecated - public void setSchema(String schema) { - this.jdbc.setSchema(schema); - } - - /** - * Return the table prefix. - * @return the table prefix - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link Jdbc#getTablePrefix()} - */ - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.batch.jdbc.table-prefix") - public String getTablePrefix() { - return this.jdbc.getTablePrefix(); - } - - @Deprecated - public void setTablePrefix(String tablePrefix) { - this.jdbc.setTablePrefix(tablePrefix); - } - - /** - * Return whether the schema should be initialized. - * @return the initialization mode - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link Jdbc#getInitializeSchema()} - */ - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.batch.jdbc.initialize-schema") - public DatabaseInitializationMode getInitializeSchema() { - return this.jdbc.getInitializeSchema(); - } - - @Deprecated - public void setInitializeSchema(DatabaseInitializationMode initializeSchema) { - this.jdbc.setInitializeSchema(initializeSchema); - } - public Job getJob() { return this.job; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/jpa/EntityManagerFactoryDependsOnPostProcessor.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/jpa/EntityManagerFactoryDependsOnPostProcessor.java deleted file mode 100644 index 9a3c3e98595..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/jpa/EntityManagerFactoryDependsOnPostProcessor.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.autoconfigure.data.jpa; - -import javax.persistence.EntityManagerFactory; - -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; - -/** - * {@link BeanFactoryPostProcessor} that can be used to dynamically declare that all - * {@link EntityManagerFactory} beans should "depend on" one or more specific beans. - * - * @author Marcel Overdijk - * @author Dave Syer - * @author Phillip Webb - * @author Andy Wilkinson - * @author Andrii Hrytsiuk - * @since 1.1.0 - * @see BeanDefinition#setDependsOn(String[]) - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor} - */ -@Deprecated -public class EntityManagerFactoryDependsOnPostProcessor - extends org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor { - - /** - * Creates a new {@code EntityManagerFactoryDependsOnPostProcessor} that will set up - * dependencies upon beans with the given names. - * @param dependsOn names of the beans to depend upon - */ - public EntityManagerFactoryDependsOnPostProcessor(String... dependsOn) { - super(dependsOn); - } - - /** - * Creates a new {@code EntityManagerFactoryDependsOnPostProcessor} that will set up - * dependencies upon beans with the given types. - * @param dependsOn types of the beans to depend upon - * @since 2.1.8 - */ - public EntityManagerFactoryDependsOnPostProcessor(Class... dependsOn) { - super(dependsOn); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java index 57e66dcb7c9..c5db0108df1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java @@ -117,7 +117,6 @@ public class FlywayAutoConfiguration { ObjectProvider javaMigrations, ObjectProvider callbacks) { FluentConfiguration configuration = new FluentConfiguration(resourceLoader.getClassLoader()); configureDataSource(configuration, properties, flywayDataSource.getIfAvailable(), dataSource.getIfUnique()); - checkLocationExists(configuration.getDataSource(), properties, resourceLoader); configureProperties(configuration, properties); List orderedCallbacks = callbacks.orderedStream().collect(Collectors.toList()); configureCallbacks(configuration, orderedCallbacks); @@ -163,17 +162,6 @@ public class FlywayAutoConfiguration { } } - @SuppressWarnings("deprecation") - private void checkLocationExists(DataSource dataSource, FlywayProperties properties, - ResourceLoader resourceLoader) { - if (properties.isCheckLocation()) { - List locations = new LocationResolver(dataSource).resolveLocations(properties.getLocations()); - if (!hasAtLeastOneLocation(resourceLoader, locations)) { - throw new FlywayMigrationScriptMissingException(locations); - } - } - } - private void configureProperties(FluentConfiguration configuration, FlywayProperties properties) { PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); String[] locations = new LocationResolver(configuration.getDataSource()) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayMigrationScriptMissingException.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayMigrationScriptMissingException.java deleted file mode 100644 index c61a268889f..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayMigrationScriptMissingException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.autoconfigure.flyway; - -import java.util.ArrayList; -import java.util.List; - -/** - * Exception thrown when no Flyway migration script is available. - * - * @author Anand Shastri - * @author Stephane Nicoll - * @since 2.2.0 - * @deprecated since 2.5.0 for removal in 2.7.0 as location checking is deprecated - */ -@Deprecated -public class FlywayMigrationScriptMissingException extends RuntimeException { - - private final List locations; - - FlywayMigrationScriptMissingException(List locations) { - super(locations.isEmpty() ? "Migration script locations not configured" : "Cannot find migration scripts in: " - + locations + " (please add migration scripts or check your Flyway configuration)"); - this.locations = new ArrayList<>(locations); - } - - public List getLocations() { - return this.locations; - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayMigrationScriptMissingFailureAnalyzer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayMigrationScriptMissingFailureAnalyzer.java deleted file mode 100644 index d66f2c7b66f..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayMigrationScriptMissingFailureAnalyzer.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.autoconfigure.flyway; - -import org.springframework.boot.diagnostics.AbstractFailureAnalyzer; -import org.springframework.boot.diagnostics.FailureAnalysis; - -/** - * A {@code FailureAnalyzer} that performs analysis of failures caused by a - * {@link FlywayMigrationScriptMissingException}. - * - * @author Anand Shastri - * @author Stephane Nicoll - * @deprecated since 2.5.0 for removal in 2.7.0 as location checking is deprecated - */ -@Deprecated -class FlywayMigrationScriptMissingFailureAnalyzer - extends AbstractFailureAnalyzer { - - @Override - protected FailureAnalysis analyze(Throwable rootFailure, FlywayMigrationScriptMissingException cause) { - StringBuilder description = new StringBuilder("Flyway failed to initialize: "); - if (cause.getLocations().isEmpty()) { - return new FailureAnalysis(description.append("no migration scripts location is configured").toString(), - "Check your Flyway configuration", cause); - } - description.append(String.format("none of the following migration scripts locations could be found:%n%n")); - cause.getLocations().forEach((location) -> description.append(String.format("\t- %s%n", location))); - return new FailureAnalysis(description.toString(), - "Review the locations above or check your Flyway configuration", cause); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java index e640d47f452..075b21fbb84 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-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. @@ -402,18 +402,6 @@ public class FlywayProperties { this.enabled = enabled; } - @Deprecated - @DeprecatedConfigurationProperty( - reason = "Locations can no longer be checked accurately due to changes in Flyway's location support.") - public boolean isCheckLocation() { - return this.checkLocation; - } - - @Deprecated - public void setCheckLocation(boolean checkLocation) { - this.checkLocation = checkLocation; - } - public boolean isFailOnMissingLocations() { return this.failOnMissingLocations; } @@ -598,17 +586,6 @@ public class FlywayProperties { this.target = target; } - /** - * Return if a new datasource is being created. - * @return {@code true} if a new datasource is created - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of directly checking user and - * url. - */ - @Deprecated - public boolean isCreateDataSource() { - return this.url != null || this.user != null; - } - public String getUser() { return this.user; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaHttpMessageConverterConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaHttpMessageConverterConfiguration.java deleted file mode 100644 index b190ed585cc..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaHttpMessageConverterConfiguration.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.autoconfigure.hateoas; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.hateoas.mediatype.hal.HalConfiguration; -import org.springframework.hateoas.server.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; -import org.springframework.http.MediaType; -import org.springframework.http.converter.AbstractHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; - -/** - * Configuration for {@link HttpMessageConverter HttpMessageConverters} when hypermedia is - * enabled. - * - * @author Andy Wilkinson - * @since 1.3.0 - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of a {@link HalConfiguration} - * bean - */ -@Deprecated -@Configuration(proxyBeanMethods = false) -public class HypermediaHttpMessageConverterConfiguration { - - @Bean - @ConditionalOnProperty(prefix = "spring.hateoas", name = "use-hal-as-default-json-media-type", - matchIfMissing = true) - public static HalMessageConverterSupportedMediaTypesCustomizer halMessageConverterSupportedMediaTypeCustomizer() { - return new HalMessageConverterSupportedMediaTypesCustomizer(); - } - - /** - * Updates any {@link TypeConstrainedMappingJackson2HttpMessageConverter}s to support - * {@code application/json} in addition to {@code application/hal+json}. Cannot be a - * {@link BeanPostProcessor} as processing must be performed after - * {@code Jackson2ModuleRegisteringBeanPostProcessor} has registered the converter and - * it is unordered. - */ - static class HalMessageConverterSupportedMediaTypesCustomizer implements BeanFactoryAware, InitializingBean { - - private volatile BeanFactory beanFactory; - - @Override - public void afterPropertiesSet() { - if (this.beanFactory instanceof ListableBeanFactory) { - configureHttpMessageConverters(((ListableBeanFactory) this.beanFactory) - .getBeansOfType(RequestMappingHandlerAdapter.class).values()); - } - } - - private void configureHttpMessageConverters(Collection handlerAdapters) { - for (RequestMappingHandlerAdapter handlerAdapter : handlerAdapters) { - for (HttpMessageConverter messageConverter : handlerAdapter.getMessageConverters()) { - configureHttpMessageConverter(messageConverter); - } - } - } - - private void configureHttpMessageConverter(HttpMessageConverter converter) { - if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) { - List supportedMediaTypes = new ArrayList<>(converter.getSupportedMediaTypes()); - if (!supportedMediaTypes.contains(MediaType.APPLICATION_JSON)) { - supportedMediaTypes.add(MediaType.APPLICATION_JSON); - } - ((AbstractHttpMessageConverter) converter).setSupportedMediaTypes(supportedMediaTypes); - } - } - - @Override - public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - this.beanFactory = beanFactory; - } - - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceSchemaCreatedEvent.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceSchemaCreatedEvent.java deleted file mode 100644 index c7970ba079e..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceSchemaCreatedEvent.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.autoconfigure.jdbc; - -import javax.sql.DataSource; - -import org.springframework.context.ApplicationEvent; - -/** - * {@link ApplicationEvent} used internally to indicate that the schema of a new - * {@link DataSource} has been created. This happens when {@literal schema-*.sql} files - * are executed or when Hibernate initializes the database. - * - * @author Dave Syer - * @author Stephane Nicoll - * @since 2.0.0 - * @deprecated since 2.5.0 for removal in 2.7.0 with no replacement as the event is no - * longer published - */ -@SuppressWarnings("serial") -@Deprecated -public class DataSourceSchemaCreatedEvent extends ApplicationEvent { - - /** - * Create a new {@link DataSourceSchemaCreatedEvent}. - * @param source the source {@link DataSource}. - */ - public DataSourceSchemaCreatedEvent(DataSource source) { - super(source); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JdbcOperationsDependsOnPostProcessor.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JdbcOperationsDependsOnPostProcessor.java deleted file mode 100644 index 176c2962f7c..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JdbcOperationsDependsOnPostProcessor.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.autoconfigure.jdbc; - -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; -import org.springframework.boot.autoconfigure.AbstractDependsOnBeanFactoryPostProcessor; -import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector; -import org.springframework.jdbc.core.JdbcOperations; - -/** - * {@link BeanFactoryPostProcessor} that can be used to dynamically declare that all - * {@link JdbcOperations} beans should "depend on" one or more specific beans. - * - * @author Marcel Overdijk - * @author Dave Syer - * @author Phillip Webb - * @author Andy Wilkinson - * @author Andrii Hrytsiuk - * @since 2.0.4 - * @see BeanDefinition#setDependsOn(String[]) - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link DependsOnDatabaseInitializationDetector} - */ -@Deprecated -public class JdbcOperationsDependsOnPostProcessor extends AbstractDependsOnBeanFactoryPostProcessor { - - /** - * Creates a new {@code JdbcOperationsDependsOnPostProcessor} that will set up - * dependencies upon beans with the given names. - * @param dependsOn names of the beans to depend upon - */ - public JdbcOperationsDependsOnPostProcessor(String... dependsOn) { - super(JdbcOperations.class, dependsOn); - } - - /** - * Creates a new {@code JdbcOperationsDependsOnPostProcessor} that will set up - * dependencies upon beans with the given types. - * @param dependsOn types of the beans to depend upon - * @since 2.1.8 - */ - public JdbcOperationsDependsOnPostProcessor(Class... dependsOn) { - super(JdbcOperations.class, dependsOn); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/NamedParameterJdbcOperationsDependsOnPostProcessor.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/NamedParameterJdbcOperationsDependsOnPostProcessor.java deleted file mode 100644 index c0afaed6df6..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/NamedParameterJdbcOperationsDependsOnPostProcessor.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.autoconfigure.jdbc; - -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; -import org.springframework.boot.autoconfigure.AbstractDependsOnBeanFactoryPostProcessor; -import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector; -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; - -/** - * {@link BeanFactoryPostProcessor} that can be used to dynamically declare that all - * {@link NamedParameterJdbcOperations} beans should "depend on" one or more specific - * beans. - * - * @author Dan Zheng - * @author Andrii Hrytsiuk - * @since 2.1.4 - * @see BeanDefinition#setDependsOn(String[]) - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link DependsOnDatabaseInitializationDetector} - */ -@Deprecated -public class NamedParameterJdbcOperationsDependsOnPostProcessor extends AbstractDependsOnBeanFactoryPostProcessor { - - /** - * Creates a new {@code NamedParameterJdbcOperationsDependsOnPostProcessor} that will - * set up dependencies upon beans with the given names. - * @param dependsOn names of the beans to depend upon - */ - public NamedParameterJdbcOperationsDependsOnPostProcessor(String... dependsOn) { - super(NamedParameterJdbcOperations.class, dependsOn); - } - - /** - * Creates a new {@code NamedParameterJdbcOperationsDependsOnPostProcessor} that will - * set up dependencies upon beans with the given types. - * @param dependsOn types of the beans to depend upon - * @since 2.1.8 - */ - public NamedParameterJdbcOperationsDependsOnPostProcessor(Class... dependsOn) { - super(NamedParameterJdbcOperations.class, dependsOn); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java index 62de6fb0ed4..344f8ace981 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-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. @@ -17,15 +17,11 @@ package org.springframework.boot.autoconfigure.jms.artemis; import java.lang.reflect.Constructor; -import java.util.HashMap; -import java.util.Map; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; -import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.springframework.beans.factory.ListableBeanFactory; @@ -139,18 +135,7 @@ class ArtemisConnectionFactoryFactory { return connectionFactory; } - @SuppressWarnings("deprecation") private T newNativeConnectionFactory(Class factoryClass) throws Exception { - // Fallback if the broker url is not set - if (!StringUtils.hasText(this.properties.getBrokerUrl()) && StringUtils.hasText(this.properties.getHost())) { - Map params = new HashMap<>(); - params.put(TransportConstants.HOST_PROP_NAME, this.properties.getHost()); - params.put(TransportConstants.PORT_PROP_NAME, this.properties.getPort()); - TransportConfiguration transportConfiguration = new TransportConfiguration( - NettyConnectorFactory.class.getName(), params); - Constructor constructor = factoryClass.getConstructor(boolean.class, TransportConfiguration[].class); - return constructor.newInstance(false, new TransportConfiguration[] { transportConfiguration }); - } String brokerUrl = StringUtils.hasText(this.properties.getBrokerUrl()) ? this.properties.getBrokerUrl() : DEFAULT_BROKER_URL; Constructor constructor = factoryClass.getConstructor(String.class); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisProperties.java index 2ec33815645..52b0ec4e4a7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-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. @@ -25,7 +25,6 @@ import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants; import org.springframework.boot.autoconfigure.jms.JmsPoolConnectionFactoryProperties; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.boot.context.properties.NestedConfigurationProperty; /** @@ -90,38 +89,6 @@ public class ArtemisProperties { this.brokerUrl = brokerUrl; } - /** - * Return the host of the broker. - * @return the host - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of broker url - */ - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.artemis.broker-url") - public String getHost() { - return this.host; - } - - @Deprecated - public void setHost(String host) { - this.host = host; - } - - /** - * Return the port of the broker. - * @return the port - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of broker url - */ - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.artemis.broker-url") - public int getPort() { - return this.port; - } - - @Deprecated - public void setPort(int port) { - this.port = port; - } - public String getUser() { return this.user; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/DslContextDependsOnPostProcessor.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/DslContextDependsOnPostProcessor.java deleted file mode 100644 index 3cb72988701..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/DslContextDependsOnPostProcessor.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.autoconfigure.jooq; - -import org.jooq.DSLContext; - -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; -import org.springframework.boot.autoconfigure.AbstractDependsOnBeanFactoryPostProcessor; -import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector; - -/** - * {@link BeanFactoryPostProcessor} that can be used to dynamically declare that all - * {@link DSLContext} beans should "depend on" one or more specific beans. - * - * @author EddĂș MelĂ©ndez - * @since 2.3.9 - * @see BeanDefinition#setDependsOn(String[]) - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link DependsOnDatabaseInitializationDetector} - */ -@Deprecated -public class DslContextDependsOnPostProcessor extends AbstractDependsOnBeanFactoryPostProcessor { - - /** - * Creates a new {@code DslContextDependsOnPostProcessor} that will set up - * dependencies upon beans with the given names. - * @param dependsOn names of the beans to depend upon - */ - public DslContextDependsOnPostProcessor(String... dependsOn) { - super(DSLContext.class, dependsOn); - } - - /** - * Creates a new {@code DslContextDependsOnPostProcessor} that will set up - * dependencies upon beans with the given types. - * @param dependsOn types of the beans to depend upon - */ - public DslContextDependsOnPostProcessor(Class... dependsOn) { - super(DSLContext.class, dependsOn); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java index 0d8949ae691..733df66a6a4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-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. @@ -17,7 +17,6 @@ package org.springframework.boot.autoconfigure.mustache; import com.samskivert.mustache.Mustache; -import com.samskivert.mustache.Mustache.Collector; import com.samskivert.mustache.Mustache.TemplateLoader; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -31,7 +30,6 @@ 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.core.env.Environment; /** * {@link EnableAutoConfiguration Auto-configuration} for Mustache. @@ -71,15 +69,8 @@ public class MustacheAutoConfiguration { @Bean @ConditionalOnMissingBean - public Mustache.Compiler mustacheCompiler(TemplateLoader mustacheTemplateLoader, Environment environment) { - return Mustache.compiler().withLoader(mustacheTemplateLoader).withCollector(collector(environment)); - } - - @Deprecated - private Collector collector(Environment environment) { - MustacheEnvironmentCollector collector = new MustacheEnvironmentCollector(); - collector.setEnvironment(environment); - return collector; + public Mustache.Compiler mustacheCompiler(TemplateLoader mustacheTemplateLoader) { + return Mustache.compiler().withLoader(mustacheTemplateLoader); } @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheEnvironmentCollector.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheEnvironmentCollector.java deleted file mode 100644 index f4d192413b4..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheEnvironmentCollector.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.autoconfigure.mustache; - -import java.util.concurrent.atomic.AtomicBoolean; - -import com.samskivert.mustache.DefaultCollector; -import com.samskivert.mustache.Mustache.Collector; -import com.samskivert.mustache.Mustache.VariableFetcher; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.context.EnvironmentAware; -import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.env.Environment; - -/** - * Mustache {@link Collector} to expose properties from the Spring {@link Environment}. - * - * @author Dave Syer - * @author Madhura Bhave - * @since 1.2.2 - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of direct addition of values from - * the Environment to the model - */ -@Deprecated -public class MustacheEnvironmentCollector extends DefaultCollector implements EnvironmentAware { - - private ConfigurableEnvironment environment; - - private final VariableFetcher propertyFetcher = new PropertyVariableFetcher(); - - @Override - public void setEnvironment(Environment environment) { - this.environment = (ConfigurableEnvironment) environment; - } - - @Override - public VariableFetcher createFetcher(Object ctx, String name) { - VariableFetcher fetcher = super.createFetcher(ctx, name); - if (fetcher != null) { - return fetcher; - } - if (this.environment.containsProperty(name)) { - return this.propertyFetcher; - } - return null; - } - - private class PropertyVariableFetcher implements VariableFetcher { - - private final Log log = LogFactory.getLog(PropertyVariableFetcher.class); - - private final AtomicBoolean logDeprecationWarning = new AtomicBoolean(); - - @Override - public Object get(Object ctx, String name) { - String property = MustacheEnvironmentCollector.this.environment.getProperty(name); - if (property != null && this.logDeprecationWarning.compareAndSet(false, true)) { - this.log.warn("Mustache variable resolution relied upon deprecated support for falling back to the " - + "Spring Environment. Please add values from the Environment directly to the model instead."); - } - return property; - } - - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryBuilder.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryBuilder.java deleted file mode 100644 index 20497b6c672..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryBuilder.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.autoconfigure.r2dbc; - -import java.util.function.Consumer; -import java.util.function.Supplier; - -import io.r2dbc.spi.ConnectionFactories; -import io.r2dbc.spi.ConnectionFactory; -import io.r2dbc.spi.ConnectionFactoryOptions; -import io.r2dbc.spi.ConnectionFactoryOptions.Builder; - -/** - * Builder for {@link ConnectionFactory}. - * - * @author Mark Paluch - * @author Tadaya Tsuyukubo - * @author Stephane Nicoll - * @since 2.3.0 - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link org.springframework.boot.r2dbc.ConnectionFactoryBuilder} - */ -@Deprecated -public final class ConnectionFactoryBuilder { - - private final ConnectionFactoryOptions.Builder optionsBuilder; - - private ConnectionFactoryBuilder(ConnectionFactoryOptions.Builder optionsBuilder) { - this.optionsBuilder = optionsBuilder; - } - - /** - * Initialize a new {@link ConnectionFactoryBuilder} based on the specified - * {@link R2dbcProperties}. If no url is specified, the - * {@link EmbeddedDatabaseConnection} supplier is invoked to determine if an embedded - * database can be configured instead. - * @param properties the properties to use to initialize the builder - * @param embeddedDatabaseConnection a supplier for an - * {@link EmbeddedDatabaseConnection} - * @return a new builder initialized with the settings defined in - * {@link R2dbcProperties} - */ - public static ConnectionFactoryBuilder of(R2dbcProperties properties, - Supplier embeddedDatabaseConnection) { - return new ConnectionFactoryBuilder( - new ConnectionFactoryOptionsInitializer().initialize(properties, adapt(embeddedDatabaseConnection))); - } - - /** - * Configure additional options. - * @param options a {@link Consumer} to customize the options - * @return this for method chaining - */ - public ConnectionFactoryBuilder configure(Consumer options) { - options.accept(this.optionsBuilder); - return this; - } - - /** - * Configure the {@linkplain ConnectionFactoryOptions#USER username}. - * @param username the connection factory username - * @return this for method chaining - */ - public ConnectionFactoryBuilder username(String username) { - return configure((options) -> options.option(ConnectionFactoryOptions.USER, username)); - } - - /** - * Configure the {@linkplain ConnectionFactoryOptions#PASSWORD password}. - * @param password the connection factory password - * @return this for method chaining - */ - public ConnectionFactoryBuilder password(CharSequence password) { - return configure((options) -> options.option(ConnectionFactoryOptions.PASSWORD, password)); - } - - /** - * Configure the {@linkplain ConnectionFactoryOptions#HOST host name}. - * @param host the connection factory hostname - * @return this for method chaining - */ - public ConnectionFactoryBuilder hostname(String host) { - return configure((options) -> options.option(ConnectionFactoryOptions.HOST, host)); - } - - /** - * Configure the {@linkplain ConnectionFactoryOptions#PORT port}. - * @param port the connection factory port - * @return this for method chaining - */ - public ConnectionFactoryBuilder port(int port) { - return configure((options) -> options.option(ConnectionFactoryOptions.PORT, port)); - } - - /** - * Configure the {@linkplain ConnectionFactoryOptions#DATABASE database}. - * @param database the connection factory database - * @return this for method chaining - */ - public ConnectionFactoryBuilder database(String database) { - return configure((options) -> options.option(ConnectionFactoryOptions.DATABASE, database)); - } - - /** - * Build a {@link ConnectionFactory} based on the state of this builder. - * @return a connection factory - */ - public ConnectionFactory build() { - return ConnectionFactories.get(buildOptions()); - } - - /** - * Build a {@link ConnectionFactoryOptions} based on the state of this builder. - * @return the options - */ - public ConnectionFactoryOptions buildOptions() { - return this.optionsBuilder.build(); - } - - private static Supplier adapt( - Supplier embeddedDatabaseConnection) { - return () -> { - EmbeddedDatabaseConnection connection = embeddedDatabaseConnection.get(); - return (connection != null) - ? org.springframework.boot.r2dbc.EmbeddedDatabaseConnection.valueOf(connection.name()) : null; - }; - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/EmbeddedDatabaseConnection.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/EmbeddedDatabaseConnection.java deleted file mode 100644 index 46426a0f148..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/EmbeddedDatabaseConnection.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.autoconfigure.r2dbc; - -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; - -/** - * Connection details for embedded databases compatible with r2dbc. - * - * @author Mark Paluch - * @author Stephane Nicoll - * @since 2.3.0 - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of - * {@link org.springframework.boot.r2dbc.EmbeddedDatabaseConnection} - */ -@Deprecated -public enum EmbeddedDatabaseConnection { - - /** - * No Connection. - */ - NONE(null, null, null), - - /** - * H2 Database Connection. - */ - H2("H2", "io.r2dbc.h2.H2ConnectionFactoryProvider", - "r2dbc:h2:mem:///%s?options=DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"); - - private final String type; - - private final String driverClassName; - - private final String url; - - EmbeddedDatabaseConnection(String type, String driverClassName, String url) { - this.type = type; - this.driverClassName = driverClassName; - this.url = url; - } - - /** - * Returns the driver class name. - * @return the driver class name - */ - public String getDriverClassName() { - return this.driverClassName; - } - - /** - * Returns the embedded database type name for the connection. - * @return the database type - */ - public String getType() { - return this.type; - } - - /** - * Returns the R2DBC URL for the connection using the specified {@code databaseName}. - * @param databaseName the name of the database - * @return the connection URL - */ - public String getUrl(String databaseName) { - Assert.hasText(databaseName, "DatabaseName must not be empty"); - return (this.url != null) ? String.format(this.url, databaseName) : null; - } - - /** - * Returns the most suitable {@link EmbeddedDatabaseConnection} for the given class - * loader. - * @param classLoader the class loader used to check for classes - * @return an {@link EmbeddedDatabaseConnection} or {@link #NONE}. - */ - public static EmbeddedDatabaseConnection get(ClassLoader classLoader) { - for (EmbeddedDatabaseConnection candidate : EmbeddedDatabaseConnection.values()) { - if (candidate != NONE && ClassUtils.isPresent(candidate.getDriverClassName(), classLoader)) { - return candidate; - } - } - return NONE; - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 6a194f74c3f..a8bc167953f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -328,12 +328,28 @@ "name": "spring.artemis.broker-url", "defaultValue": "tcp://localhost:61616" }, + { + "name": "spring.artemis.host", + "type": "java.lang.String", + "deprecation": { + "replacement": "spring.artemis.broker-url", + "level": "error" + } + }, { "name": "spring.artemis.pool.maximum-active-session-per-connection", "deprecation": { "replacement": "spring.artemis.pool.max-sessions-per-connection" } }, + { + "name": "spring.artemis.port", + "type": "java.lang.Integer", + "deprecation": { + "replacement": "spring.artemis.broker-url", + "level": "error" + } + }, { "name": "spring.autoconfigure.exclude", "type": "java.util.List", @@ -341,7 +357,11 @@ }, { "name": "spring.batch.initialize-schema", - "defaultValue": "embedded" + "type" : "org.springframework.boot.sql.init.DatabaseInitializationMode", + "deprecation" : { + "replacement": "spring.batch.jdbc.initialize-schema", + "level" : "error" + }, }, { "name": "spring.batch.initializer.enabled", @@ -362,6 +382,22 @@ "description": "Execute all Spring Batch jobs in the context on startup.", "defaultValue": true }, + { + "name" : "spring.batch.schema", + "type" : "java.lang.String", + "deprecation" : { + "replacement": "spring.batch.jdbc.schema", + "level" : "error" + } + }, + { + "name": "spring.batch.table-prefix", + "type": "java.lang.String", + "deprecation": { + "replacement": "spring.batch.jdbc.table-prefix", + "level": "error" + } + }, { "name": "spring.couchbase.bootstrap-hosts", "type": "java.util.List", @@ -848,6 +884,14 @@ "name": "spring.flyway.baseline-migration-prefix", "defaultValue": "B" }, + { + "name": "spring.flyway.check-location", + "type": "java.lang.Boolean", + "deprecation": { + "replacement": "spring.flyway.fail-on-missing-locations", + "level": "error" + } + }, { "name": "spring.flyway.connect-retries-interval", "defaultValue": 120 diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java index b69baa9acfe..01fd02c7caf 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-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. @@ -56,13 +56,10 @@ import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer; import org.springframework.boot.sql.init.DatabaseInitializationMode; import org.springframework.boot.sql.init.DatabaseInitializationSettings; -import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.boot.test.context.runner.ContextConsumer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; -import org.springframework.core.io.ResourceLoader; import org.springframework.jdbc.BadSqlGrammarException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DataSourceTransactionManager; @@ -187,28 +184,15 @@ class BatchAutoConfigurationTests { this.contextRunner.withUserConfiguration(TestConfiguration.class, EmbeddedDataSourceConfiguration.class) .withPropertyValues("spring.datasource.generate-unique-name=true", "spring.batch.jdbc.initialize-schema:never") - .run(assertDatasourceIsNotInitialized()); - } - - @Test - @Deprecated - void testDisableSchemaLoaderWithDeprecatedProperty() { - this.contextRunner.withUserConfiguration(TestConfiguration.class, EmbeddedDataSourceConfiguration.class) - .withPropertyValues("spring.datasource.generate-unique-name=true", - "spring.batch.initialize-schema:never") - .run(assertDatasourceIsNotInitialized()); - } - - private ContextConsumer assertDatasourceIsNotInitialized() { - return (context) -> { - assertThat(context).hasSingleBean(JobLauncher.class); - assertThat(context.getBean(BatchProperties.class).getJdbc().getInitializeSchema()) - .isEqualTo(DatabaseInitializationMode.NEVER); - assertThat(context).doesNotHaveBean(BatchDataSourceScriptDatabaseInitializer.class); - assertThatExceptionOfType(BadSqlGrammarException.class) - .isThrownBy(() -> new JdbcTemplate(context.getBean(DataSource.class)) - .queryForList("select * from BATCH_JOB_EXECUTION")); - }; + .run((context) -> { + assertThat(context).hasSingleBean(JobLauncher.class); + assertThat(context.getBean(BatchProperties.class).getJdbc().getInitializeSchema()) + .isEqualTo(DatabaseInitializationMode.NEVER); + assertThat(context).doesNotHaveBean(BatchDataSourceScriptDatabaseInitializer.class); + assertThatExceptionOfType(BadSqlGrammarException.class) + .isThrownBy(() -> new JdbcTemplate(context.getBean(DataSource.class)) + .queryForList("select * from BATCH_JOB_EXECUTION")); + }); } @Test @@ -235,33 +219,17 @@ class BatchAutoConfigurationTests { .withPropertyValues("spring.datasource.generate-unique-name=true", "spring.batch.jdbc.schema:classpath:batch/custom-schema-hsql.sql", "spring.batch.jdbc.tablePrefix:PREFIX_") - .run(assertCustomTablePrefix()); - } - - @Test - @Deprecated - void testRenamePrefixWithDeprecatedProperty() { - this.contextRunner - .withUserConfiguration(TestConfiguration.class, EmbeddedDataSourceConfiguration.class, - HibernateJpaAutoConfiguration.class) - .withPropertyValues("spring.datasource.generate-unique-name=true", - "spring.batch.schema:classpath:batch/custom-schema-hsql.sql", - "spring.batch.tablePrefix:PREFIX_") - .run(assertCustomTablePrefix()); - } - - private ContextConsumer assertCustomTablePrefix() { - return (context) -> { - assertThat(context).hasSingleBean(JobLauncher.class); - assertThat(context.getBean(BatchProperties.class).getJdbc().getInitializeSchema()) - .isEqualTo(DatabaseInitializationMode.EMBEDDED); - assertThat(new JdbcTemplate(context.getBean(DataSource.class)) - .queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty(); - JobExplorer jobExplorer = context.getBean(JobExplorer.class); - assertThat(jobExplorer.findRunningJobExecutions("test")).isEmpty(); - JobRepository jobRepository = context.getBean(JobRepository.class); - assertThat(jobRepository.getLastJobExecution("test", new JobParameters())).isNull(); - }; + .run((context) -> { + assertThat(context).hasSingleBean(JobLauncher.class); + assertThat(context.getBean(BatchProperties.class).getJdbc().getInitializeSchema()) + .isEqualTo(DatabaseInitializationMode.EMBEDDED); + assertThat(new JdbcTemplate(context.getBean(DataSource.class)) + .queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty(); + JobExplorer jobExplorer = context.getBean(JobExplorer.class); + assertThat(jobExplorer.findRunningJobExecutions("test")).isEmpty(); + JobRepository jobRepository = context.getBean(JobRepository.class); + assertThat(jobRepository.getLastJobExecution("test", new JobParameters())).isNull(); + }); } @Test @@ -362,18 +330,6 @@ class BatchAutoConfigurationTests { .doesNotHaveBean("batchDataSourceScriptDatabaseInitializer").hasBean("customInitializer")); } - @Test - @Deprecated - @SuppressWarnings("deprecation") - void whenTheUserDefinesTheirOwnBatchDataSourceInitializerThenTheAutoConfiguredInitializerBacksOff() { - this.contextRunner - .withUserConfiguration(TestConfiguration.class, CustomBatchDataSourceInitializerConfiguration.class) - .withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class, - DataSourceTransactionManagerAutoConfiguration.class)) - .run((context) -> assertThat(context).doesNotHaveBean(BatchDataSourceScriptDatabaseInitializer.class) - .hasSingleBean(BatchDataSourceInitializer.class).hasBean("customInitializer")); - } - @Test void whenTheUserDefinesTheirOwnDatabaseInitializerThenTheAutoConfiguredBatchInitializerRemains() { this.contextRunner.withUserConfiguration(TestConfiguration.class, CustomDatabaseInitializerConfiguration.class) @@ -547,16 +503,4 @@ class BatchAutoConfigurationTests { } - @Deprecated - @Configuration(proxyBeanMethods = false) - static class CustomBatchDataSourceInitializerConfiguration { - - @Bean - BatchDataSourceInitializer customInitializer(DataSource dataSource, ResourceLoader resourceLoader, - BatchProperties properties) { - return new BatchDataSourceInitializer(dataSource, resourceLoader, properties); - } - - } - } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationWithoutJpaTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationWithoutJpaTests.java index 2a7562919e7..6c7f56287f0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationWithoutJpaTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationWithoutJpaTests.java @@ -31,9 +31,7 @@ import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfigurati import org.springframework.boot.autoconfigure.orm.jpa.test.City; import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration; import org.springframework.boot.sql.init.DatabaseInitializationMode; -import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.boot.test.context.runner.ContextConsumer; import org.springframework.boot.testsupport.classpath.ClassPathExclusions; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.transaction.PlatformTransactionManager; @@ -77,26 +75,13 @@ class BatchAutoConfigurationWithoutJpaTests { .withPropertyValues("spring.datasource.generate-unique-name=true", "spring.batch.jdbc.schema:classpath:batch/custom-schema-hsql.sql", "spring.batch.jdbc.tablePrefix:PREFIX_") - .run(assertCustomPrefix()); - } - - @Test - @Deprecated - void jdbcWithCustomPrefixWithDeprecatedProperties() { - this.contextRunner.withUserConfiguration(DefaultConfiguration.class, EmbeddedDataSourceConfiguration.class) - .withPropertyValues("spring.datasource.generate-unique-name=true", - "spring.batch.schema:classpath:batch/custom-schema-hsql.sql", - "spring.batch.tablePrefix:PREFIX_") - .run(assertCustomPrefix()); - } - - private ContextConsumer assertCustomPrefix() { - return (context) -> { - assertThat(new JdbcTemplate(context.getBean(DataSource.class)) - .queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty(); - assertThat(context.getBean(JobExplorer.class).findRunningJobExecutions("test")).isEmpty(); - assertThat(context.getBean(JobRepository.class).getLastJobExecution("test", new JobParameters())).isNull(); - }; + .run((context) -> { + assertThat(new JdbcTemplate(context.getBean(DataSource.class)) + .queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty(); + assertThat(context.getBean(JobExplorer.class).findRunningJobExecutions("test")).isEmpty(); + assertThat(context.getBean(JobRepository.class).getLastJobExecution("test", new JobParameters())) + .isNull(); + }); } @EnableBatchProcessing diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java index c075006c14c..a535d4572e2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java @@ -291,53 +291,18 @@ class FlywayAutoConfigurationTests { @Test void changeLogDoesNotExist() { this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) - .withPropertyValues("spring.flyway.locations:filesystem:no-such-dir").run((context) -> { - assertThat(context).hasFailed(); - assertThat(context).getFailure().isInstanceOf(BeanCreationException.class); - }); - } - - @Test - @Deprecated - void checkLocationsAllMissing() { - this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) - .withPropertyValues("spring.flyway.locations:classpath:db/missing1,classpath:db/migration2") + .withPropertyValues("spring.flyway.fail-on-missing-locations=true", + "spring.flyway.locations:filesystem:no-such-dir") .run((context) -> { assertThat(context).hasFailed(); assertThat(context).getFailure().isInstanceOf(BeanCreationException.class); - assertThat(context).getFailure().hasMessageContaining("Cannot find migration scripts in"); }); } - @Test - @Deprecated - void checkLocationsAllExist() { - this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) - .withPropertyValues("spring.flyway.locations:classpath:db/changelog,classpath:db/migration") - .run((context) -> assertThat(context).hasNotFailed()); - } - - @Test - @Deprecated - void checkLocationsAllExistWithImplicitClasspathPrefix() { - this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) - .withPropertyValues("spring.flyway.locations:db/changelog,db/migration") - .run((context) -> assertThat(context).hasNotFailed()); - } - - @Test - @Deprecated - void checkLocationsAllExistWithFilesystemPrefix() { - this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) - .withPropertyValues("spring.flyway.locations:filesystem:src/test/resources/db/migration") - .run((context) -> assertThat(context).hasNotFailed()); - } - @Test void failOnMissingLocationsAllMissing() { this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) - .withPropertyValues("spring.flyway.check-location=false", - "spring.flyway.fail-on-missing-locations=true") + .withPropertyValues("spring.flyway.fail-on-missing-locations=true") .withPropertyValues("spring.flyway.locations:classpath:db/missing1,classpath:db/migration2") .run((context) -> { assertThat(context).hasFailed(); @@ -349,8 +314,7 @@ class FlywayAutoConfigurationTests { @Test void failOnMissingLocationsAllExist() { this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) - .withPropertyValues("spring.flyway.check-location=false", - "spring.flyway.fail-on-missing-locations=true") + .withPropertyValues("spring.flyway.fail-on-missing-locations=true") .withPropertyValues("spring.flyway.locations:classpath:db/changelog,classpath:db/migration") .run((context) -> assertThat(context).hasNotFailed()); } @@ -358,8 +322,7 @@ class FlywayAutoConfigurationTests { @Test void failOnMissingLocationsAllExistWithImplicitClasspathPrefix() { this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) - .withPropertyValues("spring.flyway.check-location=false", - "spring.flyway.fail-on-missing-locations=true") + .withPropertyValues("spring.flyway.fail-on-missing-locations=true") .withPropertyValues("spring.flyway.locations:db/changelog,db/migration") .run((context) -> assertThat(context).hasNotFailed()); } @@ -367,8 +330,7 @@ class FlywayAutoConfigurationTests { @Test void failOnMissingLocationsAllExistWithFilesystemPrefix() { this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) - .withPropertyValues("spring.flyway.check-location=false", - "spring.flyway.fail-on-missing-locations=true") + .withPropertyValues("spring.flyway.fail-on-missing-locations=true") .withPropertyValues("spring.flyway.locations:filesystem:src/test/resources/db/migration") .run((context) -> assertThat(context).hasNotFailed()); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayMigrationScriptMissingFailureAnalyzerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayMigrationScriptMissingFailureAnalyzerTests.java deleted file mode 100644 index 87253526704..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayMigrationScriptMissingFailureAnalyzerTests.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.autoconfigure.flyway; - -import java.util.Arrays; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.diagnostics.FailureAnalysis; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link FlywayMigrationScriptMissingFailureAnalyzer}. - * - * @author Anand Shastri - * @deprecated since 2.5.0 for removal in 2.7.0 as location checking is deprecated - */ -@Deprecated -class FlywayMigrationScriptMissingFailureAnalyzerTests { - - @Test - void analysisForMissingScriptLocation() { - FailureAnalysis failureAnalysis = performAnalysis(); - assertThat(failureAnalysis.getDescription()).contains("no migration scripts location is configured"); - assertThat(failureAnalysis.getAction()).contains("Check your Flyway configuration"); - } - - @Test - void analysisForScriptLocationsNotFound() { - FailureAnalysis failureAnalysis = performAnalysis("classpath:db/migration"); - assertThat(failureAnalysis.getDescription()) - .contains("none of the following migration scripts locations could be found") - .contains("classpath:db/migration"); - assertThat(failureAnalysis.getAction()) - .contains("Review the locations above or check your Flyway configuration"); - } - - private FailureAnalysis performAnalysis(String... locations) { - FlywayMigrationScriptMissingException exception = new FlywayMigrationScriptMissingException( - Arrays.asList(locations)); - return new FlywayMigrationScriptMissingFailureAnalyzer().analyze(exception); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java index 515a4306bfd..69d2341823b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-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. @@ -131,26 +131,6 @@ class ArtemisAutoConfigurationTests { getActiveMQConnectionFactory(getConnectionFactory(context)), "192.168.1.144", 9876)); } - @Test - @Deprecated - void nativeConnectionFactoryCustomHost() { - this.contextRunner.withUserConfiguration(EmptyConfiguration.class) - .withPropertyValues("spring.artemis.mode:native", "spring.artemis.host:192.168.1.144", - "spring.artemis.port:9876") - .run((context) -> assertNettyConnectionFactory( - getActiveMQConnectionFactory(getConnectionFactory(context)), "192.168.1.144", 9876)); - } - - @Test - @Deprecated - void nativeConnectionFactoryCustomBrokerUrlAndHost() { - this.contextRunner.withUserConfiguration(EmptyConfiguration.class) - .withPropertyValues("spring.artemis.mode:native", "spring.artemis.host:192.168.1.144", - "spring.artemis.port:9876", "spring.artemis.broker-url=tcp://192.168.1.221:6543") - .run((context) -> assertNettyConnectionFactory( - getActiveMQConnectionFactory(getConnectionFactory(context)), "192.168.1.221", 6543)); - } - @Test void nativeConnectionFactoryCredentials() { this.contextRunner.withUserConfiguration(EmptyConfiguration.class) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheStandaloneIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheStandaloneIntegrationTests.java index 2fc1dc8fdce..66b0a0e11b6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheStandaloneIntegrationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheStandaloneIntegrationTests.java @@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Dave Syer */ @DirtiesContext -@SpringBootTest(webEnvironment = WebEnvironment.NONE, properties = { "env.FOO=There", "foo=World" }) +@SpringBootTest(webEnvironment = WebEnvironment.NONE) class MustacheStandaloneIntegrationTests { @Autowired @@ -49,22 +49,6 @@ class MustacheStandaloneIntegrationTests { .isEqualTo("Hello: World"); } - @Test - void environmentCollectorCompoundKey() { - assertThat(this.compiler.compile("Hello: {{env.foo}}").execute(new Object())).isEqualTo("Hello: There"); - } - - @Test - void environmentCollectorCompoundKeyStandard() { - assertThat(this.compiler.standardsMode(true).compile("Hello: {{env.foo}}").execute(new Object())) - .isEqualTo("Hello: There"); - } - - @Test - void environmentCollectorSimpleKey() { - assertThat(this.compiler.compile("Hello: {{foo}}").execute(new Object())).isEqualTo("Hello: World"); - } - @Configuration(proxyBeanMethods = false) @Import({ MustacheAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class }) static class Application { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryBuilderTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryBuilderTests.java deleted file mode 100644 index 61af160d595..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryBuilderTests.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.autoconfigure.r2dbc; - -import io.r2dbc.spi.ConnectionFactoryOptions; -import io.r2dbc.spi.Option; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryOptionsInitializer.ConnectionFactoryBeanCreationException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.assertj.core.api.Assertions.fail; - -/** - * Tests for {@link ConnectionFactoryBuilder}. - * - * @author Mark Paluch - * @author Tadaya Tsuyukubo - * @author Stephane Nicoll - */ -@Deprecated -class ConnectionFactoryBuilderTests { - - @Test - void propertiesWithoutUrlAndNoAvailableEmbeddedConnectionShouldFail() { - R2dbcProperties properties = new R2dbcProperties(); - assertThatThrownBy(() -> ConnectionFactoryBuilder.of(properties, () -> EmbeddedDatabaseConnection.NONE)) - .isInstanceOf(ConnectionFactoryBeanCreationException.class) - .hasMessage("Failed to determine a suitable R2DBC Connection URL"); - } - - @Test - void connectionFactoryBeanCreationProvidesConnectionAndProperties() { - R2dbcProperties properties = new R2dbcProperties(); - try { - ConnectionFactoryBuilder.of(properties, () -> EmbeddedDatabaseConnection.NONE); - fail("Should have thrown a " + ConnectionFactoryBeanCreationException.class.getName()); - } - catch (ConnectionFactoryBeanCreationException ex) { - assertThat(ex.getEmbeddedDatabaseConnection()) - .isEqualTo(org.springframework.boot.r2dbc.EmbeddedDatabaseConnection.NONE); - assertThat(ex.getProperties()).isSameAs(properties); - } - } - - @Test - void regularConnectionIsConfiguredAutomaticallyWithUrl() { - R2dbcProperties properties = new R2dbcProperties(); - properties.setUrl("r2dbc:simple://:pool:"); - ConnectionFactoryOptions options = ConnectionFactoryBuilder - .of(properties, () -> EmbeddedDatabaseConnection.NONE).buildOptions(); - assertThat(options.hasOption(ConnectionFactoryOptions.USER)).isFalse(); - assertThat(options.hasOption(ConnectionFactoryOptions.PASSWORD)).isFalse(); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.DRIVER)).isEqualTo("simple"); - } - - @Test - void regularConnectionShouldInitializeUrlOptions() { - R2dbcProperties properties = new R2dbcProperties(); - properties.setUrl("r2dbc:simple:proto://user:password@myhost:4711/mydatabase"); - ConnectionFactoryOptions options = buildOptions(properties); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.DRIVER)).isEqualTo("simple"); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.PROTOCOL)).isEqualTo("proto"); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.USER)).isEqualTo("user"); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.PASSWORD)).isEqualTo("password"); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.HOST)).isEqualTo("myhost"); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.PORT)).isEqualTo(4711); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isEqualTo("mydatabase"); - } - - @Test - void regularConnectionShouldUseUrlOptionsOverProperties() { - R2dbcProperties properties = new R2dbcProperties(); - properties.setUrl("r2dbc:simple://user:password@myhost/mydatabase"); - properties.setUsername("another-user"); - properties.setPassword("another-password"); - properties.setName("another-database"); - ConnectionFactoryOptions options = buildOptions(properties); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.USER)).isEqualTo("user"); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.PASSWORD)).isEqualTo("password"); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isEqualTo("mydatabase"); - } - - @Test - void regularConnectionShouldUseDatabaseNameOverRandomName() { - R2dbcProperties properties = new R2dbcProperties(); - properties.setUrl("r2dbc:simple://user:password@myhost/mydatabase"); - properties.setGenerateUniqueName(true); - ConnectionFactoryOptions options = buildOptions(properties); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isEqualTo("mydatabase"); - } - - @Test - void regularConnectionWithRandomNameShouldIgnoreNameFromProperties() { - R2dbcProperties properties = new R2dbcProperties(); - properties.setUrl("r2dbc:h2://host"); - properties.setName("test-database"); - properties.setGenerateUniqueName(true); - ConnectionFactoryOptions options = buildOptions(properties); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isNotEqualTo("test-database") - .isNotEmpty(); - } - - @Test - void regularConnectionShouldSetCustomDriverProperties() { - R2dbcProperties properties = new R2dbcProperties(); - properties.setUrl("r2dbc:simple://user:password@myhost"); - properties.getProperties().put("simpleOne", "one"); - properties.getProperties().put("simpleTwo", "two"); - ConnectionFactoryOptions options = buildOptions(properties); - assertThat(options.getRequiredValue(Option.valueOf("simpleOne"))).isEqualTo("one"); - assertThat(options.getRequiredValue(Option.valueOf("simpleTwo"))).isEqualTo("two"); - } - - @Test - void regularConnectionShouldUseBuilderValuesOverProperties() { - R2dbcProperties properties = new R2dbcProperties(); - properties.setUrl("r2dbc:simple://user:password@myhost:47111/mydatabase"); - properties.setUsername("user"); - properties.setPassword("password"); - ConnectionFactoryOptions options = ConnectionFactoryBuilder - .of(properties, () -> EmbeddedDatabaseConnection.NONE).username("another-user") - .password("another-password").hostname("another-host").port(1234).database("another-database") - .buildOptions(); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.USER)).isEqualTo("another-user"); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.PASSWORD)).isEqualTo("another-password"); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.HOST)).isEqualTo("another-host"); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.PORT)).isEqualTo(1234); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isEqualTo("another-database"); - } - - @Test - void embeddedConnectionIsConfiguredAutomaticallyWithoutUrl() { - ConnectionFactoryOptions options = ConnectionFactoryBuilder - .of(new R2dbcProperties(), () -> EmbeddedDatabaseConnection.H2).buildOptions(); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.USER)).isEqualTo("sa"); - assertThat(options.hasOption(ConnectionFactoryOptions.PASSWORD)).isFalse(); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.DRIVER)).isEqualTo("h2"); - } - - @Test - void embeddedConnectionWithUsernameAndPassword() { - R2dbcProperties properties = new R2dbcProperties(); - properties.setUsername("embedded"); - properties.setPassword("secret"); - ConnectionFactoryOptions options = ConnectionFactoryBuilder.of(properties, () -> EmbeddedDatabaseConnection.H2) - .buildOptions(); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.USER)).isEqualTo("embedded"); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.PASSWORD)).isEqualTo("secret"); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.DRIVER)).isEqualTo("h2"); - } - - @Test - void embeddedConnectionUseDefaultDatabaseName() { - ConnectionFactoryOptions options = ConnectionFactoryBuilder - .of(new R2dbcProperties(), () -> EmbeddedDatabaseConnection.H2).buildOptions(); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isEqualTo("testdb"); - } - - @Test - void embeddedConnectionUseNameIfSet() { - R2dbcProperties properties = new R2dbcProperties(); - properties.setName("test-database"); - ConnectionFactoryOptions options = buildOptions(properties); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isEqualTo("test-database"); - } - - @Test - void embeddedConnectionCanGenerateUniqueDatabaseName() { - R2dbcProperties firstProperties = new R2dbcProperties(); - firstProperties.setGenerateUniqueName(true); - ConnectionFactoryOptions options11 = buildOptions(firstProperties); - ConnectionFactoryOptions options12 = buildOptions(firstProperties); - assertThat(options11.getRequiredValue(ConnectionFactoryOptions.DATABASE)) - .isEqualTo(options12.getRequiredValue(ConnectionFactoryOptions.DATABASE)); - R2dbcProperties secondProperties = new R2dbcProperties(); - firstProperties.setGenerateUniqueName(true); - ConnectionFactoryOptions options21 = buildOptions(secondProperties); - ConnectionFactoryOptions options22 = buildOptions(secondProperties); - assertThat(options21.getRequiredValue(ConnectionFactoryOptions.DATABASE)) - .isEqualTo(options22.getRequiredValue(ConnectionFactoryOptions.DATABASE)); - assertThat(options11.getRequiredValue(ConnectionFactoryOptions.DATABASE)) - .isNotEqualTo(options21.getRequiredValue(ConnectionFactoryOptions.DATABASE)); - } - - @Test - void embeddedConnectionShouldIgnoreNameIfRandomNameIsRequired() { - R2dbcProperties properties = new R2dbcProperties(); - properties.setGenerateUniqueName(true); - properties.setName("test-database"); - ConnectionFactoryOptions options = buildOptions(properties); - assertThat(options.getRequiredValue(ConnectionFactoryOptions.DATABASE)).isNotEqualTo("test-database"); - } - - private ConnectionFactoryOptions buildOptions(R2dbcProperties properties) { - return ConnectionFactoryBuilder.of(properties, () -> EmbeddedDatabaseConnection.H2).buildOptions(); - } - -} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/MavenPluginAction.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/MavenPluginAction.java deleted file mode 100644 index 49001e0d4c4..00000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/MavenPluginAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.gradle.plugin; - -import org.gradle.api.Action; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; -import org.gradle.api.tasks.Upload; - -/** - * {@link Action} that is executed in response to the - * {@link org.gradle.api.plugins.MavenPlugin} being applied. - * - * @author Andy Wilkinson - * @deprecated since 2.5.0 in favor of using the {@link MavenPublishPlugin} - */ -@Deprecated -final class MavenPluginAction implements PluginApplicationAction { - - private final String uploadTaskName; - - MavenPluginAction(String uploadTaskName) { - this.uploadTaskName = uploadTaskName; - } - - @Override - public Class> getPluginClass() { - return org.gradle.api.plugins.MavenPlugin.class; - } - - @Override - public void execute(Project project) { - project.getTasks().withType(Upload.class, (upload) -> { - if (this.uploadTaskName.equals(upload.getName())) { - project.afterEvaluate((evaluated) -> clearConfigurationMappings(upload)); - } - }); - } - - private void clearConfigurationMappings(Upload upload) { - upload.getRepositories().withType(org.gradle.api.artifacts.maven.MavenResolver.class, - (resolver) -> resolver.getPom().getScopeMappings().getMappings().clear()); - } - -} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java index 015d5ac46e5..68f08b6fda2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-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. @@ -117,10 +117,9 @@ public class SpringBootPlugin implements Plugin { private void registerPluginActions(Project project, Configuration bootArchives) { SinglePublishedArtifact singlePublishedArtifact = new SinglePublishedArtifact(bootArchives.getArtifacts()); - @SuppressWarnings("deprecation") List actions = Arrays.asList(new JavaPluginAction(singlePublishedArtifact), - new WarPluginAction(singlePublishedArtifact), new MavenPluginAction(bootArchives.getUploadTaskName()), - new DependencyManagementPluginAction(), new ApplicationPluginAction(), new KotlinPluginAction()); + new WarPluginAction(singlePublishedArtifact), new DependencyManagementPluginAction(), + new ApplicationPluginAction(), new KotlinPluginAction()); for (PluginApplicationAction action : actions) { withPluginClassOfAction(action, (pluginClass) -> project.getPlugins().withType(pluginClass, (plugin) -> action.execute(project))); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImage.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImage.java index db58d4b0727..1eda9ea38ba 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImage.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImage.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-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. @@ -126,17 +126,6 @@ public class BootBuildImage extends DefaultTask { return this.archiveFile; } - /** - * Returns the property for the archive file from which the image will be built. - * @return the archive file property - * @deprecated since 2.5.0 for removal in 2.7.0 in favor of {@link #getArchiveFile()} - */ - @Deprecated - @Input - public RegularFileProperty getJar() { - return this.archiveFile; - } - /** * Returns the target Java version of the project (e.g. as provided by the * {@code targetCompatibility} build property). diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MavenPluginActionIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MavenPluginActionIntegrationTests.java deleted file mode 100644 index 3c8fc1279b5..00000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MavenPluginActionIntegrationTests.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2012-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. - */ - -package org.springframework.boot.gradle.plugin; - -import org.junit.jupiter.api.TestTemplate; -import org.junit.jupiter.api.condition.DisabledForJreRange; -import org.junit.jupiter.api.condition.JRE; - -import org.springframework.boot.gradle.junit.GradleCompatibility; -import org.springframework.boot.testsupport.gradle.testkit.GradleBuild; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Integration tests for {@link MavenPluginAction}. - * - * @author Andy Wilkinson - */ -@DisabledForJreRange(min = JRE.JAVA_16) -@GradleCompatibility(versionsLessThan = "7.0-milestone-1") -class MavenPluginActionIntegrationTests { - - GradleBuild gradleBuild; - - @TestTemplate - void clearsConf2ScopeMappingsOfUploadBootArchivesTask() { - assertThat(this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("6.0.0").build("conf2ScopeMappings") - .getOutput()).contains("Conf2ScopeMappings = 0"); - } - -} diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/r2dbc/ConnectionFactoryBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/r2dbc/ConnectionFactoryBuilder.java index 58f17e48dac..1125d53d3b0 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/r2dbc/ConnectionFactoryBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/r2dbc/ConnectionFactoryBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-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. @@ -86,20 +86,6 @@ public final class ConnectionFactoryBuilder { return new ConnectionFactoryBuilder(options); } - /** - * Initialize a new {@link ConnectionFactoryBuilder} derived from the options of the - * specified {@code connectionFactory}. - * @param connectionFactory the connection factory whose options are to be used to - * initialize the builder - * @return a new builder initialized with the options from the connection factory - * @deprecated since 2.5.1 for removal in 2.7.0 in favor of - * {@link #derivedFrom(ConnectionFactory)} - */ - @Deprecated - public static ConnectionFactoryBuilder derivefrom(ConnectionFactory connectionFactory) { - return derivedFrom(connectionFactory); - } - /** * Initialize a new {@link ConnectionFactoryBuilder} derived from the options of the * specified {@code connectionFactory}.