Browse Source

Merge pull request #23799 from garyrussell

* pr/23799:
  Polish "Remove RabbitMQ AutoConfig Boolean Coercion"
  Remove RabbitMQ AutoConfig Boolean Coercion

Closes gh-23799
pull/23886/head
Stephane Nicoll 5 years ago
parent
commit
c66ef0eb3f
  1. 3
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java
  2. 8
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java

3
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java

@ -40,9 +40,6 @@ public final class SimpleRabbitListenerContainerFactoryConfigurer
map.from(config::getMaxConcurrency).whenNonNull().to(factory::setMaxConcurrentConsumers); map.from(config::getMaxConcurrency).whenNonNull().to(factory::setMaxConcurrentConsumers);
map.from(config::getBatchSize).whenNonNull().to(factory::setBatchSize); map.from(config::getBatchSize).whenNonNull().to(factory::setBatchSize);
map.from(config::isConsumerBatchEnabled).to(factory::setConsumerBatchEnabled); map.from(config::isConsumerBatchEnabled).to(factory::setConsumerBatchEnabled);
if (config.isConsumerBatchEnabled()) {
factory.setDeBatchingEnabled(true);
}
} }
} }

8
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java

@ -33,8 +33,6 @@ import com.rabbitmq.client.impl.CredentialsRefreshService;
import com.rabbitmq.client.impl.DefaultCredentialsProvider; import com.rabbitmq.client.impl.DefaultCredentialsProvider;
import org.aopalliance.aop.Advice; import org.aopalliance.aop.Advice;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
import org.mockito.Mockito;
import org.springframework.amqp.core.AcknowledgeMode; import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.core.AmqpAdmin; import org.springframework.amqp.core.AmqpAdmin;
@ -556,17 +554,13 @@ class RabbitAutoConfigurationTests {
void testSimpleRabbitListenerContainerFactoryConfigurerEnableDeBatchingWithConsumerBatchEnabled() { void testSimpleRabbitListenerContainerFactoryConfigurerEnableDeBatchingWithConsumerBatchEnabled() {
this.contextRunner.withUserConfiguration(TestConfiguration.class) this.contextRunner.withUserConfiguration(TestConfiguration.class)
.withPropertyValues("spring.rabbitmq.listener.type:direct", .withPropertyValues("spring.rabbitmq.listener.type:direct",
"spring.rabbitmq.listener.simple.consumer-batch-enabled:true", "spring.rabbitmq.listener.simple.consumer-batch-enabled:true")
"spring.rabbitmq.listener.simple.de-batching-enabled:false")
.run((context) -> { .run((context) -> {
SimpleRabbitListenerContainerFactoryConfigurer configurer = context SimpleRabbitListenerContainerFactoryConfigurer configurer = context
.getBean(SimpleRabbitListenerContainerFactoryConfigurer.class); .getBean(SimpleRabbitListenerContainerFactoryConfigurer.class);
SimpleRabbitListenerContainerFactory factory = mock(SimpleRabbitListenerContainerFactory.class); SimpleRabbitListenerContainerFactory factory = mock(SimpleRabbitListenerContainerFactory.class);
configurer.configure(factory, mock(ConnectionFactory.class)); configurer.configure(factory, mock(ConnectionFactory.class));
InOrder inOrder = Mockito.inOrder(factory);
verify(factory).setConsumerBatchEnabled(true); verify(factory).setConsumerBatchEnabled(true);
inOrder.verify(factory).setDeBatchingEnabled(false);
inOrder.verify(factory).setDeBatchingEnabled(true);
}); });
} }

Loading…
Cancel
Save