Polish @IntegrationComponentScan auto-configuration
See gh-2037 See gh-7718
This commit is contained in:
@@ -23,9 +23,8 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import sample.integration.SampleIntegrationApplication;
|
||||
import sample.integration.producer.ProducerApplication;
|
||||
@@ -48,32 +47,37 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
public class SampleIntegrationApplicationTests {
|
||||
|
||||
private static ConfigurableApplicationContext context;
|
||||
|
||||
@BeforeClass
|
||||
public static void start() throws Exception {
|
||||
context = SpringApplication.run(SampleIntegrationApplication.class);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void stop() {
|
||||
if (context != null) {
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
public void deleteOutput() {
|
||||
FileSystemUtils.deleteRecursively(new File("target/input"));
|
||||
FileSystemUtils.deleteRecursively(new File("target/output"));
|
||||
}
|
||||
|
||||
@After
|
||||
public void stop() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVanillaExchange() throws Exception {
|
||||
this.context = SpringApplication.run(SampleIntegrationApplication.class);
|
||||
SpringApplication.run(ProducerApplication.class, "World");
|
||||
String output = getOutput();
|
||||
assertThat(output).contains("Hello World");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageGateway() throws Exception {
|
||||
this.context = SpringApplication.run(SampleIntegrationApplication.class,
|
||||
"testviamg");
|
||||
String output = getOutput();
|
||||
assertThat(output).contains("testviamg");
|
||||
}
|
||||
|
||||
private String getOutput() throws Exception {
|
||||
Future<String> future = Executors.newSingleThreadExecutor()
|
||||
.submit(new Callable<String>() {
|
||||
|
||||
Reference in New Issue
Block a user