diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/ContentEnricherTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/ContentEnricherTests.java index 8ee909f1fc..cd5cfea576 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/ContentEnricherTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/ContentEnricherTests.java @@ -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"); * 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.Map; -import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.BeanFactory; @@ -69,14 +68,6 @@ import org.springframework.scheduling.support.PeriodicTrigger; */ 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}. * 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.setErrorHandler(errorHandler); + + ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); + taskScheduler.setPoolSize(2); + taskScheduler.afterPropertiesSet(); + consumer.setTaskScheduler(taskScheduler); consumer.setBeanFactory(mock(BeanFactory.class)); consumer.afterPropertiesSet(); @@ -158,6 +154,10 @@ public class ContentEnricherTests { e.getMessage()); return; } + finally { + consumer.stop(); + taskScheduler.destroy(); + } fail("ReplyRequiredException expected."); @@ -474,6 +474,8 @@ public class ContentEnricherTests { assertFalse(enricher.isRunning()); enricher.start(); assertTrue(enricher.isRunning()); + + enricher.stop(); } /**