|
1 | 1 | /*
|
2 |
| - * Copyright 2014-2019 the original author or authors. |
| 2 | + * Copyright 2014-2020 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
25 | 25 | import java.io.IOException;
|
26 | 26 | import java.io.InputStream;
|
27 | 27 | import java.nio.charset.StandardCharsets;
|
| 28 | +import java.util.Iterator; |
28 | 29 | import java.util.List;
|
| 30 | +import java.util.Map; |
29 | 31 | import java.util.regex.Matcher;
|
30 | 32 |
|
31 | 33 | import org.apache.commons.net.ftp.FTPFile;
|
|
47 | 49 | import org.springframework.integration.dsl.StandardIntegrationFlow;
|
48 | 50 | import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
49 | 51 | import org.springframework.integration.dsl.context.IntegrationFlowContext.IntegrationFlowRegistration;
|
| 52 | +import org.springframework.integration.file.DefaultDirectoryScanner; |
| 53 | +import org.springframework.integration.file.DirectoryScanner; |
50 | 54 | import org.springframework.integration.file.FileHeaders;
|
51 | 55 | import org.springframework.integration.file.remote.RemoteFileTemplate;
|
52 | 56 | import org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway;
|
@@ -86,17 +90,24 @@ public class FtpTests extends FtpTestSupport {
|
86 | 90 | @Test
|
87 | 91 | public void testFtpInboundFlow() throws IOException {
|
88 | 92 | QueueChannel out = new QueueChannel();
|
| 93 | + DirectoryScanner scanner = new DefaultDirectoryScanner(); |
89 | 94 | IntegrationFlow flow = IntegrationFlows.from(Ftp.inboundAdapter(sessionFactory())
|
90 | 95 | .preserveTimestamp(true)
|
91 | 96 | .remoteDirectory("ftpSource")
|
92 | 97 | .maxFetchSize(10)
|
| 98 | + .scanner(scanner) |
93 | 99 | .regexFilter(".*\\.txt$")
|
94 | 100 | .localFilename(f -> f.toUpperCase() + ".a")
|
95 | 101 | .localDirectory(getTargetLocalDirectory()),
|
96 | 102 | e -> e.id("ftpInboundAdapter").poller(Pollers.fixedDelay(100)))
|
97 | 103 | .channel(out)
|
98 | 104 | .get();
|
99 | 105 | IntegrationFlowRegistration registration = this.flowContext.registration(flow).register();
|
| 106 | + Map<?, ?> components = TestUtils.getPropertyValue(registration, "integrationFlow.integrationComponents", Map.class); |
| 107 | + Iterator<?> iterator = components.keySet().iterator(); |
| 108 | + iterator.next(); |
| 109 | + Object spcafb = iterator.next(); |
| 110 | + assertThat(TestUtils.getPropertyValue(spcafb, "source.fileSource.scanner")).isSameAs(scanner); |
100 | 111 | Message<?> message = out.receive(10_000);
|
101 | 112 | assertThat(message).isNotNull();
|
102 | 113 | assertThat(message.getHeaders())
|
|
0 commit comments