Remove deprecated 2.2 code
See gh-19699
This commit is contained in:
committed by
Stephane Nicoll
parent
2e32cb2af1
commit
8f102aee68
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,49 +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.batch;
|
||||
|
||||
import org.springframework.batch.core.explore.JobExplorer;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
|
||||
/**
|
||||
* {@link ApplicationRunner} to {@link JobLauncher launch} Spring Batch jobs. Runs all
|
||||
* jobs in the surrounding context by default. Can also be used to launch a specific job
|
||||
* by providing a jobName
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Jean-Pierre Bergamin
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 1.0.0
|
||||
* @deprecated since 2.2.0 in favor of {@link JobLauncherApplicationRunner}
|
||||
*/
|
||||
@Deprecated
|
||||
public class JobLauncherCommandLineRunner extends JobLauncherApplicationRunner {
|
||||
|
||||
/**
|
||||
* Create a new {@link JobLauncherCommandLineRunner}.
|
||||
* @param jobLauncher to launch jobs
|
||||
* @param jobExplorer to check the job repository for previous executions
|
||||
* @param jobRepository to check if a job instance exists with the given parameters
|
||||
* when running a job
|
||||
*/
|
||||
public JobLauncherCommandLineRunner(JobLauncher jobLauncher, JobExplorer jobExplorer, JobRepository jobRepository) {
|
||||
super(jobLauncher, jobExplorer, jobRepository);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<AssertableApplicationContext> assertJpaProperties(Consumer<JpaProperties> consumer) {
|
||||
return (context) -> {
|
||||
assertThat(context).hasSingleBean(JpaProperties.class);
|
||||
consumer.accept(context.getBean(JpaProperties.class));
|
||||
};
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties(JpaProperties.class)
|
||||
static class TestConfiguration {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user