Search in sources :

Example 11 with DefaultFileNameGenerator

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

the class FtpOutboundChannelAdapterParserTests method testBeanExpressions.

@Test
public void testBeanExpressions() throws Exception {
    FileTransferringMessageHandler<?> handler = TestUtils.getPropertyValue(withBeanExpressions, "handler", FileTransferringMessageHandler.class);
    ExpressionEvaluatingMessageProcessor<?> dirExpProc = TestUtils.getPropertyValue(handler, "remoteFileTemplate.directoryExpressionProcessor", ExpressionEvaluatingMessageProcessor.class);
    assertNotNull(dirExpProc);
    Message<String> message = MessageBuilder.withPayload("qux").build();
    assertEquals("foo", dirExpProc.processMessage(message));
    ExpressionEvaluatingMessageProcessor<?> tempDirExpProc = TestUtils.getPropertyValue(handler, "remoteFileTemplate.temporaryDirectoryExpressionProcessor", ExpressionEvaluatingMessageProcessor.class);
    assertNotNull(tempDirExpProc);
    assertEquals("bar", tempDirExpProc.processMessage(message));
    DefaultFileNameGenerator generator = TestUtils.getPropertyValue(handler, "remoteFileTemplate.fileNameGenerator", DefaultFileNameGenerator.class);
    assertNotNull(generator);
    assertEquals("baz", generator.generateFileName(message));
}
Also used : DefaultFileNameGenerator(org.springframework.integration.file.DefaultFileNameGenerator) Test(org.junit.Test)

Aggregations

DefaultFileNameGenerator (org.springframework.integration.file.DefaultFileNameGenerator)11 Test (org.junit.Test)9 File (java.io.File)6 LiteralExpression (org.springframework.expression.common.LiteralExpression)5 LsEntry (com.jcraft.jsch.ChannelSftp.LsEntry)4 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)3 BeanFactory (org.springframework.beans.factory.BeanFactory)3 FileTransferringMessageHandler (org.springframework.integration.file.remote.handler.FileTransferringMessageHandler)3 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertFalse (org.junit.Assert.assertFalse)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 RunWith (org.junit.runner.RunWith)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Bean (org.springframework.context.annotation.Bean)2 Configuration (org.springframework.context.annotation.Configuration)2 Expression (org.springframework.expression.Expression)2 FileWritingMessageHandler (org.springframework.integration.file.FileWritingMessageHandler)2 ClientCallbackWithoutResult (org.springframework.integration.file.remote.ClientCallbackWithoutResult)2 SessionCallbackWithoutResult (org.springframework.integration.file.remote.SessionCallbackWithoutResult)2