INT-3138: add awaitTermination to delayer tests
`DelayerHandlerRescheduleIntegrationTests` fail sometimes on asserts. Looks like `context.destroy()` works very slow and `<delayer>` manages to send delayed Messages JIRA: https://jira.springsource.org/browse/INT-3138
This commit is contained in:
committed by
Gary Russell
parent
cd256204d0
commit
77b0917190
@@ -19,12 +19,15 @@ import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.integration.handler.DelayHandler;
|
||||
import org.springframework.integration.redis.rules.RedisAvailable;
|
||||
@@ -32,6 +35,7 @@ import org.springframework.integration.redis.rules.RedisAvailableTests;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
@@ -60,10 +64,12 @@ public class DelayerHandlerRescheduleIntegrationTests extends RedisAvailableTest
|
||||
input.send(MessageBuilder.withPayload("test2").build());
|
||||
|
||||
// Emulate restart and check DB state before next start
|
||||
// Interrupt taskScheduler as quickly as possible
|
||||
ThreadPoolTaskScheduler taskScheduler = (ThreadPoolTaskScheduler) IntegrationContextUtils.getTaskScheduler(context);
|
||||
taskScheduler.shutdown();
|
||||
taskScheduler.getScheduledExecutor().awaitTermination(10, TimeUnit.SECONDS);
|
||||
context.destroy();
|
||||
|
||||
Thread.sleep(100);
|
||||
|
||||
try {
|
||||
context.getBean("input", MessageChannel.class);
|
||||
fail("IllegalStateException expected");
|
||||
|
||||
Reference in New Issue
Block a user