Search in sources :

Example 1 with FileInfo

use of org.springframework.integration.file.remote.FileInfo in project spring-integration by spring-projects.

the class FtpOutboundTests method testFtpOutboundGatewayInsideChain.

// INT-2275
@Test
public void testFtpOutboundGatewayInsideChain() throws Exception {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("FtpOutboundInsideChainTests-context.xml", getClass());
    MessageChannel channel = context.getBean("ftpOutboundGatewayInsideChain", MessageChannel.class);
    channel.send(MessageBuilder.withPayload("remote-test-dir").build());
    PollableChannel output = context.getBean("output", PollableChannel.class);
    Message<?> result = output.receive();
    Object payload = result.getPayload();
    assertTrue(payload instanceof List<?>);
    @SuppressWarnings("unchecked") List<? extends FileInfo<?>> remoteFiles = (List<? extends FileInfo<?>>) payload;
    assertEquals(3, remoteFiles.size());
    List<String> files = Arrays.asList(new File("remote-test-dir").list());
    for (FileInfo<?> remoteFile : remoteFiles) {
        assertTrue(files.contains(remoteFile.getFilename()));
    }
    context.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) MessageChannel(org.springframework.messaging.MessageChannel) FileInfo(org.springframework.integration.file.remote.FileInfo) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) FTPFile(org.apache.commons.net.ftp.FTPFile) Test(org.junit.Test)

Example 2 with FileInfo

use of org.springframework.integration.file.remote.FileInfo in project spring-integration by spring-projects.

the class SftpOutboundTests method testFtpOutboundGatewayInsideChain.

// INT-2275
@Test
public void testFtpOutboundGatewayInsideChain() throws Exception {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("SftpOutboundInsideChainTests-context.xml", getClass());
    MessageChannel channel = context.getBean("outboundGatewayInsideChain", MessageChannel.class);
    channel.send(MessageBuilder.withPayload("remote-test-dir").build());
    PollableChannel output = context.getBean("replyChannel", PollableChannel.class);
    Message<?> result = output.receive();
    Object payload = result.getPayload();
    assertTrue(payload instanceof List<?>);
    @SuppressWarnings("unchecked") List<? extends FileInfo<?>> remoteFiles = (List<? extends FileInfo<?>>) payload;
    assertEquals(3, remoteFiles.size());
    List<String> files = Arrays.asList(new File("remote-test-dir").list());
    for (FileInfo<?> remoteFile : remoteFiles) {
        assertTrue(files.contains(remoteFile.getFilename()));
    }
    context.close();
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MessageChannel(org.springframework.messaging.MessageChannel) FileInfo(org.springframework.integration.file.remote.FileInfo) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) List(java.util.List) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Test (org.junit.Test)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 FileInfo (org.springframework.integration.file.remote.FileInfo)2 MessageChannel (org.springframework.messaging.MessageChannel)2 PollableChannel (org.springframework.messaging.PollableChannel)2 FTPFile (org.apache.commons.net.ftp.FTPFile)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1