Fix ContentEnricherTests for dangling threads
https://build.spring.io/browse/INT-MJATS41-1353/ **Cherry-pick to 5.0.x and 4.3.x**
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -32,7 +32,6 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
@@ -69,14 +68,6 @@ import org.springframework.scheduling.support.PeriodicTrigger;
|
|||||||
*/
|
*/
|
||||||
public class ContentEnricherTests {
|
public class ContentEnricherTests {
|
||||||
|
|
||||||
private final ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void init() throws Exception {
|
|
||||||
taskScheduler.setPoolSize(2);
|
|
||||||
taskScheduler.afterPropertiesSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this test a {@link Target} message is passed into a {@link ContentEnricher}.
|
* In this test a {@link Target} message is passed into a {@link ContentEnricher}.
|
||||||
* The Enricher passes the message to a "request-channel" that is backed by a
|
* The Enricher passes the message to a "request-channel" that is backed by a
|
||||||
@@ -142,6 +133,11 @@ public class ContentEnricherTests {
|
|||||||
|
|
||||||
consumer.setTrigger(new PeriodicTrigger(0));
|
consumer.setTrigger(new PeriodicTrigger(0));
|
||||||
consumer.setErrorHandler(errorHandler);
|
consumer.setErrorHandler(errorHandler);
|
||||||
|
|
||||||
|
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
||||||
|
taskScheduler.setPoolSize(2);
|
||||||
|
taskScheduler.afterPropertiesSet();
|
||||||
|
|
||||||
consumer.setTaskScheduler(taskScheduler);
|
consumer.setTaskScheduler(taskScheduler);
|
||||||
consumer.setBeanFactory(mock(BeanFactory.class));
|
consumer.setBeanFactory(mock(BeanFactory.class));
|
||||||
consumer.afterPropertiesSet();
|
consumer.afterPropertiesSet();
|
||||||
@@ -158,6 +154,10 @@ public class ContentEnricherTests {
|
|||||||
e.getMessage());
|
e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
consumer.stop();
|
||||||
|
taskScheduler.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
fail("ReplyRequiredException expected.");
|
fail("ReplyRequiredException expected.");
|
||||||
|
|
||||||
@@ -474,6 +474,8 @@ public class ContentEnricherTests {
|
|||||||
assertFalse(enricher.isRunning());
|
assertFalse(enricher.isRunning());
|
||||||
enricher.start();
|
enricher.start();
|
||||||
assertTrue(enricher.isRunning());
|
assertTrue(enricher.isRunning());
|
||||||
|
|
||||||
|
enricher.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user