Do not block by default (#8580)

Currently, many timeouts in the project are like `-1` or other negative value
with a meaning to wait indefinitely.

According to distributed systems design and bad demo developing experience
it is not OK to block forever.

* Rework most of the timeouts in the framework to be `30` seconds.
Only one remained as `1` seconds is a `PollingConsumer` where it is
better to not block even for those 30 seconds when no messages in the queue,
but let the polling task be rescheduled.
* Remove the `MessagingGatewaySupport.replyTimeout` propagation down to the
`PollingConsumer` correlator where it was a `-1` before and blocked
the polling thread on the `Queue.poll()`.
This fixed the problem with a single thread in a pool for auto-configured `TaskScheduler`.
Now with 1 seconds wait time we are able to switch to other scheduled tasks
even with only 1 thread in the pool
This commit is contained in:
Artem Bilan
2023-03-21 17:43:00 -04:00
committed by GitHub
parent fcb06bac61
commit 1bec420fd1
58 changed files with 284 additions and 340 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@@ -16,19 +16,14 @@
package org.springframework.integration.aggregator;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.internal.stubbing.answers.ThrowsException;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.MessageGroupStore;
@@ -42,50 +37,53 @@ import org.springframework.messaging.MessageHandlingException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* @author Iwein Fuld
* @author Dave Syer
* @author Artme Bilan
*/
@RunWith(MockitoJUnitRunner.class)
public class CorrelatingMessageHandlerTests {
private AggregatingMessageHandler handler;
@Mock
private CorrelationStrategy correlationStrategy;
private final ReleaseStrategy ReleaseStrategy = new SequenceSizeReleaseStrategy();
@Mock
private MessageGroupProcessor processor;
@Mock
private MessageChannel outputChannel;
private final MessageGroupStore store = new SimpleMessageStore();
@Before
@BeforeEach
public void initializeSubject() {
correlationStrategy = mock(CorrelationStrategy.class);
processor = mock(MessageGroupProcessor.class);
outputChannel = mock(MessageChannel.class);
handler = new AggregatingMessageHandler(processor, store, correlationStrategy, ReleaseStrategy);
handler.setOutputChannel(outputChannel);
}
@Test
public void bufferCompletesNormally() throws Exception {
public void bufferCompletesNormally() {
String correlationKey = "key";
Message<?> message1 = testMessage(correlationKey, 1, 2);
Message<?> message2 = testMessage(correlationKey, 2, 2);
when(correlationStrategy.getCorrelationKey(isA(Message.class))).thenReturn(correlationKey);
when(processor.processMessageGroup(any(MessageGroup.class))).thenReturn(MessageBuilder.withPayload("grouped").build());
when(outputChannel.send(any(Message.class))).thenReturn(true);
when(processor.processMessageGroup(any(MessageGroup.class)))
.thenReturn(MessageBuilder.withPayload("grouped").build());
when(outputChannel.send(any(Message.class), eq(30000L))).thenReturn(true);
handler.handleMessage(message1);
@@ -135,21 +133,19 @@ public class CorrelatingMessageHandlerTests {
String correlationKey = "key";
final Message<?> message1 = testMessage(correlationKey, 1, 2);
final Message<?> message2 = testMessage(correlationKey, 2, 2);
final List<Message<?>> storedMessages = new ArrayList<Message<?>>();
final CountDownLatch bothMessagesHandled = new CountDownLatch(2);
when(correlationStrategy.getCorrelationKey(isA(Message.class))).thenReturn(correlationKey);
when(processor.processMessageGroup(any(MessageGroup.class))).thenReturn(MessageBuilder.withPayload("grouped").build());
when(outputChannel.send(any(Message.class))).thenReturn(true);
when(processor.processMessageGroup(any(MessageGroup.class)))
.thenReturn(MessageBuilder.withPayload("grouped").build());
when(outputChannel.send(any(Message.class), eq(30000L))).thenReturn(true);
handler.handleMessage(message1);
bothMessagesHandled.countDown();
storedMessages.add(message1);
ExecutorService exec = Executors.newSingleThreadExecutor();
exec.submit(() -> {
handler.handleMessage(message2);
storedMessages.add(message2);
bothMessagesHandled.countDown();
});
@@ -160,7 +156,7 @@ public class CorrelatingMessageHandlerTests {
}
@Test
public void testNullCorrelationKey() throws Exception {
public void testNullCorrelationKey() {
final Message<?> message1 = MessageBuilder.withPayload("foo").build();
when(correlationStrategy.getCorrelationKey(isA(Message.class))).thenReturn(null);
try {
@@ -169,7 +165,8 @@ public class CorrelatingMessageHandlerTests {
}
catch (MessageHandlingException e) {
Throwable cause = e.getCause();
boolean pass = cause instanceof IllegalStateException && cause.getMessage().toLowerCase().contains("null correlation");
boolean pass = cause instanceof IllegalStateException
&& cause.getMessage().toLowerCase().contains("null correlation");
if (!pass) {
throw e;
}
@@ -178,8 +175,11 @@ public class CorrelatingMessageHandlerTests {
private Message<?> testMessage(String correlationKey, int sequenceNumber, int sequenceSize) {
return MessageBuilder.withPayload("test" + sequenceNumber).setCorrelationId(correlationKey).setSequenceNumber(
sequenceNumber).setSequenceSize(sequenceSize).build();
return MessageBuilder.withPayload("test" + sequenceNumber)
.setCorrelationId(correlationKey)
.setSequenceNumber(sequenceNumber)
.setSequenceSize(sequenceSize)
.build();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@@ -59,9 +59,7 @@ public class ResequencerParserTests {
ResequencingMessageHandler resequencer = TestUtils.getPropertyValue(endpoint, "handler",
ResequencingMessageHandler.class);
assertThat(getPropertyValue(resequencer, "outputChannel")).isNull();
assertThat(getPropertyValue(
resequencer, "messagingTemplate.sendTimeout"))
.as("The ResequencerEndpoint is not set with the appropriate timeout value").isEqualTo(-1L);
assertThat(getPropertyValue(resequencer, "messagingTemplate.sendTimeout")).isEqualTo(30000L);
assertThat(getPropertyValue(resequencer, "sendPartialResultOnExpiry"))
.as("The ResequencerEndpoint is not configured with the appropriate 'send partial results on " +
"timeout'" +

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@@ -18,7 +18,7 @@ package org.springframework.integration.config.annotation;
import java.lang.reflect.Method;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.context.ApplicationContext;
@@ -51,7 +51,7 @@ public class AggregatorAnnotationTests {
assertThat(getPropertyValue(aggregator, "releaseStrategy") instanceof SimpleSequenceSizeReleaseStrategy)
.isTrue();
assertThat(getPropertyValue(aggregator, "outputChannel")).isNull();
assertThat(getPropertyValue(aggregator, "messagingTemplate.sendTimeout")).isEqualTo(-1L);
assertThat(getPropertyValue(aggregator, "messagingTemplate.sendTimeout")).isEqualTo(30000L);
assertThat(getPropertyValue(aggregator, "sendPartialResultOnExpiry")).isEqualTo(false);
context.close();
}
@@ -98,8 +98,8 @@ public class AggregatorAnnotationTests {
Object correlationStrategy = getPropertyValue(aggregator, "correlationStrategy");
assertThat(correlationStrategy instanceof MethodInvokingCorrelationStrategy).isTrue();
MethodInvokingCorrelationStrategy releaseStrategyAdapter = (MethodInvokingCorrelationStrategy) correlationStrategy;
DirectFieldAccessor processorAccessor = new DirectFieldAccessor(new DirectFieldAccessor(new DirectFieldAccessor(releaseStrategyAdapter)
.getPropertyValue("processor")).getPropertyValue("delegate"));
DirectFieldAccessor processorAccessor =
new DirectFieldAccessor(TestUtils.getPropertyValue(releaseStrategyAdapter, "processor.delegate"));
Object targetObject = processorAccessor.getPropertyValue("targetObject");
assertThat(targetObject).isSameAs(context.getBean(endpointName));
assertThat(processorAccessor.getPropertyValue("handlerMethods")).isNull();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@@ -49,7 +49,7 @@ class HeaderEnricherParserTests {
void sendTimeoutDefault() {
Object endpoint = context.getBean("headerEnricherWithDefaults");
long sendTimeout = TestUtils.getPropertyValue(endpoint, "handler.messagingTemplate.sendTimeout", Long.class);
assertThat(sendTimeout).isEqualTo(-1L);
assertThat(sendTimeout).isEqualTo(30000L);
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 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.
@@ -639,7 +639,7 @@ public class EnableIntegrationTests {
assertThat(TestUtils.getPropertyValue(consumer, "handler.outputChannelName")).isEqualTo("annOutput");
assertThat(TestUtils.getPropertyValue(consumer, "handler.discardChannelName")).isEqualTo("annOutput");
assertThat(TestUtils.getPropertyValue(consumer, "trigger.period")).isEqualTo(Duration.ofSeconds(1));
assertThat(TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout")).isEqualTo(-1L);
assertThat(TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout")).isEqualTo(30000L);
assertThat(TestUtils.getPropertyValue(consumer, "handler.sendPartialResultOnExpiry", Boolean.class)).isFalse();
consumer = this.context.getBean("annotationTestService.annAgg2.aggregator", PollingConsumer.class);

View File

@@ -91,9 +91,9 @@ public class MessagingGatewayTests {
@Test
public void sendMessage() {
Mockito.when(requestChannel.send(messageMock, 1000L)).thenReturn(true);
Mockito.when(requestChannel.send(messageMock, 30000L)).thenReturn(true);
this.messagingGateway.send(messageMock);
Mockito.verify(requestChannel).send(messageMock, 1000L);
Mockito.verify(requestChannel).send(messageMock, 30000L);
}
@Test
@@ -109,10 +109,10 @@ public class MessagingGatewayTests {
Mockito.doAnswer(invocation -> {
assertThat(((Message<?>) invocation.getArguments()[0]).getPayload()).isEqualTo("test");
return true;
}).when(requestChannel).send(Mockito.any(Message.class), Mockito.eq(1000L));
}).when(requestChannel).send(Mockito.any(Message.class), Mockito.eq(30000L));
this.messagingGateway.send("test");
Mockito.verify(requestChannel).send(Mockito.any(Message.class), Mockito.eq(1000L));
Mockito.verify(requestChannel).send(Mockito.any(Message.class), Mockito.eq(30000L));
}
@Test
@@ -136,17 +136,17 @@ public class MessagingGatewayTests {
@Test
public void receiveMessage() {
Mockito.when(replyChannel.receive(1000L)).thenReturn(messageMock);
Mockito.when(replyChannel.receive(30000L)).thenReturn(messageMock);
Mockito.when(messageMock.getPayload()).thenReturn("test");
assertThat(this.messagingGateway.receive()).isEqualTo("test");
Mockito.verify(replyChannel).receive(1000L);
Mockito.verify(replyChannel).receive(30000L);
}
@Test
public void receiveMessage_null() {
Mockito.when(replyChannel.receive(1000L)).thenReturn(null);
Mockito.when(replyChannel.receive(30000L)).thenReturn(null);
assertThat(this.messagingGateway.receive()).isNull();
Mockito.verify(replyChannel).receive(1000L);
Mockito.verify(replyChannel).receive(30000L);
}
/* send and receive tests */

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@@ -18,11 +18,9 @@ package org.springframework.integration.handler;
import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
@@ -32,8 +30,10 @@ import org.springframework.messaging.support.GenericMessage;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willReturn;
import static org.mockito.Mockito.mock;
/**
* @author Iwein Fuld
@@ -43,7 +43,6 @@ import static org.mockito.BDDMockito.willReturn;
* @author Artem Bilan
* @author Oleg Zhurakousky
*/
@RunWith(MockitoJUnitRunner.class)
public class AbstractReplyProducingMessageHandlerTests {
private final AbstractReplyProducingMessageHandler handler = new AbstractReplyProducingMessageHandler() {
@@ -57,9 +56,12 @@ public class AbstractReplyProducingMessageHandlerTests {
private final Message<?> message = MessageBuilder.withPayload("test").build();
@Mock
private final MessageChannel channel = null;
private MessageChannel channel;
@BeforeEach
void setup() {
channel = mock(MessageChannel.class);
}
@Test
public void errorMessageShouldContainChannelName() {
@@ -91,7 +93,7 @@ public class AbstractReplyProducingMessageHandlerTests {
handler.setOutputChannel(this.channel);
assertThat(handler.getNotPropagatedHeaders()).contains("f*", "*r");
ArgumentCaptor<Message<?>> captor = ArgumentCaptor.forClass(Message.class);
willReturn(true).given(this.channel).send(captor.capture());
willReturn(true).given(this.channel).send(captor.capture(), eq(30000L));
handler.handleMessage(MessageBuilder.withPayload("hello")
.setHeader("foo", "FOO")
.setHeader("bar", "BAR")
@@ -119,7 +121,7 @@ public class AbstractReplyProducingMessageHandlerTests {
assertThat(handler.getNotPropagatedHeaders()).contains("boom");
handler.setOutputChannel(this.channel);
ArgumentCaptor<Message<?>> captor = ArgumentCaptor.forClass(Message.class);
willReturn(true).given(this.channel).send(captor.capture());
willReturn(true).given(this.channel).send(captor.capture(), eq(30000L));
handler.handleMessage(MessageBuilder.withPayload("hello")
.setHeader("boom", "FOO")
.setHeader("bar", "BAR")
@@ -149,7 +151,7 @@ public class AbstractReplyProducingMessageHandlerTests {
handler.setOutputChannel(this.channel);
assertThat(handler.getNotPropagatedHeaders()).contains("foo", "b*r");
ArgumentCaptor<Message<?>> captor = ArgumentCaptor.forClass(Message.class);
willReturn(true).given(this.channel).send(captor.capture());
willReturn(true).given(this.channel).send(captor.capture(), eq(30000L));
handler.handleMessage(
MessageBuilder.withPayload("hello")
.setHeader("foo", "FOO")

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@@ -19,12 +19,9 @@ package org.springframework.integration.handler;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
@@ -35,6 +32,8 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
/**
@@ -43,21 +42,12 @@ import static org.mockito.Mockito.mock;
* @author Gary Russell
* @author Artem Bilan
*/
@RunWith(MockitoJUnitRunner.class)
public class MessageHandlerChainTests {
private final Message<String> message = MessageBuilder.withPayload("foo").build();
@Mock
private MessageChannel outputChannel;
@Mock
private MessageHandler handler1;
@Mock
private MessageHandler handler2;
@Mock
private MessageHandler handler3;
private ProducingHandlerStub producer1;
@@ -66,9 +56,13 @@ public class MessageHandlerChainTests {
private ProducingHandlerStub producer3;
@Before
@BeforeEach
public void setup() {
Mockito.when(outputChannel.send(Mockito.any(Message.class))).thenReturn(true);
outputChannel = mock(MessageChannel.class);
MessageHandler handler1 = mock(MessageHandler.class);
MessageHandler handler2 = mock(MessageHandler.class);
handler3 = mock(MessageHandler.class);
Mockito.when(outputChannel.send(Mockito.any(Message.class), eq(30000L))).thenReturn(true);
producer1 = new ProducingHandlerStub(handler1);
producer2 = new ProducingHandlerStub(handler2);
producer3 = new ProducingHandlerStub(handler3);
@@ -76,7 +70,7 @@ public class MessageHandlerChainTests {
@Test
public void chainWithOutputChannel() {
List<MessageHandler> handlers = new ArrayList<MessageHandler>();
List<MessageHandler> handlers = new ArrayList<>();
handlers.add(producer1);
handlers.add(producer2);
handlers.add(producer3);
@@ -86,12 +80,12 @@ public class MessageHandlerChainTests {
chain.setOutputChannel(outputChannel);
chain.setBeanFactory(mock(BeanFactory.class));
chain.handleMessage(message);
Mockito.verify(outputChannel).send(Mockito.eq(message));
Mockito.verify(outputChannel).send(Mockito.eq(message), eq(30000L));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void chainWithOutputChannelButLastHandlerDoesNotProduceReplies() {
List<MessageHandler> handlers = new ArrayList<MessageHandler>();
List<MessageHandler> handlers = new ArrayList<>();
handlers.add(producer1);
handlers.add(producer2);
handlers.add(handler3);
@@ -100,12 +94,12 @@ public class MessageHandlerChainTests {
chain.setHandlers(handlers);
chain.setOutputChannel(outputChannel);
chain.setBeanFactory(mock(BeanFactory.class));
chain.afterPropertiesSet();
assertThatIllegalArgumentException().isThrownBy(chain::afterPropertiesSet);
}
@Test
public void chainWithoutOutputChannelButLastHandlerDoesNotProduceReplies() {
List<MessageHandler> handlers = new ArrayList<MessageHandler>();
List<MessageHandler> handlers = new ArrayList<>();
handlers.add(producer1);
handlers.add(producer2);
handlers.add(handler3);
@@ -119,7 +113,7 @@ public class MessageHandlerChainTests {
@Test
public void chainForwardsToReplyChannel() {
Message<String> message = MessageBuilder.withPayload("test").setReplyChannel(outputChannel).build();
List<MessageHandler> handlers = new ArrayList<MessageHandler>();
List<MessageHandler> handlers = new ArrayList<>();
handlers.add(producer1);
handlers.add(producer2);
handlers.add(producer3);
@@ -128,7 +122,7 @@ public class MessageHandlerChainTests {
chain.setHandlers(handlers);
chain.setBeanFactory(mock(BeanFactory.class));
chain.handleMessage(message);
Mockito.verify(outputChannel).send(Mockito.any(Message.class));
Mockito.verify(outputChannel).send(Mockito.any(Message.class), eq(30000L));
}
@Test
@@ -136,7 +130,7 @@ public class MessageHandlerChainTests {
Message<String> message = MessageBuilder.withPayload("test").setReplyChannelName("testChannel").build();
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerSingleton("testChannel", outputChannel);
List<MessageHandler> handlers = new ArrayList<MessageHandler>();
List<MessageHandler> handlers = new ArrayList<>();
handlers.add(producer1);
handlers.add(producer2);
handlers.add(producer3);
@@ -145,14 +139,14 @@ public class MessageHandlerChainTests {
chain.setHandlers(handlers);
chain.setBeanFactory(beanFactory);
chain.handleMessage(message);
Mockito.verify(outputChannel).send(Mockito.eq(message));
Mockito.verify(outputChannel).send(Mockito.eq(message), eq(30000L));
}
@Test(expected = IllegalArgumentException.class) // INT-1175
@Test
public void chainRejectsDuplicateHandlers() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerSingleton("testChannel", outputChannel);
List<MessageHandler> handlers = new ArrayList<MessageHandler>();
List<MessageHandler> handlers = new ArrayList<>();
handlers.add(producer1);
handlers.add(producer2);
handlers.add(producer1);
@@ -160,10 +154,11 @@ public class MessageHandlerChainTests {
chain.setBeanName("testChain");
chain.setHandlers(handlers);
chain.setBeanFactory(beanFactory);
chain.afterPropertiesSet();
assertThatIllegalArgumentException().isThrownBy(chain::afterPropertiesSet);
}
private static class ProducingHandlerStub extends IntegrationObjectSupport implements MessageHandler, MessageProducer {
private static class ProducingHandlerStub extends IntegrationObjectSupport
implements MessageHandler, MessageProducer {
private volatile MessageChannel output;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@@ -16,8 +16,7 @@
package org.springframework.integration.router.config;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,8 +28,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -41,8 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 1.0.3
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
public class RecipientListRouterParserTests {
@Autowired
@@ -76,8 +73,7 @@ public class RecipientListRouterParserTests {
assertThat(handler.getClass()).isEqualTo(RecipientListRouter.class);
RecipientListRouter router = (RecipientListRouter) handler;
DirectFieldAccessor accessor = new DirectFieldAccessor(router);
assertThat(new DirectFieldAccessor(
accessor.getPropertyValue("messagingTemplate")).getPropertyValue("sendTimeout")).isEqualTo(-1L);
assertThat(TestUtils.getPropertyValue(router, "messagingTemplate.sendTimeout")).isEqualTo(30000L);
assertThat(accessor.getPropertyValue("applySequence")).isEqualTo(Boolean.FALSE);
assertThat(accessor.getPropertyValue("ignoreSendFailures")).isEqualTo(Boolean.FALSE);
}