diff --git a/applications/file-split-ftp/src/main/java/org/springframework/integration/samples/filesplit/Application.java b/applications/file-split-ftp/src/main/java/org/springframework/integration/samples/filesplit/Application.java index 458cf7bb..8cd372ee 100644 --- a/applications/file-split-ftp/src/main/java/org/springframework/integration/samples/filesplit/Application.java +++ b/applications/file-split-ftp/src/main/java/org/springframework/integration/samples/filesplit/Application.java @@ -71,7 +71,8 @@ public class Application { Files.inboundAdapter(new File("/tmp/in")) .preventDuplicates(false) .patternFilter("*.txt"), e -> e.poller(Pollers.fixedDelay(5000) - .errorChannel("tfrErrors.input"))) + .errorChannel("tfrErrors.input")) + .id("fileInboundChannelAdapter")) .handle(Files.splitter(true, true)) .>route(Object::getClass, m -> m .channelMapping(FileSplitter.FileMarker.class, "markers.input") @@ -133,7 +134,7 @@ public class Application { .enrichHeaders(Mail.headers() .subject("File successfully split and transferred") .from("foo@bar") - .toFunction(m -> new String[]{"bar@baz"})) + .toFunction(m -> new String[] { "bar@baz" })) .enrichHeaders(h -> h.header(EMAIL_SUCCESS_SUFFIX, ".success")) .channel("toMail.input"))); } @@ -176,7 +177,7 @@ public class Application { .enrichHeaders(Mail.headers() .subject("File split and transfer failed") .from("foo@bar") - .toFunction(m -> new String[]{"bar@baz"})) + .toFunction(m -> new String[] { "bar@baz" })) .enrichHeaders(h -> h.header(EMAIL_SUCCESS_SUFFIX, ".failed") .headerExpression(FileHeaders.ORIGINAL_FILE, "payload.failedMessage.headers['" + FileHeaders.ORIGINAL_FILE + "']")) diff --git a/applications/file-split-ftp/src/test/java/org/springframework/integration/samples/filesplit/ApplicationTests.java b/applications/file-split-ftp/src/test/java/org/springframework/integration/samples/filesplit/ApplicationTests.java index 1e7f57d8..5f9cbfe6 100644 --- a/applications/file-split-ftp/src/test/java/org/springframework/integration/samples/filesplit/ApplicationTests.java +++ b/applications/file-split-ftp/src/test/java/org/springframework/integration/samples/filesplit/ApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 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. @@ -44,8 +44,10 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; +import org.springframework.integration.endpoint.SourcePollingChannelAdapter; import org.springframework.integration.file.remote.session.Session; import org.springframework.integration.file.remote.session.SessionFactory; +import org.springframework.integration.test.context.SpringIntegrationTest; import org.springframework.integration.test.mail.TestMailServer; import org.springframework.integration.test.mail.TestMailServer.SmtpServer; import org.springframework.integration.test.util.TestUtils; @@ -55,6 +57,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) +@SpringIntegrationTest(noAutoStartup = "fileInboundChannelAdapter") public class ApplicationTests { private static final SmtpServer smtpServer = TestMailServer.smtp(0); @@ -62,6 +65,9 @@ public class ApplicationTests { @Autowired private Session session; + @Autowired + private SourcePollingChannelAdapter fileInboundChannelAdapter; + @BeforeClass public static void setup() { // Configure the boot property to send email to the test email server. @@ -74,6 +80,7 @@ public class ApplicationTests { @Before public void beforeTest() { smtpServer.getMessages().clear(); + this.fileInboundChannelAdapter.start(); } @SuppressWarnings("unchecked")