From de3b9a4910e5c8648059d30b3d5275e760bab1b3 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 19 Jan 2022 14:04:44 +0000 Subject: [PATCH] Remove code deprecated for removal in 2.x Closes gh-29482 --- .../OnEndpointElementCondition.java | 14 +- .../expose/IncludeExcludeEndpointFilter.java | 69 +- ...ConfigurationPropertiesReportEndpoint.java | 16 +- .../boot/actuate/env/EnvironmentEndpoint.java | 15 +- ...bitListenerContainerFactoryConfigurer.java | 23 +- ...bitListenerContainerFactoryConfigurer.java | 12 +- .../amqp/RabbitTemplateConfigurer.java | 23 +- ...bitListenerContainerFactoryConfigurer.java | 12 +- .../batch/BatchAutoConfiguration.java | 3 +- .../batch/BatchDataSourceInitializer.java | 83 -- ...tiveElasticsearchRestClientProperties.java | 150 -- ...sticsearchRestClientAutoConfiguration.java | 39 +- ...atedElasticsearchRestClientProperties.java | 159 --- ...sticsearchRestClientAutoConfiguration.java | 6 +- ...ElasticsearchRestClientConfigurations.java | 73 +- .../IntegrationAutoConfiguration.java | 6 +- .../IntegrationDataSourceInitializer.java | 74 - .../jdbc/DataSourceAutoConfiguration.java | 7 +- ...DataSourceInitializationConfiguration.java | 200 --- .../jdbc/DataSourceProperties.java | 193 +-- .../ArtemisConnectionFactoryFactory.java | 17 +- .../jms/artemis/ArtemisProperties.java | 43 - .../quartz/QuartzAutoConfiguration.java | 6 +- .../quartz/QuartzDataSourceInitializer.java | 93 -- .../session/JdbcSessionConfiguration.java | 6 +- .../JdbcSessionDataSourceInitializer.java | 74 - .../web/reactive/WebFluxProperties.java | 90 +- ...WebSessionIdResolverAutoConfiguration.java | 30 +- .../AbstractErrorWebExceptionHandler.java | 18 +- .../BatchDataSourceInitializerTests.java | 48 - ...earchRestClientAutoConfigurationTests.java | 86 +- ...earchRestClientAutoConfigurationTests.java | 97 +- .../IntegrationAutoConfigurationTests.java | 27 +- ...IntegrationDataSourceInitializerTests.java | 48 - .../DataSourceAutoConfigurationTests.java | 31 +- ...aSourceInitializationIntegrationTests.java | 440 ------ .../jdbc/DataSourcePropertiesTests.java | 22 +- .../JdbcTemplateAutoConfigurationTests.java | 12 +- .../ArtemisAutoConfigurationTests.java | 20 - .../HibernateJpaAutoConfigurationTests.java | 33 +- .../quartz/QuartzAutoConfigurationTests.java | 27 +- .../QuartzDataSourceInitializerTests.java | 105 -- .../SessionAutoConfigurationJdbcTests.java | 28 +- ...lInitializationAutoConfigurationTests.java | 28 +- .../WebFluxAutoConfigurationTests.java | 20 +- ...JdbcSessionDataSourceInitializerTests.java | 48 - .../classloader/RestartClassLoader.java | 24 +- .../AbstractApplicationContextRunner.java | 66 +- .../runner/ApplicationContextRunner.java | 30 +- .../ReactiveWebApplicationContextRunner.java | 30 +- .../runner/WebApplicationContextRunner.java | 30 +- .../boot/loader/tools/Packager.java | 15 +- .../boot/loader/tools/Repackager.java | 14 +- .../springframework/boot/loader/Launcher.java | 31 +- .../boot/loader/archive/Archive.java | 69 +- .../boot/SpringApplicationRunListener.java | 30 +- .../builder/SpringApplicationBuilder.java | 16 +- .../boot/context/config/ConfigData.java | 13 +- .../context/config/ConfigDataEnvironment.java | 1 - .../ConfigDataEnvironmentContributor.java | 1 - .../ConfigDataEnvironmentPostProcessor.java | 54 +- .../config/ConfigFileApplicationListener.java | 968 ------------- .../UseLegacyConfigProcessingException.java | 94 -- .../context/event/ApplicationReadyEvent.java | 15 +- .../event/ApplicationStartedEvent.java | 16 +- .../jdbc/AbstractDataSourceInitializer.java | 112 -- ...nitializerDatabaseInitializerDetector.java | 46 - .../jdbc/DataSourceInitializationMode.java | 49 - .../logging/log4j2/Log4J2LoggingSystem.java | 14 +- .../SpringPhysicalNamingStrategy.java | 106 -- ...itional-spring-configuration-metadata.json | 6 - .../main/resources/META-INF/spring.factories | 1 - ...ConfigDataEnvironmentContributorTests.java | 9 - ...nfigDataEnvironmentPostProcessorTests.java | 38 +- .../config/ConfigDataEnvironmentTests.java | 10 +- .../boot/context/config/ConfigDataTests.java | 23 +- ...leApplicationListenerLegacyReproTests.java | 182 --- .../ConfigFileApplicationListenerTests.java | 1244 ----------------- ...ationListenerYamlProfileNegationTests.java | 160 --- ...eLegacyConfigProcessingExceptionTests.java | 61 - .../context/config/UseLegacyProcessing.java | 51 - ...itializerDependencyConfigurationTests.java | 97 -- .../SpringPhysicalNamingStrategyTests.java | 80 -- .../orm/jpa/hibernate/TelephoneNumber.java | 39 - 84 files changed, 134 insertions(+), 6385 deletions(-) delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializer.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/DeprecatedReactiveElasticsearchRestClientProperties.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/DeprecatedElasticsearchRestClientProperties.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializer.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializationConfiguration.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializer.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializer.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializerTests.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializerTests.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializationIntegrationTests.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializerTests.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/test/kotlin/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializerTests.java delete mode 100644 spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java delete mode 100644 spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/UseLegacyConfigProcessingException.java delete mode 100644 spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/AbstractDataSourceInitializer.java delete mode 100644 spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/AbstractDataSourceInitializerDatabaseInitializerDetector.java delete mode 100644 spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceInitializationMode.java delete mode 100644 spring-boot-project/spring-boot/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringPhysicalNamingStrategy.java delete mode 100644 spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerLegacyReproTests.java delete mode 100644 spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java delete mode 100644 spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerYamlProfileNegationTests.java delete mode 100644 spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/UseLegacyConfigProcessingExceptionTests.java delete mode 100644 spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/UseLegacyProcessing.java delete mode 100644 spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/AbstractDataSourceInitializerDependencyConfigurationTests.java delete mode 100644 spring-boot-project/spring-boot/src/test/java/org/springframework/boot/orm/jpa/hibernate/SpringPhysicalNamingStrategyTests.java delete mode 100644 spring-boot-project/spring-boot/src/test/java/org/springframework/boot/orm/jpa/hibernate/TelephoneNumber.java diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java index a9b9a3f7dd..e271fdb802 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.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. @@ -78,18 +78,6 @@ public abstract class OnEndpointElementCondition extends SpringBootCondition { * @since 2.6.0 */ protected ConditionOutcome getDefaultOutcome(ConditionContext context, AnnotationAttributes annotationAttributes) { - return getDefaultEndpointsOutcome(context); - } - - /** - * Return the default outcome that should be used. - * @param context the condition context - * @return the default outcome - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link #getDefaultOutcome(ConditionContext, AnnotationAttributes)} - */ - @Deprecated - protected ConditionOutcome getDefaultEndpointsOutcome(ConditionContext context) { boolean match = Boolean .parseBoolean(context.getEnvironment().getProperty(this.prefix + "defaults.enabled", "true")); return new ConditionOutcome(match, ConditionMessage.forCondition(this.annotationType) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/expose/IncludeExcludeEndpointFilter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/expose/IncludeExcludeEndpointFilter.java index fa55c55b2b..86752cf4ae 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/expose/IncludeExcludeEndpointFilter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/expose/IncludeExcludeEndpointFilter.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. @@ -50,23 +50,6 @@ public class IncludeExcludeEndpointFilter> implem private final EndpointPatterns exclude; - /** - * Create a new {@link IncludeExcludeEndpointFilter} with include/exclude rules bound - * from the {@link Environment}. - * @param endpointType the endpoint type that should be considered (other types always - * match) - * @param environment the environment containing the properties - * @param prefix the property prefix to bind - * @param defaultIncludes the default {@code includes} to use when none are specified. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link #IncludeExcludeEndpointFilter(Class, Environment, String, String[])} - */ - @Deprecated - public IncludeExcludeEndpointFilter(Class endpointType, Environment environment, String prefix, - DefaultIncludes defaultIncludes) { - this(endpointType, environment, prefix, DefaultIncludes.patterns(defaultIncludes)); - } - /** * Create a new {@link IncludeExcludeEndpointFilter} with include/exclude rules bound * from the {@link Environment}. @@ -95,23 +78,6 @@ public class IncludeExcludeEndpointFilter> implem this(endpointType, include, exclude, new EndpointPatterns(defaultIncludes)); } - /** - * Create a new {@link IncludeExcludeEndpointFilter} with specific include/exclude - * rules. - * @param endpointType the endpoint type that should be considered (other types always - * match) - * @param include the include patterns - * @param exclude the exclude patterns - * @param defaultIncludes the default {@code includes} to use when none are specified. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link #IncludeExcludeEndpointFilter(Class, Environment, String, String[])} - */ - @Deprecated - public IncludeExcludeEndpointFilter(Class endpointType, Collection include, Collection exclude, - DefaultIncludes defaultIncludes) { - this(endpointType, include, exclude, DefaultIncludes.patterns(defaultIncludes)); - } - private IncludeExcludeEndpointFilter(Class endpointType, Environment environment, String prefix, EndpointPatterns defaultIncludes) { Assert.notNull(endpointType, "EndpointType must not be null"); @@ -172,35 +138,6 @@ public class IncludeExcludeEndpointFilter> implem return this.exclude.matches(endpointId); } - /** - * Default include patterns that can be used. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of {@link EndpointExposure}. - */ - @Deprecated - public enum DefaultIncludes { - - /** - * The default set of include patterns used for JMX. - */ - JMX("*"), - - /** - * The default set of include patterns used for web. - */ - WEB("health"); - - private final EndpointPatterns patterns; - - DefaultIncludes(String... patterns) { - this.patterns = new EndpointPatterns(patterns); - } - - static EndpointPatterns patterns(DefaultIncludes defaultIncludes) { - return (defaultIncludes != null) ? defaultIncludes.patterns : (EndpointPatterns) null; - } - - } - /** * A set of endpoint patterns used to match IDs. */ @@ -241,10 +178,6 @@ public class IncludeExcludeEndpointFilter> implem return this.matchesAll || this.endpointIds.contains(endpointId); } - static EndpointPatterns forExposure(EndpointExposure exposure) { - return (exposure != null) ? new EndpointPatterns(exposure.getDefaultIncludes()) : null; - } - } } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java index 99ff2500b0..6dcb6ba4d9 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.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. @@ -159,24 +159,10 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext JsonMapper.Builder builder = JsonMapper.builder(); configureJsonMapper(builder); this.objectMapper = builder.build(); - configureObjectMapper(this.objectMapper); } return this.objectMapper; } - /** - * Configure Jackson's {@link ObjectMapper} to be used to serialize the - * {@link ConfigurationProperties @ConfigurationProperties} objects into a {@link Map} - * structure. - * @param mapper the object mapper - * @deprecated since 2.6 for removal in 2.8 in favor of - * {@link #configureJsonMapper(com.fasterxml.jackson.databind.json.JsonMapper.Builder)} - */ - @Deprecated - protected void configureObjectMapper(ObjectMapper mapper) { - - } - /** * Configure Jackson's {@link JsonMapper} to be used to serialize the * {@link ConfigurationProperties @ConfigurationProperties} objects into a {@link Map} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java index 79644791c2..04c9928fd6 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.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. @@ -193,19 +193,6 @@ public class EnvironmentEndpoint { } } - /** - * Apply sanitization to the given name and value. - * @param key the name to sanitize - * @param value the value to sanitize - * @return the sanitized value - * @deprecated since 2.6.0 for removal in 2.8.0 as sanitization should be internal to - * the class - */ - @Deprecated - public Object sanitize(String key, Object value) { - return this.sanitizer.sanitize(key, value); - } - private Object sanitize(PropertySource source, String name, Object value) { return this.sanitizer.sanitize(new SanitizableData(source, name, value)); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/AbstractRabbitListenerContainerFactoryConfigurer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/AbstractRabbitListenerContainerFactoryConfigurer.java index 9877d08b95..9e25b3a1bc 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/AbstractRabbitListenerContainerFactoryConfigurer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/AbstractRabbitListenerContainerFactoryConfigurer.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. @@ -47,16 +47,6 @@ public abstract class AbstractRabbitListenerContainerFactoryConfigurer { - /** - * Creates a new configurer. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link #DirectRabbitListenerContainerFactoryConfigurer(RabbitProperties)} - */ - @Deprecated - public DirectRabbitListenerContainerFactoryConfigurer() { - super(); - } - /** * Creates a new configurer that will use the given {@code rabbitProperties}. * @param rabbitProperties properties to use diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitTemplateConfigurer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitTemplateConfigurer.java index f775b5d021..58417be263 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitTemplateConfigurer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitTemplateConfigurer.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. @@ -39,16 +39,6 @@ public class RabbitTemplateConfigurer { private RabbitProperties rabbitProperties; - /** - * Creates a new configurer. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link #RabbitTemplateConfigurer(RabbitProperties)} - */ - @Deprecated - public RabbitTemplateConfigurer() { - - } - /** * Creates a new configurer that will use the given {@code rabbitProperties}. * @param rabbitProperties properties to use @@ -78,17 +68,6 @@ public class RabbitTemplateConfigurer { this.retryTemplateCustomizers = retryTemplateCustomizers; } - /** - * Set the {@link RabbitProperties} to use. - * @param rabbitProperties the {@link RabbitProperties} - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link #RabbitTemplateConfigurer(RabbitProperties)} - */ - @Deprecated - protected void setRabbitProperties(RabbitProperties rabbitProperties) { - this.rabbitProperties = rabbitProperties; - } - protected final RabbitProperties getRabbitProperties() { return this.rabbitProperties; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java index 7406a1b5e6..b66a17c96c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.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. @@ -31,16 +31,6 @@ import org.springframework.boot.context.properties.PropertyMapper; public final class SimpleRabbitListenerContainerFactoryConfigurer extends AbstractRabbitListenerContainerFactoryConfigurer { - /** - * Creates a new configurer. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link #SimpleRabbitListenerContainerFactoryConfigurer(RabbitProperties)} - */ - @Deprecated - public SimpleRabbitListenerContainerFactoryConfigurer() { - super(); - } - /** * Creates a new configurer that will use the given {@code rabbitProperties}. * @param rabbitProperties properties to use diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java index f3a6253a80..c3e22bb919 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java @@ -108,8 +108,7 @@ public class BatchAutoConfiguration { static class DataSourceInitializerConfiguration { @Bean - @SuppressWarnings("deprecation") - @ConditionalOnMissingBean({ BatchDataSourceScriptDatabaseInitializer.class, BatchDataSourceInitializer.class }) + @ConditionalOnMissingBean(BatchDataSourceScriptDatabaseInitializer.class) BatchDataSourceScriptDatabaseInitializer batchDataSourceInitializer(DataSource dataSource, @BatchDataSource ObjectProvider batchDataSource, BatchProperties properties) { return new BatchDataSourceScriptDatabaseInitializer(batchDataSource.getIfAvailable(() -> dataSource), diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializer.java deleted file mode 100644 index 27cd382507..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializer.java +++ /dev/null @@ -1,83 +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.batch; - -import javax.sql.DataSource; - -import org.springframework.boot.autoconfigure.batch.BatchProperties.Jdbc; -import org.springframework.boot.sql.init.DatabaseInitializationMode; -import org.springframework.core.io.ResourceLoader; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; - -/** - * Initialize the Spring Batch schema (ignoring errors, so it should be idempotent). - * - * @author Dave Syer - * @author Vedran Pavic - * @since 1.0.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link BatchDataSourceScriptDatabaseInitializer} - */ -@Deprecated -public class BatchDataSourceInitializer extends org.springframework.boot.jdbc.AbstractDataSourceInitializer { - - private final Jdbc jdbcProperties; - - public BatchDataSourceInitializer(DataSource dataSource, ResourceLoader resourceLoader, - BatchProperties properties) { - super(dataSource, resourceLoader); - Assert.notNull(properties, "BatchProperties must not be null"); - this.jdbcProperties = properties.getJdbc(); - } - - @Override - protected org.springframework.boot.jdbc.DataSourceInitializationMode getMode() { - DatabaseInitializationMode mode = this.jdbcProperties.getInitializeSchema(); - switch (mode) { - case ALWAYS: - return org.springframework.boot.jdbc.DataSourceInitializationMode.ALWAYS; - case EMBEDDED: - return org.springframework.boot.jdbc.DataSourceInitializationMode.EMBEDDED; - case NEVER: - default: - return org.springframework.boot.jdbc.DataSourceInitializationMode.NEVER; - } - } - - @Override - protected String getSchemaLocation() { - return this.jdbcProperties.getSchema(); - } - - @Override - protected String getDatabaseName() { - String platform = this.jdbcProperties.getPlatform(); - if (StringUtils.hasText(platform)) { - return platform; - } - String databaseName = super.getDatabaseName(); - if ("oracle".equals(databaseName)) { - return "oracle10g"; - } - if ("mariadb".equals(databaseName)) { - return "mysql"; - } - return databaseName; - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/DeprecatedReactiveElasticsearchRestClientProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/DeprecatedReactiveElasticsearchRestClientProperties.java deleted file mode 100644 index cb879c531a..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/DeprecatedReactiveElasticsearchRestClientProperties.java +++ /dev/null @@ -1,150 +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.elasticsearch; - -import java.time.Duration; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; -import org.springframework.util.unit.DataSize; - -/** - * Deprecated configuration properties for Elasticsearch Reactive REST clients. - * - * @author Brian Clozel - * @deprecated since 2.6.0 for removal in 2.8.0 - */ -@Deprecated -@ConfigurationProperties(prefix = "spring.data.elasticsearch.client.reactive") -class DeprecatedReactiveElasticsearchRestClientProperties { - - /** - * Comma-separated list of the Elasticsearch endpoints to connect to. - */ - private List endpoints = new ArrayList<>(Collections.singletonList("localhost:9200")); - - /** - * Whether the client should use SSL to connect to the endpoints. - */ - private boolean useSsl = false; - - /** - * Credentials username. - */ - private String username; - - /** - * Credentials password. - */ - private String password; - - /** - * Connection timeout. - */ - private Duration connectionTimeout; - - /** - * Read and Write Socket timeout. - */ - private Duration socketTimeout; - - /** - * Limit on the number of bytes that can be buffered whenever the input stream needs - * to be aggregated. - */ - private DataSize maxInMemorySize; - - private boolean customized = false; - - @DeprecatedConfigurationProperty(replacement = "spring.elasticsearch.uris") - public List getEndpoints() { - return this.endpoints; - } - - public void setEndpoints(List endpoints) { - this.customized = true; - this.endpoints = endpoints; - } - - @DeprecatedConfigurationProperty(reason = "Use of SSL should be indicated through an https URI scheme") - public boolean isUseSsl() { - return this.useSsl; - } - - public void setUseSsl(boolean useSsl) { - this.customized = true; - this.useSsl = useSsl; - } - - @DeprecatedConfigurationProperty(replacement = "spring.elasticsearch.username") - public String getUsername() { - return this.username; - } - - public void setUsername(String username) { - this.customized = true; - this.username = username; - } - - @DeprecatedConfigurationProperty(replacement = "spring.elasticsearch.password") - public String getPassword() { - return this.password; - } - - public void setPassword(String password) { - this.customized = true; - this.password = password; - } - - @DeprecatedConfigurationProperty(replacement = "spring.elasticsearch.connection-timeout") - public Duration getConnectionTimeout() { - return this.connectionTimeout; - } - - public void setConnectionTimeout(Duration connectionTimeout) { - this.customized = true; - this.connectionTimeout = connectionTimeout; - } - - @DeprecatedConfigurationProperty(replacement = "spring.elasticsearch.socket-timeout") - public Duration getSocketTimeout() { - return this.socketTimeout; - } - - public void setSocketTimeout(Duration socketTimeout) { - this.customized = true; - this.socketTimeout = socketTimeout; - } - - @DeprecatedConfigurationProperty(replacement = "spring.elasticsearch.webclient.max-in-memory-size") - public DataSize getMaxInMemorySize() { - return this.maxInMemorySize; - } - - public void setMaxInMemorySize(DataSize maxInMemorySize) { - this.customized = true; - this.maxInMemorySize = maxInMemorySize; - } - - boolean isCustomized() { - return this.customized; - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRestClientAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRestClientAutoConfiguration.java index 795f76585c..15f9d1e916 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRestClientAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRestClientAutoConfiguration.java @@ -49,19 +49,16 @@ import org.springframework.web.reactive.function.client.WebClient; * @author Brian Clozel * @since 2.2.0 */ -@SuppressWarnings("deprecation") @Configuration(proxyBeanMethods = false) @ConditionalOnClass({ ReactiveRestClients.class, WebClient.class, HttpClient.class }) -@EnableConfigurationProperties({ ElasticsearchProperties.class, ReactiveElasticsearchRestClientProperties.class, - DeprecatedReactiveElasticsearchRestClientProperties.class }) +@EnableConfigurationProperties({ ElasticsearchProperties.class, ReactiveElasticsearchRestClientProperties.class }) public class ReactiveElasticsearchRestClientAutoConfiguration { private final ConsolidatedProperties properties; ReactiveElasticsearchRestClientAutoConfiguration(ElasticsearchProperties properties, - ReactiveElasticsearchRestClientProperties restClientProperties, - DeprecatedReactiveElasticsearchRestClientProperties reactiveProperties) { - this.properties = new ConsolidatedProperties(properties, restClientProperties, reactiveProperties); + ReactiveElasticsearchRestClientProperties restClientProperties) { + this.properties = new ConsolidatedProperties(properties, restClientProperties); } @Bean @@ -103,24 +100,17 @@ public class ReactiveElasticsearchRestClientAutoConfiguration { private final ReactiveElasticsearchRestClientProperties restClientProperties; - private final DeprecatedReactiveElasticsearchRestClientProperties deprecatedProperties; - private final List uris; private ConsolidatedProperties(ElasticsearchProperties properties, - ReactiveElasticsearchRestClientProperties restClientProperties, - DeprecatedReactiveElasticsearchRestClientProperties deprecatedreactiveProperties) { + ReactiveElasticsearchRestClientProperties restClientProperties) { this.properties = properties; this.restClientProperties = restClientProperties; - this.deprecatedProperties = deprecatedreactiveProperties; this.uris = properties.getUris().stream().map((s) -> s.startsWith("http") ? s : "http://" + s) .map(URI::create).collect(Collectors.toList()); } private List getEndpoints() { - if (this.deprecatedProperties.isCustomized()) { - return this.deprecatedProperties.getEndpoints(); - } return this.uris.stream().map(this::getEndpoint).collect(Collectors.toList()); } @@ -129,9 +119,6 @@ public class ReactiveElasticsearchRestClientAutoConfiguration { } private Credentials getCredentials() { - if (this.deprecatedProperties.isCustomized()) { - return Credentials.from(this.deprecatedProperties); - } Credentials propertyCredentials = Credentials.from(this.properties); Credentials uriCredentials = Credentials.from(this.uris); if (uriCredentials == null) { @@ -144,31 +131,25 @@ public class ReactiveElasticsearchRestClientAutoConfiguration { } private Duration getConnectionTimeout() { - return this.deprecatedProperties.isCustomized() ? this.deprecatedProperties.getConnectionTimeout() - : this.properties.getConnectionTimeout(); + return this.properties.getConnectionTimeout(); } private Duration getSocketTimeout() { - return this.deprecatedProperties.isCustomized() ? this.deprecatedProperties.getSocketTimeout() - : this.properties.getSocketTimeout(); + return this.properties.getSocketTimeout(); } private boolean isUseSsl() { - if (this.deprecatedProperties.isCustomized()) { - return this.deprecatedProperties.isUseSsl(); - } Set schemes = this.uris.stream().map(URI::getScheme).collect(Collectors.toSet()); Assert.isTrue(schemes.size() == 1, "Configured Elasticsearch URIs have varying schemes"); return schemes.iterator().next().equals("https"); } private DataSize getMaxInMemorySize() { - return this.deprecatedProperties.isCustomized() ? this.deprecatedProperties.getMaxInMemorySize() - : this.restClientProperties.getMaxInMemorySize(); + return this.restClientProperties.getMaxInMemorySize(); } private String getPathPrefix() { - return this.deprecatedProperties.isCustomized() ? null : this.properties.getPathPrefix(); + return this.properties.getPathPrefix(); } private static final class Credentials { @@ -207,10 +188,6 @@ public class ReactiveElasticsearchRestClientAutoConfiguration { return getCredentials(properties.getUsername(), properties.getPassword()); } - private static Credentials from(DeprecatedReactiveElasticsearchRestClientProperties properties) { - return getCredentials(properties.getUsername(), properties.getPassword()); - } - private static Credentials getCredentials(String username, String password) { if (username == null && password == null) { return null; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/DeprecatedElasticsearchRestClientProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/DeprecatedElasticsearchRestClientProperties.java deleted file mode 100644 index 373bc00c60..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/DeprecatedElasticsearchRestClientProperties.java +++ /dev/null @@ -1,159 +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.elasticsearch; - -import java.time.Duration; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; - -/** - * Deprecated configuration properties for Elasticsearch REST clients. - * - * @author Brian Clozel - * @deprecated since 2.6.0 for removal in 2.8.0. - */ -@ConfigurationProperties(prefix = "spring.elasticsearch.rest") -@Deprecated -class DeprecatedElasticsearchRestClientProperties { - - /** - * Comma-separated list of the Elasticsearch instances to use. - */ - private List uris = new ArrayList<>(Collections.singletonList("http://localhost:9200")); - - /** - * Credentials username. - */ - private String username; - - /** - * Credentials password. - */ - private String password; - - /** - * Connection timeout. - */ - private Duration connectionTimeout = Duration.ofSeconds(1); - - /** - * Read timeout. - */ - private Duration readTimeout = Duration.ofSeconds(30); - - private final Sniffer sniffer = new Sniffer(); - - private boolean customized = false; - - @DeprecatedConfigurationProperty(replacement = "spring.elasticsearch.uris") - public List getUris() { - return this.uris; - } - - public void setUris(List uris) { - this.customized = true; - this.uris = uris; - } - - @DeprecatedConfigurationProperty(replacement = "spring.elasticsearch.username") - public String getUsername() { - return this.username; - } - - public void setUsername(String username) { - this.customized = true; - this.username = username; - } - - @DeprecatedConfigurationProperty(replacement = "spring.elasticsearch.password") - public String getPassword() { - return this.password; - } - - public void setPassword(String password) { - this.customized = true; - this.password = password; - } - - @DeprecatedConfigurationProperty(replacement = "spring.elasticsearch.connection-timeout") - public Duration getConnectionTimeout() { - return this.connectionTimeout; - } - - public void setConnectionTimeout(Duration connectionTimeout) { - this.customized = true; - this.connectionTimeout = connectionTimeout; - } - - @DeprecatedConfigurationProperty(replacement = "spring.elasticsearch.socket-timeout") - public Duration getReadTimeout() { - return this.readTimeout; - } - - public void setReadTimeout(Duration readTimeout) { - this.customized = true; - this.readTimeout = readTimeout; - } - - boolean isCustomized() { - return this.customized; - } - - public Sniffer getSniffer() { - return this.sniffer; - } - - @Deprecated - class Sniffer { - - /** - * Interval between consecutive ordinary sniff executions. - */ - private Duration interval = Duration.ofMinutes(5); - - /** - * Delay of a sniff execution scheduled after a failure. - */ - private Duration delayAfterFailure = Duration.ofMinutes(1); - - @DeprecatedConfigurationProperty(replacement = "spring.elasticsearch.restclient.sniffer.interval") - public Duration getInterval() { - return this.interval; - } - - public void setInterval(Duration interval) { - DeprecatedElasticsearchRestClientProperties.this.customized = true; - this.interval = interval; - } - - @DeprecatedConfigurationProperty(replacement = "spring.elasticsearch.restclient.sniffer.delay-after-failure") - public Duration getDelayAfterFailure() { - return this.delayAfterFailure; - } - - public void setDelayAfterFailure(Duration delayAfterFailure) { - DeprecatedElasticsearchRestClientProperties.this.customized = true; - this.delayAfterFailure = delayAfterFailure; - } - - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfiguration.java index 6064f0f332..2cb0ede158 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfiguration.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. @@ -34,11 +34,9 @@ import org.springframework.context.annotation.Import; * @author Stephane Nicoll * @since 2.1.0 */ -@SuppressWarnings("deprecation") @Configuration(proxyBeanMethods = false) @ConditionalOnClass(RestClientBuilder.class) -@EnableConfigurationProperties({ ElasticsearchProperties.class, ElasticsearchRestClientProperties.class, - DeprecatedElasticsearchRestClientProperties.class }) +@EnableConfigurationProperties({ ElasticsearchProperties.class, ElasticsearchRestClientProperties.class }) @Import({ RestClientBuilderConfiguration.class, RestHighLevelClientConfiguration.class, RestClientSnifferConfiguration.class }) public class ElasticsearchRestClientAutoConfiguration { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientConfigurations.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientConfigurations.java index 9389042190..31776e8096 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientConfigurations.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientConfigurations.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. @@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.elasticsearch; import java.net.URI; import java.net.URISyntaxException; import java.time.Duration; -import java.util.List; import org.apache.http.HttpHost; import org.apache.http.auth.AuthScope; @@ -53,12 +52,10 @@ class ElasticsearchRestClientConfigurations { @ConditionalOnMissingBean(RestClientBuilder.class) static class RestClientBuilderConfiguration { - private final ConsolidatedProperties properties; + private final ElasticsearchProperties properties; - @SuppressWarnings("deprecation") - RestClientBuilderConfiguration(ElasticsearchProperties properties, - DeprecatedElasticsearchRestClientProperties deprecatedProperties) { - this.properties = new ConsolidatedProperties(properties, deprecatedProperties); + RestClientBuilderConfiguration(ElasticsearchProperties properties) { + this.properties = properties; } @Bean @@ -80,7 +77,7 @@ class ElasticsearchRestClientConfigurations { return requestConfigBuilder; }); if (this.properties.getPathPrefix() != null) { - builder.setPathPrefix(this.properties.properties.getPathPrefix()); + builder.setPathPrefix(this.properties.getPathPrefix()); } builderCustomizers.orderedStream().forEach((customizer) -> customizer.customize(builder)); return builder; @@ -133,16 +130,12 @@ class ElasticsearchRestClientConfigurations { @Bean @ConditionalOnMissingBean Sniffer elasticsearchSniffer(org.elasticsearch.client.RestHighLevelClient client, - ElasticsearchRestClientProperties properties, - DeprecatedElasticsearchRestClientProperties deprecatedProperties) { + ElasticsearchRestClientProperties properties) { SnifferBuilder builder = Sniffer.builder(client.getLowLevelClient()); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); - Duration interval = deprecatedProperties.isCustomized() ? deprecatedProperties.getSniffer().getInterval() - : properties.getSniffer().getInterval(); + Duration interval = properties.getSniffer().getInterval(); map.from(interval).asInt(Duration::toMillis).to(builder::setSniffIntervalMillis); - Duration delayAfterFailure = deprecatedProperties.isCustomized() - ? deprecatedProperties.getSniffer().getDelayAfterFailure() - : properties.getSniffer().getDelayAfterFailure(); + Duration delayAfterFailure = properties.getSniffer().getDelayAfterFailure(); map.from(delayAfterFailure).asInt(Duration::toMillis).to(builder::setSniffAfterFailureDelayMillis); return builder.build(); } @@ -153,9 +146,9 @@ class ElasticsearchRestClientConfigurations { private static final PropertyMapper map = PropertyMapper.get(); - private final ConsolidatedProperties properties; + private final ElasticsearchProperties properties; - DefaultRestClientBuilderCustomizer(ConsolidatedProperties properties) { + DefaultRestClientBuilderCustomizer(ElasticsearchProperties properties) { this.properties = properties; } @@ -180,7 +173,7 @@ class ElasticsearchRestClientConfigurations { private static class PropertiesCredentialsProvider extends BasicCredentialsProvider { - PropertiesCredentialsProvider(ConsolidatedProperties properties) { + PropertiesCredentialsProvider(ElasticsearchProperties properties) { if (StringUtils.hasText(properties.getUsername())) { Credentials credentials = new UsernamePasswordCredentials(properties.getUsername(), properties.getPassword()); @@ -221,48 +214,4 @@ class ElasticsearchRestClientConfigurations { } - @SuppressWarnings("deprecation") - private static final class ConsolidatedProperties { - - private final ElasticsearchProperties properties; - - private final DeprecatedElasticsearchRestClientProperties deprecatedProperties; - - private ConsolidatedProperties(ElasticsearchProperties properties, - DeprecatedElasticsearchRestClientProperties deprecatedProperties) { - this.properties = properties; - this.deprecatedProperties = deprecatedProperties; - } - - private List getUris() { - return this.deprecatedProperties.isCustomized() ? this.deprecatedProperties.getUris() - : this.properties.getUris(); - } - - private String getUsername() { - return this.deprecatedProperties.isCustomized() ? this.deprecatedProperties.getUsername() - : this.properties.getUsername(); - } - - private String getPassword() { - return this.deprecatedProperties.isCustomized() ? this.deprecatedProperties.getPassword() - : this.properties.getPassword(); - } - - private Duration getConnectionTimeout() { - return this.deprecatedProperties.isCustomized() ? this.deprecatedProperties.getConnectionTimeout() - : this.properties.getConnectionTimeout(); - } - - private Duration getSocketTimeout() { - return this.deprecatedProperties.isCustomized() ? this.deprecatedProperties.getReadTimeout() - : this.properties.getSocketTimeout(); - } - - private String getPathPrefix() { - return this.deprecatedProperties.isCustomized() ? null : this.properties.getPathPrefix(); - } - - } - } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java index 33e59604f9..2a967b500a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.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. @@ -238,9 +238,7 @@ public class IntegrationAutoConfiguration { protected static class IntegrationJdbcConfiguration { @Bean - @SuppressWarnings("deprecation") - @ConditionalOnMissingBean({ IntegrationDataSourceScriptDatabaseInitializer.class, - IntegrationDataSourceInitializer.class }) + @ConditionalOnMissingBean(IntegrationDataSourceScriptDatabaseInitializer.class) public IntegrationDataSourceScriptDatabaseInitializer integrationDataSourceInitializer(DataSource dataSource, IntegrationProperties properties) { return new IntegrationDataSourceScriptDatabaseInitializer(dataSource, properties.getJdbc()); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializer.java deleted file mode 100644 index 7f2663d139..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializer.java +++ /dev/null @@ -1,74 +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.integration; - -import javax.sql.DataSource; - -import org.springframework.boot.sql.init.DatabaseInitializationMode; -import org.springframework.core.io.ResourceLoader; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; - -/** - * Initializer for Spring Integration schema. - * - * @author Vedran Pavic - * @since 2.0.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link IntegrationDataSourceScriptDatabaseInitializer} - */ -@Deprecated -public class IntegrationDataSourceInitializer extends org.springframework.boot.jdbc.AbstractDataSourceInitializer { - - private final IntegrationProperties.Jdbc properties; - - public IntegrationDataSourceInitializer(DataSource dataSource, ResourceLoader resourceLoader, - IntegrationProperties properties) { - super(dataSource, resourceLoader); - Assert.notNull(properties, "IntegrationProperties must not be null"); - this.properties = properties.getJdbc(); - } - - @Override - protected org.springframework.boot.jdbc.DataSourceInitializationMode getMode() { - DatabaseInitializationMode mode = this.properties.getInitializeSchema(); - switch (mode) { - case ALWAYS: - return org.springframework.boot.jdbc.DataSourceInitializationMode.ALWAYS; - case EMBEDDED: - return org.springframework.boot.jdbc.DataSourceInitializationMode.EMBEDDED; - case NEVER: - default: - return org.springframework.boot.jdbc.DataSourceInitializationMode.NEVER; - } - } - - @Override - protected String getSchemaLocation() { - return this.properties.getSchema(); - } - - @Override - protected String getDatabaseName() { - String platform = this.properties.getPlatform(); - if (StringUtils.hasText(platform)) { - return platform; - } - return super.getDatabaseName(); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java index 742681d7f1..73448b9855 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.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. @@ -52,15 +52,12 @@ import org.springframework.util.StringUtils; * @author Kazuki Shimizu * @since 1.0.0 */ -@SuppressWarnings("deprecation") @Configuration(proxyBeanMethods = false) @ConditionalOnClass({ DataSource.class, EmbeddedDatabaseType.class }) @ConditionalOnMissingBean(type = "io.r2dbc.spi.ConnectionFactory") @AutoConfigureBefore(SqlInitializationAutoConfiguration.class) @EnableConfigurationProperties(DataSourceProperties.class) -@Import({ DataSourcePoolMetadataProvidersConfiguration.class, - DataSourceInitializationConfiguration.InitializationSpecificCredentialsDataSourceInitializationConfiguration.class, - DataSourceInitializationConfiguration.SharedCredentialsDataSourceInitializationConfiguration.class }) +@Import(DataSourcePoolMetadataProvidersConfiguration.class) public class DataSourceAutoConfiguration { @Configuration(proxyBeanMethods = false) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializationConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializationConfiguration.java deleted file mode 100644 index 780187234f..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializationConfiguration.java +++ /dev/null @@ -1,200 +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 java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -import javax.sql.DataSource; - -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; -import org.springframework.boot.autoconfigure.condition.ConditionMessage; -import org.springframework.boot.autoconfigure.condition.ConditionOutcome; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate; -import org.springframework.boot.autoconfigure.condition.SpringBootCondition; -import org.springframework.boot.autoconfigure.jdbc.DataSourceInitializationConfiguration.InitializationSpecificCredentialsDataSourceInitializationConfiguration.DifferentCredentialsCondition; -import org.springframework.boot.autoconfigure.jdbc.DataSourceInitializationConfiguration.SharedCredentialsDataSourceInitializationConfiguration.DataSourceInitializationCondition; -import org.springframework.boot.autoconfigure.sql.init.SqlDataSourceScriptDatabaseInitializer; -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.sql.init.dependency.DatabaseInitializationDependencyConfigurer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ConditionContext; -import org.springframework.context.annotation.DependsOn; -import org.springframework.core.env.Environment; -import org.springframework.core.type.AnnotatedTypeMetadata; -import org.springframework.jdbc.datasource.SimpleDriverDataSource; -import org.springframework.util.StringUtils; - -/** - * Configuration for {@link DataSource} initialization using a - * {@link DataSourceScriptDatabaseInitializer} with DDL and DML scripts. - * - * @author Andy Wilkinson - */ -@Deprecated -class DataSourceInitializationConfiguration { - - private static DataSource determineDataSource(Supplier dataSource, String username, String password) { - if (StringUtils.hasText(username) && StringUtils.hasText(password)) { - return DataSourceBuilder.derivedFrom(dataSource.get()).type(SimpleDriverDataSource.class).username(username) - .password(password).build(); - } - return dataSource.get(); - } - - private static List scriptLocations(List locations, String fallback, String platform) { - if (locations != null) { - return locations; - } - List fallbackLocations = new ArrayList<>(); - fallbackLocations.add("optional:classpath*:" + fallback + "-" + platform + ".sql"); - fallbackLocations.add("optional:classpath*:" + fallback + ".sql"); - return fallbackLocations; - } - - private static DatabaseInitializationMode mapMode(org.springframework.boot.jdbc.DataSourceInitializationMode mode) { - switch (mode) { - case ALWAYS: - return DatabaseInitializationMode.ALWAYS; - case EMBEDDED: - return DatabaseInitializationMode.EMBEDDED; - case NEVER: - return DatabaseInitializationMode.NEVER; - default: - throw new IllegalStateException("Unexpected initialization mode '" + mode + "'"); - } - } - - // Fully-qualified to work around javac bug in JDK 1.8 - @org.springframework.context.annotation.Configuration(proxyBeanMethods = false) - @org.springframework.context.annotation.Conditional(DifferentCredentialsCondition.class) - @org.springframework.context.annotation.Import(DatabaseInitializationDependencyConfigurer.class) - @ConditionalOnSingleCandidate(DataSource.class) - @ConditionalOnMissingBean(DataSourceScriptDatabaseInitializer.class) - static class InitializationSpecificCredentialsDataSourceInitializationConfiguration { - - @Bean - SqlDataSourceScriptDatabaseInitializer ddlOnlyScriptDataSourceInitializer(ObjectProvider dataSource, - DataSourceProperties properties) { - DatabaseInitializationSettings settings = new DatabaseInitializationSettings(); - settings.setSchemaLocations(scriptLocations(properties.getSchema(), "schema", properties.getPlatform())); - settings.setContinueOnError(properties.isContinueOnError()); - settings.setSeparator(properties.getSeparator()); - settings.setEncoding(properties.getSqlScriptEncoding()); - settings.setMode(mapMode(properties.getInitializationMode())); - DataSource initializationDataSource = determineDataSource(dataSource::getObject, - properties.getSchemaUsername(), properties.getSchemaPassword()); - return new SqlDataSourceScriptDatabaseInitializer(initializationDataSource, settings); - } - - @Bean - @DependsOn("ddlOnlyScriptDataSourceInitializer") - SqlDataSourceScriptDatabaseInitializer dmlOnlyScriptDataSourceInitializer(ObjectProvider dataSource, - DataSourceProperties properties) { - DatabaseInitializationSettings settings = new DatabaseInitializationSettings(); - settings.setDataLocations(scriptLocations(properties.getData(), "data", properties.getPlatform())); - settings.setContinueOnError(properties.isContinueOnError()); - settings.setSeparator(properties.getSeparator()); - settings.setEncoding(properties.getSqlScriptEncoding()); - settings.setMode(mapMode(properties.getInitializationMode())); - DataSource initializationDataSource = determineDataSource(dataSource::getObject, - properties.getDataUsername(), properties.getDataPassword()); - return new SqlDataSourceScriptDatabaseInitializer(initializationDataSource, settings); - } - - static class DifferentCredentialsCondition extends AnyNestedCondition { - - DifferentCredentialsCondition() { - super(ConfigurationPhase.PARSE_CONFIGURATION); - } - - @ConditionalOnProperty(prefix = "spring.datasource", name = "schema-username") - static class SchemaCredentials { - - } - - @ConditionalOnProperty(prefix = "spring.datasource", name = "data-username") - static class DataCredentials { - - } - - } - - } - - // Fully-qualified to work around javac bug in JDK 1.8 - @org.springframework.context.annotation.Configuration(proxyBeanMethods = false) - @org.springframework.context.annotation.Import(DatabaseInitializationDependencyConfigurer.class) - @org.springframework.context.annotation.Conditional(DataSourceInitializationCondition.class) - @ConditionalOnSingleCandidate(DataSource.class) - @ConditionalOnMissingBean(DataSourceScriptDatabaseInitializer.class) - static class SharedCredentialsDataSourceInitializationConfiguration { - - @Bean - SqlDataSourceScriptDatabaseInitializer scriptDataSourceInitializer(DataSource dataSource, - DataSourceProperties properties) { - DatabaseInitializationSettings settings = new DatabaseInitializationSettings(); - settings.setSchemaLocations(scriptLocations(properties.getSchema(), "schema", properties.getPlatform())); - settings.setDataLocations(scriptLocations(properties.getData(), "data", properties.getPlatform())); - settings.setContinueOnError(properties.isContinueOnError()); - settings.setSeparator(properties.getSeparator()); - settings.setEncoding(properties.getSqlScriptEncoding()); - settings.setMode(mapMode(properties.getInitializationMode())); - return new SqlDataSourceScriptDatabaseInitializer(dataSource, settings); - } - - static class DataSourceInitializationCondition extends SpringBootCondition { - - private static final Set INITIALIZATION_PROPERTIES = Collections - .unmodifiableSet(new HashSet<>(Arrays.asList("spring.datasource.initialization-mode", - "spring.datasource.platform", "spring.datasource.schema", "spring.datasource.schema[0]", - "spring.datasource.schema-username", "spring.datasource.schema-password", - "spring.datasource.data", "spring.datasource.data[0]", "spring.datasource.data-username", - "spring.datasource.data-password", "spring.datasource.continue-on-error", - "spring.datasource.separator", "spring.datasource.sql-script-encoding"))); - - @Override - public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { - ConditionMessage.Builder message = ConditionMessage.forCondition("DataSource Initialization"); - Environment environment = context.getEnvironment(); - Set configuredProperties = INITIALIZATION_PROPERTIES.stream() - .filter(environment::containsProperty).collect(Collectors.toSet()); - if (configuredProperties.isEmpty()) { - return ConditionOutcome - .noMatch(message.didNotFind("configured properties").items(INITIALIZATION_PROPERTIES)); - } - return ConditionOutcome.match( - message.found("configured property", "configured properties").items(configuredProperties)); - } - - } - - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java index f6f53a29af..0cbc87f222 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.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. @@ -16,9 +16,7 @@ package org.springframework.boot.autoconfigure.jdbc; -import java.nio.charset.Charset; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import java.util.UUID; @@ -28,7 +26,6 @@ import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.jdbc.DatabaseDriver; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; @@ -95,73 +92,6 @@ public class DataSourceProperties implements BeanClassLoaderAware, InitializingB */ private String jndiName; - /** - * Mode to apply when determining if DataSource initialization should be performed - * using the available DDL and DML scripts. - */ - @Deprecated - private org.springframework.boot.jdbc.DataSourceInitializationMode initializationMode = org.springframework.boot.jdbc.DataSourceInitializationMode.EMBEDDED; - - /** - * Platform to use in the DDL or DML scripts (such as schema-${platform}.sql or - * data-${platform}.sql). - */ - @Deprecated - private String platform = "all"; - - /** - * Schema (DDL) script resource references. - */ - private List schema; - - /** - * Username of the database to execute DDL scripts (if different). - */ - @Deprecated - private String schemaUsername; - - /** - * Password of the database to execute DDL scripts (if different). - */ - @Deprecated - private String schemaPassword; - - /** - * Data (DML) script resource references. - */ - @Deprecated - private List data; - - /** - * Username of the database to execute DML scripts (if different). - */ - @Deprecated - private String dataUsername; - - /** - * Password of the database to execute DML scripts (if different). - */ - @Deprecated - private String dataPassword; - - /** - * Whether to stop if an error occurs while initializing the database. - */ - @Deprecated - private boolean continueOnError = false; - - /** - * Statement separator in SQL initialization scripts. - */ - @Deprecated - private String separator = ";"; - - /** - * SQL scripts encoding. - */ - @Deprecated - private Charset sqlScriptEncoding; - /** * Connection details for an embedded database. Defaults to the most suitable embedded * database that is available on the classpath. @@ -391,127 +321,6 @@ public class DataSourceProperties implements BeanClassLoaderAware, InitializingB this.jndiName = jndiName; } - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.sql.init.mode") - public org.springframework.boot.jdbc.DataSourceInitializationMode getInitializationMode() { - return this.initializationMode; - } - - @Deprecated - public void setInitializationMode(org.springframework.boot.jdbc.DataSourceInitializationMode initializationMode) { - this.initializationMode = initializationMode; - } - - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.sql.init.platform") - public String getPlatform() { - return this.platform; - } - - @Deprecated - public void setPlatform(String platform) { - this.platform = platform; - } - - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.sql.init.schema-locations") - public List getSchema() { - return this.schema; - } - - @Deprecated - public void setSchema(List schema) { - this.schema = schema; - } - - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.sql.init.username") - public String getSchemaUsername() { - return this.schemaUsername; - } - - @Deprecated - public void setSchemaUsername(String schemaUsername) { - this.schemaUsername = schemaUsername; - } - - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.sql.init.password") - public String getSchemaPassword() { - return this.schemaPassword; - } - - @Deprecated - public void setSchemaPassword(String schemaPassword) { - this.schemaPassword = schemaPassword; - } - - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.sql.init.data-locations") - public List getData() { - return this.data; - } - - @Deprecated - public void setData(List data) { - this.data = data; - } - - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.sql.init.username") - public String getDataUsername() { - return this.dataUsername; - } - - @Deprecated - public void setDataUsername(String dataUsername) { - this.dataUsername = dataUsername; - } - - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.sql.init.password") - public String getDataPassword() { - return this.dataPassword; - } - - @Deprecated - public void setDataPassword(String dataPassword) { - this.dataPassword = dataPassword; - } - - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.sql.init.continue-on-error") - public boolean isContinueOnError() { - return this.continueOnError; - } - - @Deprecated - public void setContinueOnError(boolean continueOnError) { - this.continueOnError = continueOnError; - } - - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.sql.init.separator") - public String getSeparator() { - return this.separator; - } - - @Deprecated - public void setSeparator(String separator) { - this.separator = separator; - } - - @Deprecated - @DeprecatedConfigurationProperty(replacement = "spring.sql.init.encoding") - public Charset getSqlScriptEncoding() { - return this.sqlScriptEncoding; - } - - @Deprecated - public void setSqlScriptEncoding(Charset sqlScriptEncoding) { - this.sqlScriptEncoding = sqlScriptEncoding; - } - public EmbeddedDatabaseConnection getEmbeddedDatabaseConnection() { return this.embeddedDatabaseConnection; } 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 62de6fb0ed..344f8ace98 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 224f57a2ed..cd7edf8ecd 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 @@ -24,7 +24,6 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; /** * Configuration properties for Artemis. @@ -47,16 +46,6 @@ public class ArtemisProperties { */ private String brokerUrl; - /** - * Artemis broker host. - */ - private String host; - - /** - * Artemis broker port. - */ - private int port = 61616; - /** * Login user of the broker. */ @@ -85,38 +74,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/quartz/QuartzAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java index 48725001ef..a94b4764a8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.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. @@ -133,9 +133,7 @@ public class QuartzAutoConfiguration { } @Bean - @SuppressWarnings("deprecation") - @ConditionalOnMissingBean({ QuartzDataSourceScriptDatabaseInitializer.class, - QuartzDataSourceInitializer.class }) + @ConditionalOnMissingBean(QuartzDataSourceScriptDatabaseInitializer.class) @Conditional(OnQuartzDatasourceInitializationCondition.class) public QuartzDataSourceScriptDatabaseInitializer quartzDataSourceScriptDatabaseInitializer( DataSource dataSource, @QuartzDataSource ObjectProvider quartzDataSource, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializer.java deleted file mode 100644 index 512d5f1811..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializer.java +++ /dev/null @@ -1,93 +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.quartz; - -import javax.sql.DataSource; - -import org.springframework.boot.sql.init.DatabaseInitializationMode; -import org.springframework.core.io.ResourceLoader; -import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; - -/** - * Initialize the Quartz Scheduler schema. - * - * @author Vedran Pavic - * @since 2.0.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link QuartzDataSourceScriptDatabaseInitializer} - */ -@Deprecated -public class QuartzDataSourceInitializer extends org.springframework.boot.jdbc.AbstractDataSourceInitializer { - - private final QuartzProperties properties; - - public QuartzDataSourceInitializer(DataSource dataSource, ResourceLoader resourceLoader, - QuartzProperties properties) { - super(dataSource, resourceLoader); - Assert.notNull(properties, "QuartzProperties must not be null"); - this.properties = properties; - } - - @Override - protected void customize(ResourceDatabasePopulator populator) { - populator.setCommentPrefixes(this.properties.getJdbc().getCommentPrefix().toArray(new String[0])); - } - - @Override - protected org.springframework.boot.jdbc.DataSourceInitializationMode getMode() { - DatabaseInitializationMode mode = this.properties.getJdbc().getInitializeSchema(); - switch (mode) { - case ALWAYS: - return org.springframework.boot.jdbc.DataSourceInitializationMode.ALWAYS; - case EMBEDDED: - return org.springframework.boot.jdbc.DataSourceInitializationMode.EMBEDDED; - case NEVER: - default: - return org.springframework.boot.jdbc.DataSourceInitializationMode.NEVER; - } - } - - @Override - protected String getSchemaLocation() { - return this.properties.getJdbc().getSchema(); - } - - @Override - protected String getDatabaseName() { - String platform = this.properties.getJdbc().getPlatform(); - if (StringUtils.hasText(platform)) { - return platform; - } - String databaseName = super.getDatabaseName(); - if ("db2".equals(databaseName)) { - return "db2_v95"; - } - if ("mysql".equals(databaseName) || "mariadb".equals(databaseName)) { - return "mysql_innodb"; - } - if ("postgresql".equals(databaseName)) { - return "postgres"; - } - if ("sqlserver".equals(databaseName)) { - return "sqlServer"; - } - return databaseName; - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/JdbcSessionConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/JdbcSessionConfiguration.java index 397a89f60f..2eae122820 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/JdbcSessionConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/JdbcSessionConfiguration.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,9 +56,7 @@ import org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessi class JdbcSessionConfiguration { @Bean - @SuppressWarnings("deprecation") - @ConditionalOnMissingBean({ JdbcSessionDataSourceScriptDatabaseInitializer.class, - JdbcSessionDataSourceInitializer.class }) + @ConditionalOnMissingBean(JdbcSessionDataSourceScriptDatabaseInitializer.class) @Conditional(OnJdbcSessionDatasourceInitializationCondition.class) JdbcSessionDataSourceScriptDatabaseInitializer jdbcSessionDataSourceScriptDatabaseInitializer( @SpringSessionDataSource ObjectProvider sessionDataSource, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializer.java deleted file mode 100644 index f855c52637..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializer.java +++ /dev/null @@ -1,74 +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.session; - -import javax.sql.DataSource; - -import org.springframework.boot.sql.init.DatabaseInitializationMode; -import org.springframework.core.io.ResourceLoader; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; - -/** - * Initializer for Spring Session schema. - * - * @author Vedran Pavic - * @since 1.4.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link JdbcSessionDataSourceScriptDatabaseInitializer} - */ -@Deprecated -public class JdbcSessionDataSourceInitializer extends org.springframework.boot.jdbc.AbstractDataSourceInitializer { - - private final JdbcSessionProperties properties; - - public JdbcSessionDataSourceInitializer(DataSource dataSource, ResourceLoader resourceLoader, - JdbcSessionProperties properties) { - super(dataSource, resourceLoader); - Assert.notNull(properties, "JdbcSessionProperties must not be null"); - this.properties = properties; - } - - @Override - protected org.springframework.boot.jdbc.DataSourceInitializationMode getMode() { - DatabaseInitializationMode mode = this.properties.getInitializeSchema(); - switch (mode) { - case ALWAYS: - return org.springframework.boot.jdbc.DataSourceInitializationMode.ALWAYS; - case EMBEDDED: - return org.springframework.boot.jdbc.DataSourceInitializationMode.EMBEDDED; - case NEVER: - default: - return org.springframework.boot.jdbc.DataSourceInitializationMode.NEVER; - } - } - - @Override - protected String getSchemaLocation() { - return this.properties.getSchema(); - } - - @Override - protected String getDatabaseName() { - String platform = this.properties.getPlatform(); - if (StringUtils.hasText(platform)) { - return platform; - } - return super.getDatabaseName(); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxProperties.java index 990b9f1fa6..fa2083785c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxProperties.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.web.reactive; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.util.StringUtils; /** @@ -36,8 +35,6 @@ public class WebFluxProperties { private final Format format = new Format(); - private final Session session = new Session(); - /** * Path pattern used for static resources. */ @@ -71,11 +68,6 @@ public class WebFluxProperties { return this.format; } - @DeprecatedConfigurationProperty(replacement = "server.reactive.session") - public Session getSession() { - return this.session; - } - public String getStaticPathPattern() { return this.staticPathPattern; } @@ -127,84 +119,4 @@ public class WebFluxProperties { } - /** - * Session properties. - * - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@code server.reactive.session}. - */ - @Deprecated - public static class Session { - - private final Cookie cookie = new Cookie(); - - @DeprecatedConfigurationProperty(replacement = "server.reactive.session.cookie") - public Cookie getCookie() { - return this.cookie; - } - - } - - /** - * Session cookie properties. - * - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link org.springframework.boot.web.server.Cookie}. - */ - @Deprecated - public static class Cookie { - - /** - * SameSite attribute value for session Cookies. - */ - private SameSite sameSite; - - @DeprecatedConfigurationProperty(replacement = "server.reactive.session.cookie.same-site") - public SameSite getSameSite() { - return this.sameSite; - } - - public void setSameSite(SameSite sameSite) { - this.sameSite = sameSite; - } - - } - - /** - * SameSite values. - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link org.springframework.boot.web.server.Cookie.SameSite}. - */ - @Deprecated - public enum SameSite { - - /** - * Cookies are sent in both first-party and cross-origin requests. - */ - NONE("None"), - - /** - * Cookies are sent in a first-party context, also when following a link to the - * origin site. - */ - LAX("Lax"), - - /** - * Cookies are only sent in a first-party context (i.e. not when following a link - * to the origin site). - */ - STRICT("Strict"); - - private final String attribute; - - SameSite(String attribute) { - this.attribute = attribute; - } - - public String attribute() { - return this.attribute; - } - - } - } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebSessionIdResolverAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebSessionIdResolverAutoConfiguration.java index adf1b6f416..4dc6813414 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebSessionIdResolverAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebSessionIdResolverAutoConfiguration.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. @@ -23,8 +23,8 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.PropertyMapper; -import org.springframework.boot.context.properties.source.MutuallyExclusiveConfigurationPropertiesException; import org.springframework.boot.web.server.Cookie; +import org.springframework.boot.web.server.Cookie.SameSite; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.ResponseCookie.ResponseCookieBuilder; @@ -48,24 +48,9 @@ public class WebSessionIdResolverAutoConfiguration { private final ServerProperties serverProperties; - private final WebFluxProperties webFluxProperties; - public WebSessionIdResolverAutoConfiguration(ServerProperties serverProperties, WebFluxProperties webFluxProperties) { this.serverProperties = serverProperties; - this.webFluxProperties = webFluxProperties; - assertNoMutuallyExclusiveProperties(serverProperties, webFluxProperties); - } - - @SuppressWarnings("deprecation") - private void assertNoMutuallyExclusiveProperties(ServerProperties serverProperties, - WebFluxProperties webFluxProperties) { - MutuallyExclusiveConfigurationPropertiesException.throwIfMultipleNonNullValuesIn((entries) -> { - entries.put("spring.webflux.session.cookie.same-site", - webFluxProperties.getSession().getCookie().getSameSite()); - entries.put("server.reactive.session.cookie.same-site", - serverProperties.getReactive().getSession().getCookie().getSameSite()); - }); } @Bean @@ -91,16 +76,9 @@ public class WebSessionIdResolverAutoConfiguration { map.from(getSameSite(cookie)).to(builder::sameSite); } - @SuppressWarnings("deprecation") private String getSameSite(Cookie properties) { - if (properties.getSameSite() != null) { - return properties.getSameSite().attributeValue(); - } - WebFluxProperties.Cookie deprecatedProperties = this.webFluxProperties.getSession().getCookie(); - if (deprecatedProperties.getSameSite() != null) { - return deprecatedProperties.getSameSite().attribute(); - } - return null; + SameSite sameSite = properties.getSameSite(); + return (sameSite != null) ? sameSite.attributeValue() : null; } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java index 31700ef12d..5bb9fd55db 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.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. @@ -30,7 +30,6 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProviders; import org.springframework.boot.autoconfigure.web.WebProperties.Resources; import org.springframework.boot.web.error.ErrorAttributeOptions; -import org.springframework.boot.web.error.ErrorAttributeOptions.Include; import org.springframework.boot.web.reactive.error.ErrorAttributes; import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler; import org.springframework.context.ApplicationContext; @@ -136,21 +135,6 @@ public abstract class AbstractErrorWebExceptionHandler implements ErrorWebExcept this.viewResolvers = viewResolvers; } - /** - * Extract the error attributes from the current request, to be used to populate error - * views or JSON payloads. - * @param request the source request - * @param includeStackTrace whether to include the error stacktrace information - * @return the error attributes as a Map - * @deprecated since 2.3.0 for removal in 2.5.0 in favor of - * {@link #getErrorAttributes(ServerRequest, ErrorAttributeOptions)} - */ - @Deprecated - protected Map getErrorAttributes(ServerRequest request, boolean includeStackTrace) { - return getErrorAttributes(request, - (includeStackTrace) ? ErrorAttributeOptions.of(Include.STACK_TRACE) : ErrorAttributeOptions.defaults()); - } - /** * Extract the error attributes from the current request, to be used to populate error * views or JSON payloads. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializerTests.java deleted file mode 100644 index 88fabb00d1..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchDataSourceInitializerTests.java +++ /dev/null @@ -1,48 +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.batch; - -import javax.sql.DataSource; - -import org.junit.jupiter.api.Test; - -import org.springframework.core.io.DefaultResourceLoader; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; - -/** - * Tests for {@link BatchDataSourceInitializer}. - * - * @author Stephane Nicoll - */ -@Deprecated -class BatchDataSourceInitializerTests { - - @Test - void getDatabaseNameWithPlatformDoesNotTouchDataSource() { - DataSource dataSource = mock(DataSource.class); - BatchProperties properties = new BatchProperties(); - properties.getJdbc().setPlatform("test"); - BatchDataSourceInitializer initializer = new BatchDataSourceInitializer(dataSource, new DefaultResourceLoader(), - properties); - assertThat(initializer.getDatabaseName()).isEqualTo("test"); - verifyNoInteractions(dataSource); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRestClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRestClientAutoConfigurationTests.java index 31463dc37f..abadc2af24 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRestClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRestClientAutoConfigurationTests.java @@ -16,10 +16,6 @@ package org.springframework.boot.autoconfigure.data.elasticsearch; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; import java.net.InetSocketAddress; import java.nio.charset.StandardCharsets; import java.time.Duration; @@ -28,8 +24,6 @@ import java.util.List; import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; @@ -81,33 +75,6 @@ class ReactiveElasticsearchRestClientAutoConfigurationTests { .hasSingleBean(ClientConfiguration.class).hasBean("customClientConfiguration")); } - @Test - @Deprecated - void whenEndpointIsCustomizedThenClientConfigurationHasCustomEndpoint() { - this.contextRunner.withPropertyValues("spring.data.elasticsearch.client.reactive.endpoints=localhost:9876") - .run((context) -> { - List endpoints = context.getBean(ClientConfiguration.class).getEndpoints(); - assertThat(endpoints).hasSize(1); - assertThat(endpoints.get(0).getHostString()).isEqualTo("localhost"); - assertThat(endpoints.get(0).getPort()).isEqualTo(9876); - }); - } - - @Test - @Deprecated - void whenMultipleEndpointsAreConfiguredThenClientConfigurationHasMultipleEndpoints() { - this.contextRunner - .withPropertyValues("spring.data.elasticsearch.client.reactive.endpoints=localhost:9876,localhost:8765") - .run((context) -> { - List endpoints = context.getBean(ClientConfiguration.class).getEndpoints(); - assertThat(endpoints).hasSize(2); - assertThat(endpoints.get(0).getHostString()).isEqualTo("localhost"); - assertThat(endpoints.get(0).getPort()).isEqualTo(9876); - assertThat(endpoints.get(1).getHostString()).isEqualTo("localhost"); - assertThat(endpoints.get(1).getPort()).isEqualTo(8765); - }); - } - @Test void whenUriIsCustomizedThenClientConfigurationHasCustomEndpoint() { this.contextRunner.withPropertyValues("spring.elasticsearch.uris=http://localhost:9876").run((context) -> { @@ -223,13 +190,6 @@ class ReactiveElasticsearchRestClientAutoConfigurationTests { }); } - @Test - @Deprecated - void whenConfiguredToUseSslThenClientConfigurationUsesSsl() { - this.contextRunner.withPropertyValues("spring.data.elasticsearch.client.reactive.use-ssl=true") - .run((context) -> assertThat(context.getBean(ClientConfiguration.class).useSsl()).isTrue()); - } - @Test void whenSocketTimeoutIsNotConfiguredThenClientConfigurationUsesDefault() { this.contextRunner.run((context) -> assertThat(context.getBean(ClientConfiguration.class).getSocketTimeout()) @@ -242,16 +202,16 @@ class ReactiveElasticsearchRestClientAutoConfigurationTests { .isEqualTo(Duration.ofSeconds(1))); } - @ParameterizedPropertyPrefixTest - void whenSocketTimeoutIsConfiguredThenClientConfigurationHasCustomSocketTimeout(String prefix) { - this.contextRunner.withPropertyValues(prefix + "socket-timeout=2s") + @Test + void whenSocketTimeoutIsConfiguredThenClientConfigurationHasCustomSocketTimeout() { + this.contextRunner.withPropertyValues("spring.elasticsearch.socket-timeout=2s") .run((context) -> assertThat(context.getBean(ClientConfiguration.class).getSocketTimeout()) .isEqualTo(Duration.ofSeconds(2))); } - @ParameterizedPropertyPrefixTest - void whenConnectionTimeoutIsConfiguredThenClientConfigurationHasCustomConnectTimeout(String prefix) { - this.contextRunner.withPropertyValues(prefix + "connection-timeout=2s") + @Test + void whenConnectionTimeoutIsConfiguredThenClientConfigurationHasCustomConnectTimeout() { + this.contextRunner.withPropertyValues("spring.elasticsearch.connection-timeout=2s") .run((context) -> assertThat(context.getBean(ClientConfiguration.class).getConnectTimeout()) .isEqualTo(Duration.ofSeconds(2))); } @@ -263,23 +223,25 @@ class ReactiveElasticsearchRestClientAutoConfigurationTests { .isEqualTo("/some/prefix")); } - @ParameterizedPropertyPrefixTest - void whenCredentialsAreConfiguredThenClientConfigurationHasDefaultAuthorizationHeader(String prefix) { - this.contextRunner.withPropertyValues(prefix + "username=alice", prefix + "password=secret") + @Test + void whenCredentialsAreConfiguredThenClientConfigurationHasDefaultAuthorizationHeader() { + this.contextRunner + .withPropertyValues("spring.elasticsearch.username=alice", "spring.elasticsearch.password=secret") .run((context) -> assertThat( context.getBean(ClientConfiguration.class).getDefaultHeaders().get(HttpHeaders.AUTHORIZATION)) .containsExactly("Basic YWxpY2U6c2VjcmV0")); } - @ParameterizedTest - @ValueSource(strings = { "spring.elasticsearch.webclient.", "spring.data.elasticsearch.client.reactive." }) - void whenMaxInMemorySizeIsConfiguredThenUnderlyingWebClientHasCustomMaxInMemorySize(String prefix) { - this.contextRunner.withPropertyValues(prefix + "max-in-memory-size=1MB").run((context) -> { - WebClient client = configureWebClient(context.getBean(ClientConfiguration.class).getClientConfigurers()); - assertThat(client).extracting("exchangeFunction.strategies.codecConfigurer.defaultCodecs") - .asInstanceOf(InstanceOfAssertFactories.type(DefaultCodecConfig.class)) - .extracting(DefaultCodecConfig::maxInMemorySize).isEqualTo(1024 * 1024); - }); + @Test + void whenMaxInMemorySizeIsConfiguredThenUnderlyingWebClientHasCustomMaxInMemorySize() { + this.contextRunner.withPropertyValues("spring.elasticsearch.webclient.max-in-memory-size=1MB") + .run((context) -> { + WebClient client = configureWebClient( + context.getBean(ClientConfiguration.class).getClientConfigurers()); + assertThat(client).extracting("exchangeFunction.strategies.codecConfigurer.defaultCodecs") + .asInstanceOf(InstanceOfAssertFactories.type(DefaultCodecConfig.class)) + .extracting(DefaultCodecConfig::maxInMemorySize).isEqualTo(1024 * 1024); + }); } private WebClient configureWebClient(List> callbacks) { @@ -310,12 +272,4 @@ class ReactiveElasticsearchRestClientAutoConfigurationTests { } - @ParameterizedTest - @Target(ElementType.METHOD) - @Retention(RetentionPolicy.RUNTIME) - @ValueSource(strings = { "spring.data.elasticsearch.client.reactive.", "spring.elasticsearch." }) - static @interface ParameterizedPropertyPrefixTest { - - } - } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java index ac2ff6249e..9959338ee7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.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. @@ -16,10 +16,6 @@ package org.springframework.boot.autoconfigure.elasticsearch; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; import java.time.Duration; import java.util.Map; @@ -35,8 +31,6 @@ import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClientBuilder; import org.elasticsearch.client.sniff.Sniffer; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.FilteredClassLoader; @@ -126,17 +120,6 @@ class ElasticsearchRestClientAutoConfigurationTests { }); } - @Test - void configureWithLegacyCustomTimeouts() { - this.contextRunner.withPropertyValues("spring.elasticsearch.rest.connection-timeout=15s", - "spring.elasticsearch.rest.read-timeout=1m").run((context) -> { - assertThat(context).hasSingleBean(org.elasticsearch.client.RestHighLevelClient.class); - org.elasticsearch.client.RestHighLevelClient restClient = context - .getBean(org.elasticsearch.client.RestHighLevelClient.class); - assertTimeouts(restClient, Duration.ofSeconds(15), Duration.ofMinutes(1)); - }); - } - @Test void configureWithCustomTimeouts() { this.contextRunner.withPropertyValues("spring.elasticsearch.connection-timeout=15s", @@ -156,18 +139,18 @@ class ElasticsearchRestClientAutoConfigurationTests { .isEqualTo(Math.toIntExact(connectTimeout.toMillis())); } - @ParameterizedPropertyPrefixTest - void configureUriWithNoScheme(String prefix) { - this.contextRunner.withPropertyValues(prefix + "uris=localhost:9876").run((context) -> { + @Test + void configureUriWithNoScheme() { + this.contextRunner.withPropertyValues("spring.elasticsearch.uris=localhost:9876").run((context) -> { RestClient client = context.getBean(org.elasticsearch.client.RestHighLevelClient.class).getLowLevelClient(); assertThat(client.getNodes().stream().map(Node::getHost).map(HttpHost::toString)) .containsExactly("http://localhost:9876"); }); } - @ParameterizedPropertyPrefixTest - void configureUriWithUsernameOnly(String prefix) { - this.contextRunner.withPropertyValues(prefix + "uris=http://user@localhost:9200").run((context) -> { + @Test + void configureUriWithUsernameOnly() { + this.contextRunner.withPropertyValues("spring.elasticsearch.uris=http://user@localhost:9200").run((context) -> { RestClient client = context.getBean(org.elasticsearch.client.RestHighLevelClient.class).getLowLevelClient(); assertThat(client.getNodes().stream().map(Node::getHost).map(HttpHost::toString)) .containsExactly("http://localhost:9200"); @@ -181,26 +164,32 @@ class ElasticsearchRestClientAutoConfigurationTests { }); } - @ParameterizedPropertyPrefixTest - void configureUriWithUsernameAndEmptyPassword(String prefix) { - this.contextRunner.withPropertyValues(prefix + "uris=http://user:@localhost:9200").run((context) -> { - RestClient client = context.getBean(org.elasticsearch.client.RestHighLevelClient.class).getLowLevelClient(); - assertThat(client.getNodes().stream().map(Node::getHost).map(HttpHost::toString)) - .containsExactly("http://localhost:9200"); - assertThat(client) - .extracting("client.credentialsProvider", InstanceOfAssertFactories.type(CredentialsProvider.class)) - .satisfies((credentialsProvider) -> { - Credentials credentials = credentialsProvider.getCredentials(new AuthScope("localhost", 9200)); - assertThat(credentials.getUserPrincipal().getName()).isEqualTo("user"); - assertThat(credentials.getPassword()).isEmpty(); - }); - }); + @Test + void configureUriWithUsernameAndEmptyPassword() { + this.contextRunner.withPropertyValues("spring.elasticsearch.uris=http://user:@localhost:9200") + .run((context) -> { + RestClient client = context.getBean(org.elasticsearch.client.RestHighLevelClient.class) + .getLowLevelClient(); + assertThat(client.getNodes().stream().map(Node::getHost).map(HttpHost::toString)) + .containsExactly("http://localhost:9200"); + assertThat(client) + .extracting("client.credentialsProvider", + InstanceOfAssertFactories.type(CredentialsProvider.class)) + .satisfies((credentialsProvider) -> { + Credentials credentials = credentialsProvider + .getCredentials(new AuthScope("localhost", 9200)); + assertThat(credentials.getUserPrincipal().getName()).isEqualTo("user"); + assertThat(credentials.getPassword()).isEmpty(); + }); + }); } - @ParameterizedPropertyPrefixTest - void configureUriWithUsernameAndPasswordWhenUsernameAndPasswordPropertiesSet(String prefix) { - this.contextRunner.withPropertyValues(prefix + "uris=http://user:password@localhost:9200,localhost:9201", - prefix + "username=admin", prefix + "password=admin").run((context) -> { + @Test + void configureUriWithUsernameAndPasswordWhenUsernameAndPasswordPropertiesSet() { + this.contextRunner + .withPropertyValues("spring.elasticsearch.uris=http://user:password@localhost:9200,localhost:9201", + "spring.elasticsearch.username=admin", "spring.elasticsearch.password=admin") + .run((context) -> { RestClient client = context.getBean(org.elasticsearch.client.RestHighLevelClient.class) .getLowLevelClient(); assertThat(client.getNodes().stream().map(Node::getHost).map(HttpHost::toString)) @@ -248,10 +237,10 @@ class ElasticsearchRestClientAutoConfigurationTests { }); } - @ParameterizedSnifferPropertyPrefixTest - void configureWithCustomSnifferSettings(String prefix) { - this.contextRunner.withPropertyValues(prefix + "interval=180s", prefix + "delay-after-failure=30s") - .run((context) -> { + @Test + void configureWithCustomSnifferSettings() { + this.contextRunner.withPropertyValues("spring.elasticsearch.restclient.sniffer.interval=180s", + "spring.elasticsearch.restclient.sniffer.delay-after-failure=30s").run((context) -> { assertThat(context).hasSingleBean(Sniffer.class); Sniffer sniffer = context.getBean(Sniffer.class); assertThat(sniffer).hasFieldOrPropertyWithValue("sniffIntervalMillis", @@ -334,20 +323,4 @@ class ElasticsearchRestClientAutoConfigurationTests { } - @ParameterizedTest - @Target(ElementType.METHOD) - @Retention(RetentionPolicy.RUNTIME) - @ValueSource(strings = { "spring.elasticsearch.rest.", "spring.elasticsearch." }) - static @interface ParameterizedPropertyPrefixTest { - - } - - @ParameterizedTest - @Target(ElementType.METHOD) - @Retention(RetentionPolicy.RUNTIME) - @ValueSource(strings = { "spring.elasticsearch.rest.sniffer.", "spring.elasticsearch.restclient.sniffer." }) - static @interface ParameterizedSnifferPropertyPrefixTest { - - } - } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java index b2d7878d75..7a02deae7d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.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. @@ -51,7 +51,6 @@ import org.springframework.boot.test.context.runner.ApplicationContextRunner; 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.integration.annotation.IntegrationComponentScan; import org.springframework.integration.annotation.MessagingGateway; import org.springframework.integration.annotation.ServiceActivator; @@ -386,18 +385,6 @@ class IntegrationAutoConfigurationTests { .hasBean("customInitializer")); } - @Test - @Deprecated - @SuppressWarnings("deprecation") - void whenTheUserDefinesTheirOwnIntegrationDataSourceInitializerThenTheAutoConfiguredInitializerBacksOff() { - this.contextRunner.withUserConfiguration(CustomIntegrationDataSourceInitializerConfiguration.class) - .withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class, - DataSourceTransactionManagerAutoConfiguration.class)) - .run((context) -> assertThat(context) - .doesNotHaveBean(IntegrationDataSourceScriptDatabaseInitializer.class) - .hasSingleBean(IntegrationDataSourceInitializer.class).hasBean("customInitializer")); - } - @Test void whenTheUserDefinesTheirOwnDatabaseInitializerThenTheAutoConfiguredIntegrationInitializerRemains() { this.contextRunner.withUserConfiguration(CustomDatabaseInitializerConfiguration.class) @@ -578,18 +565,6 @@ class IntegrationAutoConfigurationTests { } - @Deprecated - @Configuration(proxyBeanMethods = false) - static class CustomIntegrationDataSourceInitializerConfiguration { - - @Bean - IntegrationDataSourceInitializer customInitializer(DataSource dataSource, ResourceLoader resourceLoader, - IntegrationProperties properties) { - return new IntegrationDataSourceInitializer(dataSource, resourceLoader, properties); - } - - } - @Configuration(proxyBeanMethods = false) static class PollingConsumerConfiguration { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializerTests.java deleted file mode 100644 index c98814cf00..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationDataSourceInitializerTests.java +++ /dev/null @@ -1,48 +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.integration; - -import javax.sql.DataSource; - -import org.junit.jupiter.api.Test; - -import org.springframework.core.io.DefaultResourceLoader; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; - -/** - * Tests for {@link IntegrationDataSourceInitializer}. - * - * @author Stephane Nicoll - */ -@Deprecated -class IntegrationDataSourceInitializerTests { - - @Test - void getDatabaseNameWithPlatformDoesNotTouchDataSource() { - DataSource dataSource = mock(DataSource.class); - IntegrationProperties properties = new IntegrationProperties(); - properties.getJdbc().setPlatform("test"); - IntegrationDataSourceInitializer initializer = new IntegrationDataSourceInitializer(dataSource, - new DefaultResourceLoader(), properties); - assertThat(initializer.getDatabaseName()).isEqualTo("test"); - verifyNoInteractions(dataSource); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java index 7cc2f74cf2..f060ed5dd1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.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. @@ -39,18 +39,15 @@ import org.apache.commons.dbcp2.BasicDataSource; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.jdbc.DatabaseDriver; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer; -import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitialization; import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.SimpleDriverDataSource; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; import org.springframework.util.StringUtils; @@ -235,16 +232,6 @@ class DataSourceAutoConfigurationTests { .run((context) -> assertThat(context).getBean(DataSource.class).isInstanceOf(EmbeddedDatabase.class)); } - @Test - @Deprecated - void testDataSourceIsInitializedEarly() { - this.contextRunner.withUserConfiguration(TestInitializedDataSourceConfiguration.class) - .withPropertyValues("spring.datasource.initialization-mode=always").run((context) -> { - assertThat(context).hasSingleBean(DataSourceScriptDatabaseInitializer.class); - assertThat(context.getBean(TestInitializedDataSourceConfiguration.class).called).isTrue(); - }); - } - @Test void whenNoInitializationRelatedSpringDataSourcePropertiesAreConfiguredThenInitializationBacksOff() { this.contextRunner @@ -282,22 +269,6 @@ class DataSourceAutoConfigurationTests { } - @Configuration(proxyBeanMethods = false) - @DependsOnDatabaseInitialization - static class TestInitializedDataSourceConfiguration { - - private boolean called; - - @Autowired - void validateDataSourceIsInitialized(DataSource dataSource) { - // Inject the datasource to validate it is initialized at the injection point - JdbcTemplate template = new JdbcTemplate(dataSource); - assertThat(template.queryForObject("SELECT COUNT(*) from BAR", Integer.class)).isEqualTo(1); - this.called = true; - } - - } - // see testExplicitDriverClassClearsUsername public static class DatabaseTestDriver implements Driver { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializationIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializationIntegrationTests.java deleted file mode 100644 index c8a8d279ed..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializationIntegrationTests.java +++ /dev/null @@ -1,440 +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 java.io.IOException; -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Random; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.logging.Logger; - -import javax.sql.DataSource; - -import com.zaxxer.hikari.HikariDataSource; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.BeanCreationException; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; -import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; -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.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Scope; -import org.springframework.context.support.SimpleThreadScope; -import org.springframework.core.io.DefaultResourceLoader; -import org.springframework.core.io.Resource; -import org.springframework.core.io.ResourceLoader; -import org.springframework.core.io.support.ResourcePatternResolver; -import org.springframework.core.io.support.ResourcePatternUtils; -import org.springframework.jdbc.BadSqlGrammarException; -import org.springframework.jdbc.core.JdbcOperations; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.util.ClassUtils; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Integration tests for DataSource initialization. - * - * @author Dave Syer - * @author Stephane Nicoll - */ -@Deprecated -class DataSourceInitializationIntegrationTests { - - private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)) - .withPropertyValues("spring.datasource.initialization-mode=never", - "spring.datasource.url:jdbc:hsqldb:mem:init-" + UUID.randomUUID()); - - @Test - void dataSourceInitialized() { - this.contextRunner.withPropertyValues("spring.datasource.initialization-mode:always").run((context) -> { - assertThat(context).hasSingleBean(DataSource.class); - DataSource dataSource = context.getBean(DataSource.class); - assertThat(dataSource).isInstanceOf(HikariDataSource.class); - assertDataSourceIsInitialized(dataSource); - }); - } - - @Test - void initializationAppliesToCustomDataSource() { - this.contextRunner.withUserConfiguration(OneDataSource.class) - .withPropertyValues("spring.datasource.initialization-mode:always").run((context) -> { - assertThat(context).hasSingleBean(DataSource.class); - assertDataSourceIsInitialized(context.getBean(DataSource.class)); - }); - } - - @Test - void initializationWithUsernameAndPasswordAppliesToCustomDataSource() { - this.contextRunner.withUserConfiguration(OneDataSource.class) - .withPropertyValues("spring.datasource.initialization-mode:always", - "spring.datasource.schema-username=test", "spring.datasource.schema-password=secret") - .run((context) -> { - assertThat(context).hasSingleBean(DataSource.class); - assertDataSourceIsInitialized(context.getBean(DataSource.class)); - }); - } - - private void assertDataSourceIsInitialized(DataSource dataSource) { - JdbcOperations template = new JdbcTemplate(dataSource); - assertThat(template.queryForObject("SELECT COUNT(*) from BAR", Integer.class)).isEqualTo(1); - } - - @Test - void dataSourceInitializedWithExplicitScript() { - this.contextRunner.withPropertyValues("spring.datasource.initialization-mode:always", - "spring.datasource.schema:" + getRelativeLocationFor("schema.sql"), - "spring.datasource.data:" + getRelativeLocationFor("data.sql")).run((context) -> { - DataSource dataSource = context.getBean(DataSource.class); - assertThat(dataSource).isInstanceOf(HikariDataSource.class); - assertThat(dataSource).isNotNull(); - JdbcOperations template = new JdbcTemplate(dataSource); - assertThat(template.queryForObject("SELECT COUNT(*) from FOO", Integer.class)).isEqualTo(1); - }); - } - - @Test - void dataSourceInitializedWithMultipleScripts() { - this.contextRunner.withPropertyValues("spring.datasource.initialization-mode:always", - "spring.datasource.schema:" + getRelativeLocationFor("schema.sql") + "," - + getRelativeLocationFor("another.sql"), - "spring.datasource.data:" + getRelativeLocationFor("data.sql")).run((context) -> { - DataSource dataSource = context.getBean(DataSource.class); - assertThat(dataSource).isInstanceOf(HikariDataSource.class); - assertThat(dataSource).isNotNull(); - JdbcOperations template = new JdbcTemplate(dataSource); - assertThat(template.queryForObject("SELECT COUNT(*) from FOO", Integer.class)).isEqualTo(1); - assertThat(template.queryForObject("SELECT COUNT(*) from SPAM", Integer.class)).isEqualTo(0); - }); - } - - @Test - void dataSourceInitializedWithExplicitSqlScriptEncoding() { - this.contextRunner.withPropertyValues("spring.datasource.initialization-mode:always", - "spring.datasource.sqlScriptEncoding:UTF-8", - "spring.datasource.schema:" + getRelativeLocationFor("encoding-schema.sql"), - "spring.datasource.data:" + getRelativeLocationFor("encoding-data.sql")).run((context) -> { - DataSource dataSource = context.getBean(DataSource.class); - assertThat(dataSource).isInstanceOf(HikariDataSource.class); - assertThat(dataSource).isNotNull(); - JdbcOperations template = new JdbcTemplate(dataSource); - assertThat(template.queryForObject("SELECT COUNT(*) from BAR", Integer.class)).isEqualTo(2); - assertThat(template.queryForObject("SELECT name from BAR WHERE id=1", String.class)) - .isEqualTo("bar"); - assertThat(template.queryForObject("SELECT name from BAR WHERE id=2", String.class)) - .isEqualTo("ばー"); - }); - } - - @Test - void initializationDisabled() { - this.contextRunner.run(assertInitializationIsDisabled()); - } - - @Test - void initializationDoesNotApplyWithSeveralDataSources() { - this.contextRunner.withUserConfiguration(TwoDataSources.class) - .withPropertyValues("spring.datasource.initialization-mode:always").run((context) -> { - assertThat(context.getBeanNamesForType(DataSource.class)).hasSize(2); - assertDataSourceNotInitialized(context.getBean("oneDataSource", DataSource.class)); - assertDataSourceNotInitialized(context.getBean("twoDataSource", DataSource.class)); - }); - } - - private ContextConsumer assertInitializationIsDisabled() { - return (context) -> { - assertThat(context).hasSingleBean(DataSource.class); - DataSource dataSource = context.getBean(DataSource.class); - assertDataSourceNotInitialized(dataSource); - }; - } - - private void assertDataSourceNotInitialized(DataSource dataSource) { - JdbcOperations template = new JdbcTemplate(dataSource); - assertThatExceptionOfType(BadSqlGrammarException.class) - .isThrownBy(() -> template.queryForObject("SELECT COUNT(*) from BAR", Integer.class)) - .satisfies((ex) -> { - SQLException sqlException = ex.getSQLException(); - int expectedCode = -5501; // user lacks privilege or object not found - assertThat(sqlException.getErrorCode()).isEqualTo(expectedCode); - }); - } - - @Test - void dataSourceInitializedWithSchemaCredentials() { - this.contextRunner - .withPropertyValues("spring.datasource.initialization-mode:always", - "spring.datasource.sqlScriptEncoding:UTF-8", - "spring.datasource.schema:" + getRelativeLocationFor("encoding-schema.sql"), - "spring.datasource.data:" + getRelativeLocationFor("encoding-data.sql"), - "spring.datasource.schema-username:admin", "spring.datasource.schema-password:admin") - .run((context) -> { - assertThat(context).hasFailed(); - assertThat(context.getStartupFailure()).isInstanceOf(BeanCreationException.class) - .hasMessageContaining("invalid authorization specification"); - context.getStartupFailure().printStackTrace(); - }); - } - - @Test - void dataSourceInitializedWithDataCredentials() { - this.contextRunner - .withPropertyValues("spring.datasource.initialization-mode:always", - "spring.datasource.sqlScriptEncoding:UTF-8", - "spring.datasource.schema:" + getRelativeLocationFor("encoding-schema.sql"), - "spring.datasource.data:" + getRelativeLocationFor("encoding-data.sql"), - "spring.datasource.data-username:admin", "spring.datasource.data-password:admin") - .run((context) -> { - assertThat(context).hasFailed(); - assertThat(context.getStartupFailure()).isInstanceOf(BeanCreationException.class) - .hasMessageContaining("invalid authorization specification"); - }); - } - - @Test - void multipleScriptsAppliedInLexicalOrder() { - new ApplicationContextRunner(() -> { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - context.setResourceLoader(new ReverseOrderResourceLoader(new DefaultResourceLoader())); - return context; - }).withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)) - .withPropertyValues("spring.datasource.initialization-mode=always", - "spring.datasource.url:jdbc:hsqldb:mem:testdb-" + new Random().nextInt(), - "spring.datasource.schema:classpath*:" + getRelativeLocationFor("lexical-schema-*.sql"), - "spring.datasource.data:classpath*:" + getRelativeLocationFor("data.sql")) - .run((context) -> { - DataSource dataSource = context.getBean(DataSource.class); - assertThat(dataSource).isInstanceOf(HikariDataSource.class); - assertThat(dataSource).isNotNull(); - JdbcOperations template = new JdbcTemplate(dataSource); - assertThat(template.queryForObject("SELECT COUNT(*) from FOO", Integer.class)).isEqualTo(1); - }); - } - - @Test - void testDataSourceInitializedWithInvalidSchemaResource() { - this.contextRunner.withPropertyValues("spring.datasource.initialization-mode:always", - "spring.datasource.schema:classpath:does/not/exist.sql").run((context) -> { - assertThat(context).hasFailed(); - assertThat(context.getStartupFailure()).isInstanceOf(BeanCreationException.class); - assertThat(context.getStartupFailure()) - .hasMessageContaining("No schema scripts found at location 'classpath:does/not/exist.sql'"); - }); - } - - @Test - void dataSourceInitializedWithInvalidDataResource() { - this.contextRunner.withPropertyValues("spring.datasource.initialization-mode:always", - "spring.datasource.schema:" + getRelativeLocationFor("schema.sql"), - "spring.datasource.data:classpath:does/not/exist.sql").run((context) -> { - assertThat(context).hasFailed(); - assertThat(context.getStartupFailure()).isInstanceOf(BeanCreationException.class); - assertThat(context.getStartupFailure()) - .hasMessageContaining("No data scripts found at location 'classpath:does/not/exist.sql'"); - }); - } - - @Test - void whenDataSourceIsProxiedByABeanPostProcessorThenDataSourceInitializationUsesTheProxy() { - this.contextRunner.withPropertyValues("spring.datasource.initialization-mode:always") - .withUserConfiguration(DataSourceProxyConfiguration.class).run((context) -> { - assertThat(context).hasSingleBean(DataSource.class); - DataSource dataSource = context.getBean(DataSource.class); - assertThat(dataSource).isInstanceOf(DataSourceProxy.class); - assertThat(((DataSourceProxy) dataSource).connectionsRetrieved).hasPositiveValue(); - assertDataSourceIsInitialized(dataSource); - }); - } - - @Test - // gh-13042 - void whenDataSourceIsScopedAndJpaIsInvolvedThenInitializationCompletesSuccessfully() { - this.contextRunner.withPropertyValues("spring.datasource.initialization-mode:always") - .withConfiguration(AutoConfigurations.of(HibernateJpaAutoConfiguration.class)) - .withUserConfiguration(ScopedDataSourceConfiguration.class).run((context) -> { - assertThat(context).hasSingleBean(DataSource.class); - DataSource dataSource = context.getBean(DataSource.class); - assertThat(dataSource).isInstanceOf(HikariDataSource.class); - assertDataSourceIsInitialized(dataSource); - }); - } - - private String getRelativeLocationFor(String resource) { - return ClassUtils.addResourcePathToPackagePath(getClass(), resource); - } - - @Configuration(proxyBeanMethods = false) - static class OneDataSource { - - @Bean - DataSource oneDataSource() { - return new TestDataSource(true); - } - - } - - @Configuration(proxyBeanMethods = false) - static class TwoDataSources extends OneDataSource { - - @Bean - DataSource twoDataSource() { - return new TestDataSource(true); - } - - } - - /** - * {@link ResourcePatternResolver} used to ensure consistently wrong resource - * ordering. - */ - static class ReverseOrderResourceLoader implements ResourcePatternResolver { - - private final ResourcePatternResolver resolver; - - ReverseOrderResourceLoader(ResourceLoader loader) { - this.resolver = ResourcePatternUtils.getResourcePatternResolver(loader); - } - - @Override - public Resource getResource(String location) { - return this.resolver.getResource(location); - } - - @Override - public ClassLoader getClassLoader() { - return this.resolver.getClassLoader(); - } - - @Override - public Resource[] getResources(String locationPattern) throws IOException { - Resource[] resources = this.resolver.getResources(locationPattern); - Arrays.sort(resources, Comparator.comparing(Resource::getFilename).reversed()); - return resources; - } - - } - - @Configuration(proxyBeanMethods = true) - static class DataSourceProxyConfiguration { - - @Bean - static BeanPostProcessor dataSourceProxy() { - return new BeanPostProcessor() { - - @Override - public Object postProcessAfterInitialization(Object bean, String beanName) { - if (bean instanceof DataSource) { - return new DataSourceProxy((DataSource) bean); - } - return bean; - } - - }; - } - - } - - static class DataSourceProxy implements DataSource { - - private final AtomicInteger connectionsRetrieved = new AtomicInteger(); - - private final DataSource delegate; - - DataSourceProxy(DataSource delegate) { - this.delegate = delegate; - } - - @Override - public PrintWriter getLogWriter() throws SQLException { - return this.delegate.getLogWriter(); - } - - @Override - public void setLogWriter(PrintWriter out) throws SQLException { - this.delegate.setLogWriter(out); - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return this.delegate.isWrapperFor(iface); - } - - @Override - public T unwrap(Class iface) throws SQLException { - return this.delegate.unwrap(iface); - } - - @Override - public Connection getConnection() throws SQLException { - this.connectionsRetrieved.incrementAndGet(); - return this.delegate.getConnection(); - } - - @Override - public Connection getConnection(String username, String password) throws SQLException { - this.connectionsRetrieved.incrementAndGet(); - return this.delegate.getConnection(username, password); - } - - @Override - public int getLoginTimeout() throws SQLException { - return this.delegate.getLoginTimeout(); - } - - @Override - public void setLoginTimeout(int seconds) throws SQLException { - this.delegate.setLoginTimeout(seconds); - } - - @Override - public Logger getParentLogger() throws SQLFeatureNotSupportedException { - return this.delegate.getParentLogger(); - } - - } - - @Configuration(proxyBeanMethods = false) - static class ScopedDataSourceConfiguration { - - @Bean - static BeanFactoryPostProcessor fooScope() { - return (beanFactory) -> beanFactory.registerScope("test", new SimpleThreadScope()); - } - - @Bean - @Scope("test") - HikariDataSource dataSource(DataSourceProperties properties) { - return properties.initializeDataSourceBuilder().type(HikariDataSource.class).build(); - } - - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourcePropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourcePropertiesTests.java index 74b9ad9ef4..8df12bedf6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourcePropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourcePropertiesTests.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. @@ -178,24 +178,4 @@ class DataSourcePropertiesTests { assertThat(properties.determinePassword()).isNull(); } - @Test - @Deprecated - void determineCredentialsForSchemaScripts() { - DataSourceProperties properties = new DataSourceProperties(); - properties.setSchemaUsername("foo"); - properties.setSchemaPassword("bar"); - assertThat(properties.getSchemaUsername()).isEqualTo("foo"); - assertThat(properties.getSchemaPassword()).isEqualTo("bar"); - } - - @Test - @Deprecated - void determineCredentialsForDataScripts() { - DataSourceProperties properties = new DataSourceProperties(); - properties.setDataUsername("foo"); - properties.setDataPassword("bar"); - assertThat(properties.getDataUsername()).isEqualTo("foo"); - assertThat(properties.getDataPassword()).isEqualTo("bar"); - } - } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JdbcTemplateAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JdbcTemplateAutoConfigurationTests.java index 5f51ab8b73..fb4a14d9cd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JdbcTemplateAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JdbcTemplateAutoConfigurationTests.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. @@ -145,16 +145,6 @@ class JdbcTemplateAutoConfigurationTests { }); } - @Test - @Deprecated - void testDependencyToDeprecatedDataSourceInitialization() { - this.contextRunner.withUserConfiguration(DataSourceInitializationValidator.class) - .withPropertyValues("spring.datasource.initialization-mode=always").run((context) -> { - assertThat(context).hasNotFailed(); - assertThat(context.getBean(DataSourceInitializationValidator.class).count).isEqualTo(1); - }); - } - @Test void testDependencyToScriptBasedDataSourceInitialization() { this.contextRunner.withConfiguration(AutoConfigurations.of(SqlInitializationAutoConfiguration.class)) 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 b662898bdd..e2991eaebf 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 @@ -130,26 +130,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/orm/jpa/HibernateJpaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java index 838025dbc7..02732167ba 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.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. @@ -99,17 +99,6 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes super(HibernateJpaAutoConfiguration.class); } - @Test - @Deprecated - void testDataScriptWithDeprecatedMissingDdl() { - contextRunner().withPropertyValues("spring.datasource.data:classpath:/city.sql", - // Missing: - "spring.datasource.schema:classpath:/ddl.sql").run((context) -> { - assertThat(context).hasFailed(); - assertThat(context.getStartupFailure()).hasMessageContaining("ddl.sql"); - }); - } - @Test void testDmlScriptWithMissingDdl() { contextRunner().withPropertyValues("spring.sql.init.data-locations:classpath:/city.sql", @@ -120,16 +109,6 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes }); } - @Test - void testDataScript() { - // This can't succeed because the data SQL is executed immediately after the - // schema and Hibernate hasn't initialized yet at that point - contextRunner().withPropertyValues("spring.datasource.data:classpath:/city.sql").run((context) -> { - assertThat(context).hasFailed(); - assertThat(context.getStartupFailure()).isInstanceOf(BeanCreationException.class); - }); - } - @Test void testDmlScript() { // This can't succeed because the data SQL is executed immediately after the @@ -140,16 +119,6 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes }); } - @Test - @Deprecated - void testDataScriptRunsEarly() { - contextRunner().withUserConfiguration(TestInitializedJpaConfiguration.class) - .withClassLoader(new HideDataScriptClassLoader()) - .withPropertyValues("spring.jpa.show-sql=true", "spring.jpa.hibernate.ddl-auto:create-drop", - "spring.datasource.data:classpath:/city.sql", "spring.jpa.defer-datasource-initialization=true") - .run((context) -> assertThat(context.getBean(TestInitializedJpaConfiguration.class).called).isTrue()); - } - @Test void testDmlScriptRunsEarly() { contextRunner().withUserConfiguration(TestInitializedJpaConfiguration.class) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java index e0f891b3d4..874b2c56b9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.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. @@ -63,7 +63,6 @@ import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Primary; import org.springframework.core.env.Environment; import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.ResourceLoader; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.scheduling.quartz.LocalDataSourceJobStore; @@ -318,18 +317,6 @@ class QuartzAutoConfigurationTests { .doesNotHaveBean("quartzDataSourceScriptDatabaseInitializer").hasBean("customInitializer")); } - @Test - @Deprecated - @SuppressWarnings("deprecation") - void whenTheUserDefinesTheirOwnQuartzDataSourceInitializerThenTheAutoConfiguredInitializerBacksOff() { - this.contextRunner.withUserConfiguration(CustomQuartzDataSourceInitializerConfiguration.class) - .withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class, - DataSourceTransactionManagerAutoConfiguration.class)) - .withPropertyValues("spring.quartz.job-store-type=jdbc") - .run((context) -> assertThat(context).doesNotHaveBean(QuartzDataSourceScriptDatabaseInitializer.class) - .hasSingleBean(QuartzDataSourceInitializer.class).hasBean("customInitializer")); - } - @Test void whenTheUserDefinesTheirOwnDatabaseInitializerThenTheAutoConfiguredQuartzInitializerRemains() { this.contextRunner.withUserConfiguration(CustomDatabaseInitializerConfiguration.class) @@ -561,18 +548,6 @@ class QuartzAutoConfigurationTests { } - @Deprecated - @Configuration(proxyBeanMethods = false) - static class CustomQuartzDataSourceInitializerConfiguration { - - @Bean - QuartzDataSourceInitializer customInitializer(DataSource dataSource, ResourceLoader resourceLoader, - QuartzProperties properties) { - return new QuartzDataSourceInitializer(dataSource, resourceLoader, properties); - } - - } - static class ComponentThatUsesScheduler { ComponentThatUsesScheduler(Scheduler scheduler) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializerTests.java deleted file mode 100644 index 488118cb92..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceInitializerTests.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.autoconfigure.quartz; - -import java.util.UUID; - -import javax.sql.DataSource; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.assertj.AssertableApplicationContext; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.DefaultResourceLoader; -import org.springframework.core.io.ResourceLoader; -import org.springframework.jdbc.core.JdbcTemplate; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; - -/** - * Tests for {@link QuartzDataSourceInitializer}. - * - * @author Stephane Nicoll - */ -@Deprecated -class QuartzDataSourceInitializerTests { - - private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration( - AutoConfigurations.of(DataSourceAutoConfiguration.class, JdbcTemplateAutoConfiguration.class)) - .withPropertyValues("spring.datasource.url=" + String.format( - "jdbc:h2:mem:test-%s;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE", UUID.randomUUID().toString())); - - @Test - void getDatabaseNameWithPlatformDoesNotTouchDataSource() { - DataSource dataSource = mock(DataSource.class); - QuartzProperties properties = new QuartzProperties(); - properties.getJdbc().setPlatform("test"); - QuartzDataSourceInitializer initializer = new QuartzDataSourceInitializer(dataSource, - new DefaultResourceLoader(), properties); - assertThat(initializer.getDatabaseName()).isEqualTo("test"); - verifyNoInteractions(dataSource); - } - - @Test - void hashIsUsedAsACommentPrefixByDefault() { - this.contextRunner.withUserConfiguration(TestConfiguration.class).withPropertyValues( - "spring.quartz.jdbc.schema=classpath:org/springframework/boot/autoconfigure/quartz/tables_#_comments.sql") - .run(this::assertThatDataSourceHasBeenInitialized); - } - - @Test - void doubleDashIsUsedAsACommentPrefixByDefault() { - this.contextRunner.withUserConfiguration(TestConfiguration.class).withPropertyValues( - "spring.quartz.jdbc.schema=classpath:org/springframework/boot/autoconfigure/quartz/tables_--_comments.sql") - .run(this::assertThatDataSourceHasBeenInitialized); - } - - @Test - void commentPrefixCanBeCustomized() { - this.contextRunner.withUserConfiguration(TestConfiguration.class).withPropertyValues( - "spring.quartz.jdbc.comment-prefix=**", - "spring.quartz.jdbc.schema=classpath:org/springframework/boot/autoconfigure/quartz/tables_custom_comment_prefix.sql") - .run(this::assertThatDataSourceHasBeenInitialized); - } - - private void assertThatDataSourceHasBeenInitialized(AssertableApplicationContext context) { - JdbcTemplate jdbcTemplate = context.getBean(JdbcTemplate.class); - assertThat(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM QRTZ_TEST_TABLE", Integer.class)).isEqualTo(0); - } - - @Configuration(proxyBeanMethods = false) - @EnableConfigurationProperties(QuartzProperties.class) - static class TestConfiguration { - - @Bean - QuartzDataSourceInitializer initializer(DataSource dataSource, ResourceLoader resourceLoader, - QuartzProperties properties) { - return new QuartzDataSourceInitializer(dataSource, resourceLoader, properties); - } - - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationJdbcTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationJdbcTests.java index 069c2a782f..966f5dd7ab 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationJdbcTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationJdbcTests.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. @@ -40,7 +40,6 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean; 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.JdbcOperations; import org.springframework.session.FlushMode; @@ -256,19 +255,6 @@ class SessionAutoConfigurationJdbcTests extends AbstractSessionAutoConfiguration .hasBean("customInitializer")); } - @Test - @Deprecated - @SuppressWarnings("deprecation") - void whenTheUserDefinesTheirOwnJdbcSessionDataSourceInitializerThenTheAutoConfiguredInitializerBacksOff() { - this.contextRunner.withUserConfiguration(CustomJdbcSessionDataSourceInitializerConfiguration.class) - .withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class, - DataSourceTransactionManagerAutoConfiguration.class)) - .withPropertyValues("spring.session.store-type=jdbc") - .run((context) -> assertThat(context) - .doesNotHaveBean(JdbcSessionDataSourceScriptDatabaseInitializer.class) - .hasSingleBean(JdbcSessionDataSourceInitializer.class).hasBean("customInitializer")); - } - @Test void whenTheUserDefinesTheirOwnDatabaseInitializerThenTheAutoConfiguredJdbcSessionInitializerRemains() { this.contextRunner.withUserConfiguration(CustomDatabaseInitializerConfiguration.class) @@ -326,16 +312,4 @@ class SessionAutoConfigurationJdbcTests extends AbstractSessionAutoConfiguration } - @Deprecated - @Configuration(proxyBeanMethods = false) - static class CustomJdbcSessionDataSourceInitializerConfiguration { - - @Bean - JdbcSessionDataSourceInitializer customInitializer(DataSource dataSource, ResourceLoader resourceLoader, - JdbcSessionProperties properties) { - return new JdbcSessionDataSourceInitializer(dataSource, resourceLoader, properties); - } - - } - } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/sql/init/SqlInitializationAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/sql/init/SqlInitializationAutoConfigurationTests.java index c733ee39d8..d40130f181 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/sql/init/SqlInitializationAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/sql/init/SqlInitializationAutoConfigurationTests.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. @@ -67,14 +67,6 @@ class SqlInitializationAutoConfigurationTests { .run((context) -> assertThat(context).hasSingleBean(R2dbcScriptDatabaseInitializer.class)); } - @Test - @Deprecated - void whenConnectionFactoryIsAvailableAndInitializationIsDisabledThenInitializerIsNotAutoConfigured() { - this.contextRunner.withConfiguration(AutoConfigurations.of(R2dbcAutoConfiguration.class)) - .withPropertyValues("spring.sql.init.enabled:false") - .run((context) -> assertThat(context).doesNotHaveBean(AbstractScriptDatabaseInitializer.class)); - } - @Test void whenConnectionFactoryIsAvailableAndModeIsNeverThenInitializerIsNotAutoConfigured() { this.contextRunner.withConfiguration(AutoConfigurations.of(R2dbcAutoConfiguration.class)) @@ -89,14 +81,6 @@ class SqlInitializationAutoConfigurationTests { .run((context) -> assertThat(context).hasSingleBean(DataSourceScriptDatabaseInitializer.class)); } - @Test - @Deprecated - void whenDataSourceIsAvailableAndInitializationIsDisabledThenInitializerIsNotAutoConfigured() { - this.contextRunner.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)) - .withPropertyValues("spring.sql.init.enabled:false") - .run((context) -> assertThat(context).doesNotHaveBean(AbstractScriptDatabaseInitializer.class)); - } - @Test void whenDataSourceIsAvailableAndModeIsNeverThenThenInitializerIsNotAutoConfigured() { this.contextRunner.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)) @@ -170,16 +154,6 @@ class SqlInitializationAutoConfigurationTests { }); } - @Test - void whenDataSourceAutoConfigurationHasDefinedAnInitializerThenAutoConfigurationBacksOff() { - this.contextRunner.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)) - .withPropertyValues("spring.datasource.schema=classpath:schema.sql") - .withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO)).run((context) -> { - assertThat(context).hasSingleBean(SqlDataSourceScriptDatabaseInitializer.class); - assertThat(context).hasBean("scriptDataSourceInitializer"); - }); - } - @Configuration(proxyBeanMethods = false) static class SqlDatabaseInitializerConfiguration { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java index 85b61876eb..413dc19ef0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.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. @@ -40,7 +40,6 @@ import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration; import org.springframework.boot.autoconfigure.validation.ValidatorAdapter; import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration.WebFluxConfig; -import org.springframework.boot.context.properties.source.MutuallyExclusiveConfigurationPropertiesException; import org.springframework.boot.test.context.runner.ContextConsumer; import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; import org.springframework.boot.web.codec.CodecCustomizer; @@ -580,23 +579,6 @@ class WebFluxAutoConfigurationTests { }))); } - @Test - void sameSiteAttributesAreExclusive() { - this.contextRunner.withPropertyValues("spring.webflux.session.cookie.same-site:strict", - "server.reactive.session.cookie.same-site:strict").run((context) -> { - assertThat(context).hasFailed(); - assertThat(context).getFailure() - .hasRootCauseExactlyInstanceOf(MutuallyExclusiveConfigurationPropertiesException.class); - }); - } - - @Test - void deprecatedCustomSameSiteConfigurationShouldBeApplied() { - this.contextRunner.withPropertyValues("spring.webflux.session.cookie.same-site:strict").run( - assertExchangeWithSession((exchange) -> assertThat(exchange.getResponse().getCookies().get("SESSION")) - .isNotEmpty().allMatch((cookie) -> cookie.getSameSite().equals("Strict")))); - } - @Test void customSessionCookieConfigurationShouldBeApplied() { this.contextRunner.withPropertyValues("server.reactive.session.cookie.name:JSESSIONID", diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/kotlin/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/kotlin/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializerTests.java deleted file mode 100644 index 886b960903..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/kotlin/org/springframework/boot/autoconfigure/session/JdbcSessionDataSourceInitializerTests.java +++ /dev/null @@ -1,48 +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.session; - -import javax.sql.DataSource; - -import org.junit.jupiter.api.Test; - -import org.springframework.core.io.DefaultResourceLoader; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; - -/** - * Tests for {@link JdbcSessionDataSourceInitializer}. - * - * @author Stephane Nicoll - */ -@Deprecated -class JdbcSessionDataSourceInitializerTests { - - @Test - void getDatabaseNameWithPlatformDoesNotTouchDataSource() { - DataSource dataSource = mock(DataSource.class); - JdbcSessionProperties properties = new JdbcSessionProperties(); - properties.setPlatform("test"); - JdbcSessionDataSourceInitializer initializer = new JdbcSessionDataSourceInitializer(dataSource, - new DefaultResourceLoader(), properties); - assertThat(initializer.getDatabaseName()).isEqualTo("test"); - verifyNoInteractions(dataSource); - } - -} diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoader.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoader.java index 74f141709a..e988d88e25 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoader.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoader.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. @@ -23,9 +23,6 @@ import java.net.URLClassLoader; import java.security.ProtectionDomain; import java.util.Enumeration; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.springframework.boot.devtools.restart.classloader.ClassLoaderFile.Kind; import org.springframework.core.SmartClassLoader; import org.springframework.util.Assert; @@ -59,29 +56,10 @@ public class RestartClassLoader extends URLClassLoader implements SmartClassLoad * @param urls the urls managed by the classloader */ public RestartClassLoader(ClassLoader parent, URL[] urls, ClassLoaderFileRepository updatedFiles) { - this(parent, urls, updatedFiles, LogFactory.getLog(RestartClassLoader.class)); - } - - /** - * Create a new {@link RestartClassLoader} instance. - * @param parent the parent classloader - * @param updatedFiles any files that have been updated since the JARs referenced in - * URLs were created. - * @param urls the urls managed by the classloader - * @param logger the logger used for messages - * @deprecated since 2.4.11 for removal in 2.7.0 in favor of - * {@link #RestartClassLoader(ClassLoader, URL[], ClassLoaderFileRepository)} - */ - @Deprecated - public RestartClassLoader(ClassLoader parent, URL[] urls, ClassLoaderFileRepository updatedFiles, Log logger) { super(urls, parent); Assert.notNull(parent, "Parent must not be null"); Assert.notNull(updatedFiles, "UpdatedFiles must not be null"); - Assert.notNull(logger, "Logger must not be null"); this.updatedFiles = updatedFiles; - if (logger.isDebugEnabled()) { - logger.debug("Created RestartClassLoader " + toString()); - } } @Override diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java index 073e109a8b..d7603b8e57 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.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. @@ -110,19 +110,6 @@ public abstract class AbstractApplicationContextRunner, SELF> instanceFactory; - /** - * Create a new {@link AbstractApplicationContextRunner} instance. - * @param contextFactory the factory used to create the actual context - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link #AbstractApplicationContextRunner(Supplier, Function)} - */ - @Deprecated - protected AbstractApplicationContextRunner(Supplier contextFactory) { - Assert.notNull(contextFactory, "ContextFactory must not be null"); - this.runnerConfiguration = new RunnerConfiguration<>(contextFactory); - this.instanceFactory = this::legacyNewInstance; - } - /** * Create a new {@link AbstractApplicationContextRunner} instance. * @param contextFactory the factory used to create the actual context @@ -151,43 +138,6 @@ public abstract class AbstractApplicationContextRunner contextFactory, boolean allowBeanDefinitionOverriding, - List> initializers, TestPropertyValues environmentProperties, - TestPropertyValues systemProperties, ClassLoader classLoader, ApplicationContext parent, - List> beanRegistrations, List configurations) { - Assert.notNull(contextFactory, "ContextFactory must not be null"); - Assert.notNull(environmentProperties, "EnvironmentProperties must not be null"); - Assert.notNull(systemProperties, "SystemProperties must not be null"); - Assert.notNull(configurations, "Configurations must not be null"); - Assert.notNull(initializers, "Initializers must not be null"); - RunnerConfiguration configuration = new RunnerConfiguration<>(contextFactory); - configuration.allowBeanDefinitionOverriding = allowBeanDefinitionOverriding; - configuration.initializers = Collections.unmodifiableList(initializers); - configuration.environmentProperties = environmentProperties; - configuration.systemProperties = systemProperties; - configuration.classLoader = classLoader; - configuration.parent = parent; - configuration.beanRegistrations = Collections.unmodifiableList(beanRegistrations); - configuration.configurations = Collections.unmodifiableList(configurations); - this.runnerConfiguration = configuration; - this.instanceFactory = this::legacyNewInstance; - } - /** * Specify if bean definition overriding, by registering a definition with the same * name as an existing definition, should be allowed. @@ -374,20 +324,6 @@ public abstract class AbstractApplicationContextRunner configuration) { - return newInstance(configuration.contextFactory, configuration.allowBeanDefinitionOverriding, - configuration.initializers, configuration.environmentProperties, configuration.systemProperties, - configuration.classLoader, configuration.parent, configuration.beanRegistrations, - configuration.configurations); - } - - @Deprecated - protected abstract SELF newInstance(Supplier contextFactory, boolean allowBeanDefinitionOverriding, - List> initializers, TestPropertyValues environmentProperties, - TestPropertyValues systemProperties, ClassLoader classLoader, ApplicationContext parent, - List> beanRegistrations, List configurations); - private SELF newInstance(RunnerConfiguration runnerConfiguration) { return this.instanceFactory.apply(runnerConfiguration); } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/ApplicationContextRunner.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/ApplicationContextRunner.java index 7b791e98e0..83de2a500d 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/ApplicationContextRunner.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/ApplicationContextRunner.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. @@ -16,14 +16,9 @@ package org.springframework.boot.test.context.runner; -import java.util.List; import java.util.function.Supplier; -import org.springframework.boot.context.annotation.Configurations; import org.springframework.boot.test.context.assertj.AssertableApplicationContext; -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -62,27 +57,4 @@ public class ApplicationContextRunner extends super(runnerConfiguration, ApplicationContextRunner::new); } - @Deprecated - private ApplicationContextRunner(Supplier contextFactory, - boolean allowBeanDefinitionOverriding, - List> initializers, - TestPropertyValues environmentProperties, TestPropertyValues systemProperties, ClassLoader classLoader, - ApplicationContext parent, List> beanRegistrations, - List configurations) { - super(contextFactory, allowBeanDefinitionOverriding, initializers, environmentProperties, systemProperties, - classLoader, parent, beanRegistrations, configurations); - } - - @Override - @Deprecated - protected ApplicationContextRunner newInstance(Supplier contextFactory, - boolean allowBeanDefinitionOverriding, - List> initializers, - TestPropertyValues environmentProperties, TestPropertyValues systemProperties, ClassLoader classLoader, - ApplicationContext parent, List> beanRegistrations, - List configurations) { - return new ApplicationContextRunner(contextFactory, allowBeanDefinitionOverriding, initializers, - environmentProperties, systemProperties, classLoader, parent, beanRegistrations, configurations); - } - } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/ReactiveWebApplicationContextRunner.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/ReactiveWebApplicationContextRunner.java index a9f077d26f..77c99ecc5b 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/ReactiveWebApplicationContextRunner.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/ReactiveWebApplicationContextRunner.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. @@ -16,16 +16,11 @@ package org.springframework.boot.test.context.runner; -import java.util.List; import java.util.function.Supplier; -import org.springframework.boot.context.annotation.Configurations; import org.springframework.boot.test.context.assertj.AssertableReactiveWebApplicationContext; -import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext; import org.springframework.boot.web.reactive.context.ConfigurableReactiveWebApplicationContext; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextInitializer; /** * An {@link AbstractApplicationContextRunner ApplicationContext runner} for a @@ -63,27 +58,4 @@ public final class ReactiveWebApplicationContextRunner extends super(configuration, ReactiveWebApplicationContextRunner::new); } - @Deprecated - private ReactiveWebApplicationContextRunner(Supplier contextFactory, - boolean allowBeanDefinitionOverriding, - List> initializers, - TestPropertyValues environmentProperties, TestPropertyValues systemProperties, ClassLoader classLoader, - ApplicationContext parent, List> beanRegistrations, - List configurations) { - super(contextFactory, allowBeanDefinitionOverriding, initializers, environmentProperties, systemProperties, - classLoader, parent, beanRegistrations, configurations); - } - - @Override - @Deprecated - protected ReactiveWebApplicationContextRunner newInstance( - Supplier contextFactory, boolean allowBeanDefinitionOverriding, - List> initializers, - TestPropertyValues environmentProperties, TestPropertyValues systemProperties, ClassLoader classLoader, - ApplicationContext parent, List> beanRegistrations, - List configurations) { - return new ReactiveWebApplicationContextRunner(contextFactory, allowBeanDefinitionOverriding, initializers, - environmentProperties, systemProperties, classLoader, parent, beanRegistrations, configurations); - } - } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/WebApplicationContextRunner.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/WebApplicationContextRunner.java index 2566a52558..fd186a747a 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/WebApplicationContextRunner.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/WebApplicationContextRunner.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. @@ -16,15 +16,10 @@ package org.springframework.boot.test.context.runner; -import java.util.List; import java.util.function.Supplier; -import org.springframework.boot.context.annotation.Configurations; import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext; -import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextInitializer; import org.springframework.mock.web.MockServletContext; import org.springframework.web.context.ConfigurableWebApplicationContext; import org.springframework.web.context.WebApplicationContext; @@ -66,29 +61,6 @@ public final class WebApplicationContextRunner extends super(configuration, WebApplicationContextRunner::new); } - @Deprecated - private WebApplicationContextRunner(Supplier contextFactory, - boolean allowBeanDefinitionOverriding, - List> initializers, - TestPropertyValues environmentProperties, TestPropertyValues systemProperties, ClassLoader classLoader, - ApplicationContext parent, List> beanRegistrations, - List configurations) { - super(contextFactory, allowBeanDefinitionOverriding, initializers, environmentProperties, systemProperties, - classLoader, parent, beanRegistrations, configurations); - } - - @Override - @Deprecated - protected WebApplicationContextRunner newInstance(Supplier contextFactory, - boolean allowBeanDefinitionOverriding, - List> initializers, - TestPropertyValues environmentProperties, TestPropertyValues systemProperties, ClassLoader classLoader, - ApplicationContext parent, List> beanRegistrations, - List configurations) { - return new WebApplicationContextRunner(contextFactory, allowBeanDefinitionOverriding, initializers, - environmentProperties, systemProperties, classLoader, parent, beanRegistrations, configurations); - } - /** * Decorate the specified {@code contextFactory} to set a {@link MockServletContext} * on each newly created {@link WebApplicationContext}. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java index 8921aba23d..4c5942031d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.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. @@ -96,23 +96,10 @@ public abstract class Packager { * @param source the source archive file to package */ protected Packager(File source) { - this(source, null); - } - - /** - * Create a new {@link Packager} instance. - * @param source the source archive file to package - * @param layoutFactory the layout factory to use or {@code null} - * @deprecated since 2.3.10 for removal in 2.5 in favor of {@link #Packager(File)} and - * {@link #setLayoutFactory(LayoutFactory)} - */ - @Deprecated - protected Packager(File source, LayoutFactory layoutFactory) { Assert.notNull(source, "Source file must not be null"); Assert.isTrue(source.exists() && source.isFile(), () -> "Source must refer to an existing file, got " + source.getAbsolutePath()); this.source = source.getAbsoluteFile(); - this.layoutFactory = layoutFactory; } /** diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java index 329b7ce90c..aec2596eaf 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Repackager.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,18 +46,6 @@ public class Repackager extends Packager { super(source); } - /** - * Create a new {@link Repackager} instance. - * @param source the source archive file to package - * @param layoutFactory the layout factory to use or {@code null} - * @deprecated since 2.3.10 for removal in 2.5 in favor of {@link #Repackager(File)} - * and {@link #setLayoutFactory(LayoutFactory)} - */ - @Deprecated - public Repackager(File source, LayoutFactory layoutFactory) { - super(source, layoutFactory); - } - /** * Sets if source files should be backed up when they would be overwritten. * @param backupSource if source files should be backed up diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java index a2e8c249b8..f83f685d24 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.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. @@ -58,19 +58,6 @@ public abstract class Launcher { launch(args, launchClass, classLoader); } - /** - * Create a classloader for the specified archives. - * @param archives the archives - * @return the classloader - * @throws Exception if the classloader cannot be created - * @deprecated since 2.3.0 for removal in 2.5.0 in favor of - * {@link #createClassLoader(Iterator)} - */ - @Deprecated - protected ClassLoader createClassLoader(List archives) throws Exception { - return createClassLoader(archives.iterator()); - } - /** * Create a classloader for the specified archives. * @param archives the archives @@ -132,21 +119,7 @@ public abstract class Launcher { * @throws Exception if the class path archives cannot be obtained * @since 2.3.0 */ - protected Iterator getClassPathArchivesIterator() throws Exception { - return getClassPathArchives().iterator(); - } - - /** - * Returns the archives that will be used to construct the class path. - * @return the class path archives - * @throws Exception if the class path archives cannot be obtained - * @deprecated since 2.3.0 for removal in 2.5.0 in favor of implementing - * {@link #getClassPathArchivesIterator()}. - */ - @Deprecated - protected List getClassPathArchives() throws Exception { - throw new IllegalStateException("Unexpected call to getClassPathArchives()"); - } + protected abstract Iterator getClassPathArchivesIterator() throws Exception; protected final Archive createArchive() throws Exception { ProtectionDomain protectionDomain = getClass().getProtectionDomain(); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/Archive.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/Archive.java index 7b8d53e6ba..a99c1c2c22 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/Archive.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/Archive.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. @@ -20,11 +20,6 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.Iterator; -import java.util.List; -import java.util.Objects; -import java.util.Spliterator; -import java.util.Spliterators; -import java.util.function.Consumer; import java.util.jar.Manifest; import org.springframework.boot.loader.Launcher; @@ -62,67 +57,7 @@ public interface Archive extends Iterable, AutoCloseable { * @throws IOException on IO error * @since 2.3.0 */ - default Iterator getNestedArchives(EntryFilter searchFilter, EntryFilter includeFilter) - throws IOException { - EntryFilter combinedFilter = (entry) -> (searchFilter == null || searchFilter.matches(entry)) - && (includeFilter == null || includeFilter.matches(entry)); - List nestedArchives = getNestedArchives(combinedFilter); - return nestedArchives.iterator(); - } - - /** - * Returns nested {@link Archive}s for entries that match the specified filter. - * @param filter the filter used to limit entries - * @return nested archives - * @throws IOException if nested archives cannot be read - * @deprecated since 2.3.0 for removal in 2.5.0 in favor of - * {@link #getNestedArchives(EntryFilter, EntryFilter)} - */ - @Deprecated - default List getNestedArchives(EntryFilter filter) throws IOException { - throw new IllegalStateException("Unexpected call to getNestedArchives(filter)"); - } - - /** - * Return a new iterator for the archive entries. - * @deprecated since 2.3.0 for removal in 2.5.0 in favor of using - * {@link org.springframework.boot.loader.jar.JarFile} to access entries and - * {@link #getNestedArchives(EntryFilter, EntryFilter)} for accessing nested archives. - * @see java.lang.Iterable#iterator() - */ - @Deprecated - @Override - Iterator iterator(); - - /** - * Performs the given action for each element of the {@code Iterable} until all - * elements have been processed or the action throws an exception. - * @deprecated since 2.3.0 for removal in 2.5.0 in favor of using - * {@link org.springframework.boot.loader.jar.JarFile} to access entries and - * {@link #getNestedArchives(EntryFilter, EntryFilter)} for accessing nested archives. - * @see Iterable#forEach - */ - @Deprecated - @Override - default void forEach(Consumer action) { - Objects.requireNonNull(action); - for (Entry entry : this) { - action.accept(entry); - } - } - - /** - * Creates a {@link Spliterator} over the elements described by this {@code Iterable}. - * @deprecated since 2.3.0 for removal in 2.5.0 in favor of using - * {@link org.springframework.boot.loader.jar.JarFile} to access entries and - * {@link #getNestedArchives(EntryFilter, EntryFilter)} for accessing nested archives. - * @see Iterable#spliterator - */ - @Deprecated - @Override - default Spliterator spliterator() { - return Spliterators.spliteratorUnknownSize(iterator(), 0); - } + Iterator getNestedArchives(EntryFilter searchFilter, EntryFilter includeFilter) throws IOException; /** * Return if the archive is exploded (already unpacked). diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java index feb92d0bca..653b452bdd 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.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. @@ -81,20 +81,6 @@ public interface SpringApplicationRunListener { * @since 2.6.0 */ default void started(ConfigurableApplicationContext context, Duration timeTaken) { - started(context); - } - - /** - * The context has been refreshed and the application has started but - * {@link CommandLineRunner CommandLineRunners} and {@link ApplicationRunner - * ApplicationRunners} have not been called. - * @param context the application context. - * @since 2.0.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link #started(ConfigurableApplicationContext, Duration)} - */ - @Deprecated - default void started(ConfigurableApplicationContext context) { } /** @@ -107,20 +93,6 @@ public interface SpringApplicationRunListener { * @since 2.6.0 */ default void ready(ConfigurableApplicationContext context, Duration timeTaken) { - running(context); - } - - /** - * Called immediately before the run method finishes, when the application context has - * been refreshed and all {@link CommandLineRunner CommandLineRunners} and - * {@link ApplicationRunner ApplicationRunners} have been called. - * @param context the application context. - * @since 2.0.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link #ready(ConfigurableApplicationContext, Duration)} - */ - @Deprecated - default void running(ConfigurableApplicationContext context) { } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java index ac18433f34..62f06e924b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.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. @@ -102,20 +102,6 @@ public class SpringApplicationBuilder { this.application = createSpringApplication(resourceLoader, sources); } - /** - * Creates a new {@link SpringApplication} instance from the given sources. Subclasses - * may override in order to provide a custom subclass of {@link SpringApplication}. - * @param sources the sources - * @return the {@link SpringApplication} instance - * @since 1.1.0 - * @deprecated since 2.6.0 for removal in 2.8.0 in favor of - * {@link #createSpringApplication(ResourceLoader, Class...)} - */ - @Deprecated - protected SpringApplication createSpringApplication(Class... sources) { - return new SpringApplication(sources); - } - /** * Creates a new {@link SpringApplication} instance from the given sources using the * given {@link ResourceLoader}. Subclasses may override in order to provide a custom diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigData.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigData.java index 618d4e7d66..a4a0cfad1d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigData.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigData.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. @@ -88,17 +88,6 @@ public final class ConfigData { return this.propertySources; } - /** - * Return a set of {@link Option config data options} for this source. - * @return the config data options - * @deprecated since 2.4.5 in favor of {@link #getOptions(PropertySource)} - */ - @Deprecated - public Set