Skip to content

Commit 7899c64

Browse files
committed
Improve Mock Test Runtime
Set shutdown timeout to 0, especially when changing queues.
1 parent 681075d commit 7899c64

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/listener/SimpleMessageListenerContainerTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public void testDefaultConsumerCount() {
159159
container.setMessageListener(new MessageListenerAdapter(this));
160160
container.setQueueNames("foo");
161161
container.setAutoStartup(false);
162+
container.setShutdownTimeout(0);
162163
container.afterPropertiesSet();
163164
assertThat(ReflectionTestUtils.getField(container, "concurrentConsumers")).isEqualTo(1);
164165
container.stop();
@@ -262,6 +263,8 @@ public void testTxSizeAcksWIthShortSet() throws Exception {
262263
container.setQueueNames("foobar");
263264
container.setBatchSize(2);
264265
container.setMessageListener(messages::add);
266+
container.setShutdownTimeout(0);
267+
container.afterPropertiesSet();
265268
container.start();
266269
BasicProperties props = new BasicProperties();
267270
byte[] payload = "baz".getBytes();
@@ -308,6 +311,7 @@ public void testConsumerArgs() throws Exception {
308311
container.setMessageListener(message -> {
309312
});
310313
container.setConsumerArguments(Collections.singletonMap("x-priority", 10));
314+
container.setShutdownTimeout(0);
311315
container.afterPropertiesSet();
312316
container.start();
313317
verify(channel).basicConsume(anyString(), anyBoolean(), anyString(), anyBoolean(), anyBoolean(),
@@ -343,6 +347,7 @@ public void testChangeQueues() throws Exception {
343347
container.setReceiveTimeout(1);
344348
container.setMessageListener(message -> {
345349
});
350+
container.setShutdownTimeout(0);
346351
container.afterPropertiesSet();
347352
container.start();
348353
assertThat(latch1.await(10, TimeUnit.SECONDS)).isTrue();
@@ -389,6 +394,7 @@ public void testAddQueuesAndStartInCycle() throws Exception {
389394
final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
390395
container.setMessageListener(message -> {
391396
});
397+
container.setShutdownTimeout(0);
392398
container.afterPropertiesSet();
393399

394400
for (int i = 0; i < 10; i++) {

0 commit comments

Comments
 (0)