diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index 96f9c97fb33..d63b65483d2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ import org.springframework.amqp.core.AcknowledgeMode; import org.springframework.amqp.rabbit.connection.CachingConnectionFactory.CacheMode; import org.springframework.amqp.rabbit.connection.CachingConnectionFactory.ConfirmType; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.boot.convert.DurationUnit; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -289,17 +288,6 @@ public class RabbitProperties { this.requestedChannelMax = requestedChannelMax; } - @DeprecatedConfigurationProperty(reason = "replaced to support additional confirm types", - replacement = "spring.rabbitmq.publisher-confirm-type") - public boolean isPublisherConfirms() { - return ConfirmType.CORRELATED.equals(this.publisherConfirmType); - } - - @Deprecated - public void setPublisherConfirms(boolean publisherConfirms) { - this.publisherConfirmType = (publisherConfirms) ? ConfirmType.CORRELATED : ConfirmType.NONE; - } - public boolean isPublisherReturns() { return this.publisherReturns; } @@ -732,28 +720,6 @@ public class RabbitProperties { this.maxConcurrency = maxConcurrency; } - /** - * Return the number of messages processed in one transaction. - * @return the number of messages - * @deprecated since 2.2.0 in favor of {@link SimpleContainer#getBatchSize()} - */ - @DeprecatedConfigurationProperty(replacement = "spring.rabbitmq.listener.simple.batch-size") - @Deprecated - public Integer getTransactionSize() { - return getBatchSize(); - } - - /** - * Set the number of messages processed in one transaction. - * @param transactionSize the number of messages - * @deprecated since 2.2.0 in favor of - * {@link SimpleContainer#setBatchSize(Integer)} - */ - @Deprecated - public void setTransactionSize(Integer transactionSize) { - setBatchSize(transactionSize); - } - public Integer getBatchSize() { return this.batchSize; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java index 909496791f1..9a208af28e7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,8 +21,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.sql.DataSource; - import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.orm.jpa.vendor.Database; @@ -129,20 +127,4 @@ public class JpaProperties { this.openInView = openInView; } - /** - * Determine the {@link Database} to use based on this configuration and the primary - * {@link DataSource}. - * @param dataSource the auto-configured data source - * @return {@code Database} - * @deprecated since 2.2.0 in favor of letting the JPA container detect the database - * to use. - */ - @Deprecated - public Database determineDatabase(DataSource dataSource) { - if (this.database != null) { - return this.database; - } - return DatabaseLookup.getDatabase(dataSource); - } - } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java index ab80ca7500d..00b79cffe94 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -201,17 +201,6 @@ class RabbitAutoConfigurationTests { }); } - @Test - @Deprecated - void testConnectionFactoryPublisherConfirmTypeUsingDeprecatedProperty() { - this.contextRunner.withUserConfiguration(TestConfiguration.class) - .withPropertyValues("spring.rabbitmq.publisher-confirms=true").run((context) -> { - CachingConnectionFactory connectionFactory = context.getBean(CachingConnectionFactory.class); - assertThat(connectionFactory.isPublisherConfirms()).isTrue(); - assertThat(connectionFactory.isSimplePublisherConfirms()).isFalse(); - }); - } - @Test void testConnectionFactoryPublisherConfirmTypeCorrelated() { this.contextRunner.withUserConfiguration(TestConfiguration.class) @@ -459,18 +448,6 @@ class RabbitAutoConfigurationTests { }); } - @Test - @Deprecated - void testRabbitListenerContainerFactoryWithDeprecatedTransactionSizeStillWorks() { - this.contextRunner - .withUserConfiguration(MessageConvertersConfiguration.class, MessageRecoverersConfiguration.class) - .withPropertyValues("spring.rabbitmq.listener.simple.transactionSize:20").run((context) -> { - SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context - .getBean("rabbitListenerContainerFactory", SimpleRabbitListenerContainerFactory.class); - assertThat(rabbitListenerContainerFactory).hasFieldOrPropertyWithValue("batchSize", 20); - }); - } - @Test void testDirectRabbitListenerContainerFactoryWithCustomSettings() { this.contextRunner diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitPropertiesTests.java index ac84b9ff600..e2499732477 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author 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,7 +20,6 @@ import org.junit.jupiter.api.Test; import org.springframework.amqp.rabbit.config.DirectRabbitListenerContainerFactory; import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; -import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; import org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer; import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; @@ -293,24 +292,4 @@ class RabbitPropertiesTests { assertThat(container).hasFieldOrPropertyWithValue("missingQueuesFatal", direct.isMissingQueuesFatal()); } - @Test - @Deprecated - void isPublisherConfirmsShouldDefaultToFalse() { - assertThat(this.properties.isPublisherConfirms()).isEqualTo(false); - } - - @Test - @Deprecated - void isPublisherConfirmsWhenPublisherConfirmsTypeSimpleShouldBeFalse() { - this.properties.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.SIMPLE); - assertThat(this.properties.isPublisherConfirms()).isEqualTo(false); - } - - @Test - @Deprecated - void isPublisherConfirmsWhenPublisherConfirmsTypeCorrelatedShouldBeTrue() { - this.properties.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED); - assertThat(this.properties.isPublisherConfirms()).isEqualTo(true); - } - } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java deleted file mode 100644 index 2453e9d985d..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.autoconfigure.orm.jpa; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.SQLException; -import java.util.function.Consumer; - -import javax.sql.DataSource; - -import org.junit.jupiter.api.Test; - -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.boot.test.context.runner.ContextConsumer; -import org.springframework.context.annotation.Configuration; -import org.springframework.orm.jpa.vendor.Database; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - -/** - * Tests for {@link JpaProperties}. - * - * @author Stephane Nicoll - */ -class JpaPropertiesTests { - - private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withUserConfiguration(TestConfiguration.class); - - @Test - @Deprecated - @SuppressWarnings("deprecation") - void determineDatabaseNoCheckIfDatabaseIsSet() { - this.contextRunner.withPropertyValues("spring.jpa.database=postgresql") - .run(assertJpaProperties((properties) -> { - DataSource dataSource = mockStandaloneDataSource(); - Database database = properties.determineDatabase(dataSource); - assertThat(database).isEqualTo(Database.POSTGRESQL); - try { - verify(dataSource, never()).getConnection(); - } - catch (SQLException ex) { - throw new IllegalStateException("Should not happen", ex); - } - })); - } - - @Test - @Deprecated - @SuppressWarnings("deprecation") - void determineDatabaseWithKnownUrl() { - this.contextRunner.run(assertJpaProperties((properties) -> { - Database database = properties.determineDatabase(mockDataSource("jdbc:h2:mem:testdb")); - assertThat(database).isEqualTo(Database.H2); - })); - } - - @Test - @Deprecated - @SuppressWarnings("deprecation") - void determineDatabaseWithKnownUrlAndUserConfig() { - this.contextRunner.withPropertyValues("spring.jpa.database=mysql").run(assertJpaProperties((properties) -> { - Database database = properties.determineDatabase(mockDataSource("jdbc:h2:mem:testdb")); - assertThat(database).isEqualTo(Database.MYSQL); - })); - } - - @Test - @Deprecated - @SuppressWarnings("deprecation") - void determineDatabaseWithUnknownUrl() { - this.contextRunner.run(assertJpaProperties((properties) -> { - Database database = properties.determineDatabase(mockDataSource("jdbc:unknown://localhost")); - assertThat(database).isEqualTo(Database.DEFAULT); - })); - } - - private DataSource mockStandaloneDataSource() { - try { - DataSource ds = mock(DataSource.class); - given(ds.getConnection()).willThrow(SQLException.class); - return ds; - } - catch (SQLException ex) { - throw new IllegalStateException("Should not happen", ex); - } - } - - private DataSource mockDataSource(String jdbcUrl) { - DataSource ds = mock(DataSource.class); - try { - DatabaseMetaData metadata = mock(DatabaseMetaData.class); - given(metadata.getURL()).willReturn(jdbcUrl); - Connection connection = mock(Connection.class); - given(connection.getMetaData()).willReturn(metadata); - given(ds.getConnection()).willReturn(connection); - } - catch (SQLException ex) { - // Do nothing - } - return ds; - } - - private ContextConsumer assertJpaProperties(Consumer consumer) { - return (context) -> { - assertThat(context).hasSingleBean(JpaProperties.class); - consumer.accept(context.getBean(JpaProperties.class)); - }; - } - - @Configuration(proxyBeanMethods = false) - @EnableConfigurationProperties(JpaProperties.class) - static class TestConfiguration { - - } - -}