1717package org .springframework .boot .autoconfigure .amqp ;
1818
1919import java .security .NoSuchAlgorithmException ;
20+ import java .util .List ;
2021import java .util .concurrent .atomic .AtomicInteger ;
2122
2223import javax .net .ssl .SSLContext ;
@@ -125,6 +126,7 @@ void testDefaultConnectionFactoryConfiguration() {
125126 }
126127
127128 @ Test
129+ @ SuppressWarnings ("unchecked" )
128130 void testConnectionFactoryWithOverrides () {
129131 this .contextRunner .withUserConfiguration (TestConfiguration .class )
130132 .withPropertyValues ("spring.rabbitmq.host:remote-server" , "spring.rabbitmq.port:9000" ,
@@ -137,15 +139,16 @@ void testConnectionFactoryWithOverrides() {
137139 assertThat (connectionFactory .getVirtualHost ()).isEqualTo ("/vhost" );
138140 com .rabbitmq .client .ConnectionFactory rcf = connectionFactory .getRabbitConnectionFactory ();
139141 assertThat (rcf .getConnectionTimeout ()).isEqualTo (123 );
140- assertThat ((Address [] ) ReflectionTestUtils .getField (connectionFactory , "addresses" )).hasSize (1 );
142+ assertThat ((List < Address > ) ReflectionTestUtils .getField (connectionFactory , "addresses" )).hasSize (1 );
141143 });
142144 }
143145
144146 @ Test
147+ @ SuppressWarnings ("unchecked" )
145148 void testConnectionFactoryWithCustomConnectionNameStrategy () {
146149 this .contextRunner .withUserConfiguration (ConnectionNameStrategyConfiguration .class ).run ((context ) -> {
147150 CachingConnectionFactory connectionFactory = context .getBean (CachingConnectionFactory .class );
148- Address [] addresses = (Address [] ) ReflectionTestUtils .getField (connectionFactory , "addresses" );
151+ List < Address > addresses = (List < Address > ) ReflectionTestUtils .getField (connectionFactory , "addresses" );
149152 assertThat (addresses ).hasSize (1 );
150153 com .rabbitmq .client .ConnectionFactory rcf = mock (com .rabbitmq .client .ConnectionFactory .class );
151154 given (rcf .newConnection (isNull (), eq (addresses ), anyString ())).willReturn (mock (Connection .class ));
@@ -363,8 +366,8 @@ void testRabbitListenerContainerFactoryBackOff() {
363366 this .contextRunner .withUserConfiguration (TestConfiguration5 .class ).run ((context ) -> {
364367 SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context
365368 .getBean ("rabbitListenerContainerFactory" , SimpleRabbitListenerContainerFactory .class );
366- rabbitListenerContainerFactory .setTxSize (10 );
367- verify (rabbitListenerContainerFactory ).setTxSize (10 );
369+ rabbitListenerContainerFactory .setBatchSize (10 );
370+ verify (rabbitListenerContainerFactory ).setBatchSize (10 );
368371 assertThat (rabbitListenerContainerFactory .getAdviceChain ()).isNull ();
369372 });
370373 }
@@ -385,20 +388,32 @@ void testSimpleRabbitListenerContainerFactoryWithCustomSettings() {
385388 "spring.rabbitmq.listener.simple.prefetch:40" ,
386389 "spring.rabbitmq.listener.simple.defaultRequeueRejected:false" ,
387390 "spring.rabbitmq.listener.simple.idleEventInterval:5" ,
388- "spring.rabbitmq.listener.simple.transactionSize :20" ,
391+ "spring.rabbitmq.listener.simple.batchSize :20" ,
389392 "spring.rabbitmq.listener.simple.missingQueuesFatal:false" )
390393 .run ((context ) -> {
391394 SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context
392395 .getBean ("rabbitListenerContainerFactory" , SimpleRabbitListenerContainerFactory .class );
393396 assertThat (rabbitListenerContainerFactory ).hasFieldOrPropertyWithValue ("concurrentConsumers" , 5 );
394397 assertThat (rabbitListenerContainerFactory ).hasFieldOrPropertyWithValue ("maxConcurrentConsumers" ,
395398 10 );
396- assertThat (rabbitListenerContainerFactory ).hasFieldOrPropertyWithValue ("txSize " , 20 );
399+ assertThat (rabbitListenerContainerFactory ).hasFieldOrPropertyWithValue ("batchSize " , 20 );
397400 assertThat (rabbitListenerContainerFactory ).hasFieldOrPropertyWithValue ("missingQueuesFatal" , false );
398401 checkCommonProps (context , rabbitListenerContainerFactory );
399402 });
400403 }
401404
405+ @ Test
406+ @ Deprecated
407+ void testRabbitListenerContainerFactoryWithDeprecatedTransactionSizeStillWorks () {
408+ this .contextRunner
409+ .withUserConfiguration (MessageConvertersConfiguration .class , MessageRecoverersConfiguration .class )
410+ .withPropertyValues ("spring.rabbitmq.listener.simple.transactionSize:20" ).run ((context ) -> {
411+ SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context
412+ .getBean ("rabbitListenerContainerFactory" , SimpleRabbitListenerContainerFactory .class );
413+ assertThat (rabbitListenerContainerFactory ).hasFieldOrPropertyWithValue ("batchSize" , 20 );
414+ });
415+ }
416+
402417 @ Test
403418 void testDirectRabbitListenerContainerFactoryWithCustomSettings () {
404419 this .contextRunner
0 commit comments