DSL: Fix Tail Tests

Timing problem - set end(false), don't start adapter until file
is written.
This commit is contained in:
Gary Russell
2014-09-07 16:28:14 -05:00
parent ff4a229bc5
commit 070252961d

View File

@@ -121,6 +121,7 @@ import org.springframework.integration.file.DefaultFileNameGenerator;
import org.springframework.integration.file.FileHeaders;
import org.springframework.integration.file.remote.RemoteFileTemplate;
import org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway;
import org.springframework.integration.file.tail.ApacheCommonsFileTailingMessageProducer;
import org.springframework.integration.ftp.session.DefaultFtpSessionFactory;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice;
@@ -162,6 +163,7 @@ import org.springframework.util.StreamUtils;
import com.jcraft.jsch.ChannelSftp;
import com.mongodb.MongoClient;
import de.flapdoodle.embed.mongo.MongodExecutable;
import de.flapdoodle.embed.mongo.MongodStarter;
import de.flapdoodle.embed.mongo.config.MongodConfigBuilder;
@@ -339,6 +341,9 @@ public class IntegrationFlowTests {
@Qualifier("tailChannel")
private PollableChannel tailChannel;
@Autowired
private ApacheCommonsFileTailingMessageProducer tailer;
@Autowired
private AmqpTemplate amqpTemplate;
@@ -947,7 +952,7 @@ public class IntegrationFlowTests {
for (int i = 0; i < 50; i++) {
file.write((i + "\n").getBytes());
}
this.tailer.start();
for (int i = 0; i < 50; i++) {
Message<?> message = this.tailChannel.receive(5000);
assertNotNull(message);
@@ -1870,8 +1875,10 @@ public class IntegrationFlowTests {
@Bean
public IntegrationFlow tailFlow() {
return IntegrationFlows.from(Files.tailAdapter(new File(tmpDir, "TailTest"))
.delay(500)
.id("tailer"))
.delay(500)
.end(false)
.id("tailer")
.autoStartup(false))
.transform("hello "::concat)
.channel(MessageChannels.queue("tailChannel"))
.get();