17
17
package org .springframework .boot .autoconfigure .amqp ;
18
18
19
19
import java .security .NoSuchAlgorithmException ;
20
+ import java .util .List ;
20
21
import java .util .concurrent .atomic .AtomicInteger ;
21
22
22
23
import javax .net .ssl .SSLContext ;
@@ -125,6 +126,7 @@ void testDefaultConnectionFactoryConfiguration() {
125
126
}
126
127
127
128
@ Test
129
+ @ SuppressWarnings ("unchecked" )
128
130
void testConnectionFactoryWithOverrides () {
129
131
this .contextRunner .withUserConfiguration (TestConfiguration .class )
130
132
.withPropertyValues ("spring.rabbitmq.host:remote-server" , "spring.rabbitmq.port:9000" ,
@@ -137,15 +139,16 @@ void testConnectionFactoryWithOverrides() {
137
139
assertThat (connectionFactory .getVirtualHost ()).isEqualTo ("/vhost" );
138
140
com .rabbitmq .client .ConnectionFactory rcf = connectionFactory .getRabbitConnectionFactory ();
139
141
assertThat (rcf .getConnectionTimeout ()).isEqualTo (123 );
140
- assertThat ((Address [] ) ReflectionTestUtils .getField (connectionFactory , "addresses" )).hasSize (1 );
142
+ assertThat ((List < Address > ) ReflectionTestUtils .getField (connectionFactory , "addresses" )).hasSize (1 );
141
143
});
142
144
}
143
145
144
146
@ Test
147
+ @ SuppressWarnings ("unchecked" )
145
148
void testConnectionFactoryWithCustomConnectionNameStrategy () {
146
149
this .contextRunner .withUserConfiguration (ConnectionNameStrategyConfiguration .class ).run ((context ) -> {
147
150
CachingConnectionFactory connectionFactory = context .getBean (CachingConnectionFactory .class );
148
- Address [] addresses = (Address [] ) ReflectionTestUtils .getField (connectionFactory , "addresses" );
151
+ List < Address > addresses = (List < Address > ) ReflectionTestUtils .getField (connectionFactory , "addresses" );
149
152
assertThat (addresses ).hasSize (1 );
150
153
com .rabbitmq .client .ConnectionFactory rcf = mock (com .rabbitmq .client .ConnectionFactory .class );
151
154
given (rcf .newConnection (isNull (), eq (addresses ), anyString ())).willReturn (mock (Connection .class ));
@@ -363,8 +366,8 @@ void testRabbitListenerContainerFactoryBackOff() {
363
366
this .contextRunner .withUserConfiguration (TestConfiguration5 .class ).run ((context ) -> {
364
367
SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context
365
368
.getBean ("rabbitListenerContainerFactory" , SimpleRabbitListenerContainerFactory .class );
366
- rabbitListenerContainerFactory .setTxSize (10 );
367
- verify (rabbitListenerContainerFactory ).setTxSize (10 );
369
+ rabbitListenerContainerFactory .setBatchSize (10 );
370
+ verify (rabbitListenerContainerFactory ).setBatchSize (10 );
368
371
assertThat (rabbitListenerContainerFactory .getAdviceChain ()).isNull ();
369
372
});
370
373
}
@@ -385,20 +388,32 @@ void testSimpleRabbitListenerContainerFactoryWithCustomSettings() {
385
388
"spring.rabbitmq.listener.simple.prefetch:40" ,
386
389
"spring.rabbitmq.listener.simple.defaultRequeueRejected:false" ,
387
390
"spring.rabbitmq.listener.simple.idleEventInterval:5" ,
388
- "spring.rabbitmq.listener.simple.transactionSize :20" ,
391
+ "spring.rabbitmq.listener.simple.batchSize :20" ,
389
392
"spring.rabbitmq.listener.simple.missingQueuesFatal:false" )
390
393
.run ((context ) -> {
391
394
SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context
392
395
.getBean ("rabbitListenerContainerFactory" , SimpleRabbitListenerContainerFactory .class );
393
396
assertThat (rabbitListenerContainerFactory ).hasFieldOrPropertyWithValue ("concurrentConsumers" , 5 );
394
397
assertThat (rabbitListenerContainerFactory ).hasFieldOrPropertyWithValue ("maxConcurrentConsumers" ,
395
398
10 );
396
- assertThat (rabbitListenerContainerFactory ).hasFieldOrPropertyWithValue ("txSize " , 20 );
399
+ assertThat (rabbitListenerContainerFactory ).hasFieldOrPropertyWithValue ("batchSize " , 20 );
397
400
assertThat (rabbitListenerContainerFactory ).hasFieldOrPropertyWithValue ("missingQueuesFatal" , false );
398
401
checkCommonProps (context , rabbitListenerContainerFactory );
399
402
});
400
403
}
401
404
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
+
402
417
@ Test
403
418
void testDirectRabbitListenerContainerFactoryWithCustomSettings () {
404
419
this .contextRunner
0 commit comments