Search in sources :

Example 1 with FtpOutboundGateway

use of org.springframework.integration.ftp.gateway.FtpOutboundGateway in project spring-integration by spring-projects.

the class FtpOutboundGatewayParserTests method testGateway2.

@Test
public void testGateway2() throws Exception {
    FtpOutboundGateway gateway = TestUtils.getPropertyValue(gateway2, "handler", FtpOutboundGateway.class);
    assertEquals("X", TestUtils.getPropertyValue(gateway, "remoteFileTemplate.remoteFileSeparator"));
    assertNotNull(TestUtils.getPropertyValue(gateway, "remoteFileTemplate.sessionFactory"));
    assertThat(TestUtils.getPropertyValue(gateway, "remoteFileTemplate.sessionFactory"), Matchers.instanceOf(CachingSessionFactory.class));
    assertEquals(FtpRemoteFileTemplate.ExistsMode.NLST, TestUtils.getPropertyValue(gateway, "remoteFileTemplate.existsMode"));
    assertNotNull(TestUtils.getPropertyValue(gateway, "outputChannel"));
    assertEquals("local-test-dir", TestUtils.getPropertyValue(gateway, "localDirectoryExpression.literalValue"));
    assertFalse(TestUtils.getPropertyValue(gateway, "autoCreateLocalDirectory", Boolean.class));
    assertEquals(Command.GET, TestUtils.getPropertyValue(gateway, "command"));
    @SuppressWarnings("unchecked") Set<String> options = TestUtils.getPropertyValue(gateway, "options", Set.class);
    assertTrue(options.contains(Option.PRESERVE_TIMESTAMP));
    gateway.handleMessage(new GenericMessage<String>("foo"));
    assertFalse(TestUtils.getPropertyValue(gateway, "requiresReply", Boolean.class));
    assertEquals(1, adviceCalled);
    // INT-3129
    assertNotNull(TestUtils.getPropertyValue(gateway, "localFilenameGeneratorExpression"));
    final AtomicReference<Method> genMethod = new AtomicReference<Method>();
    ReflectionUtils.doWithMethods(FtpOutboundGateway.class, method -> {
        method.setAccessible(true);
        genMethod.set(method);
    }, method -> "generateLocalFileName".equals(method.getName()));
    assertEquals("FOO.afoo", genMethod.get().invoke(gateway, new GenericMessage<String>(""), "foo"));
    assertThat(TestUtils.getPropertyValue(gateway, "mputFilter"), Matchers.instanceOf(SimplePatternFileListFilter.class));
}
Also used : GenericMessage(org.springframework.messaging.support.GenericMessage) CachingSessionFactory(org.springframework.integration.file.remote.session.CachingSessionFactory) FtpOutboundGateway(org.springframework.integration.ftp.gateway.FtpOutboundGateway) AtomicReference(java.util.concurrent.atomic.AtomicReference) Method(java.lang.reflect.Method) SimplePatternFileListFilter(org.springframework.integration.file.filters.SimplePatternFileListFilter) Test(org.junit.Test)

Example 2 with FtpOutboundGateway

use of org.springframework.integration.ftp.gateway.FtpOutboundGateway in project spring-integration by spring-projects.

the class FtpOutboundGatewayParserTests method testWithBeanExpression.

@Test
public void testWithBeanExpression() {
    FtpOutboundGateway gateway = TestUtils.getPropertyValue(withBeanExpression, "handler", FtpOutboundGateway.class);
    ExpressionEvaluatingMessageProcessor<?> processor = TestUtils.getPropertyValue(gateway, "fileNameProcessor", ExpressionEvaluatingMessageProcessor.class);
    assertNotNull(processor);
    assertEquals("foo", processor.processMessage(MessageBuilder.withPayload("bar").build()));
}
Also used : FtpOutboundGateway(org.springframework.integration.ftp.gateway.FtpOutboundGateway) Test(org.junit.Test)

Example 3 with FtpOutboundGateway

use of org.springframework.integration.ftp.gateway.FtpOutboundGateway in project spring-integration by spring-projects.

the class FtpOutboundGatewayParserTests method testGatewayMv.

@Test
public void testGatewayMv() {
    FtpOutboundGateway gateway = TestUtils.getPropertyValue(gateway3, "handler", FtpOutboundGateway.class);
    assertNotNull(TestUtils.getPropertyValue(gateway, "remoteFileTemplate.sessionFactory"));
    assertNotNull(TestUtils.getPropertyValue(gateway, "outputChannel"));
    assertEquals(Command.MV, TestUtils.getPropertyValue(gateway, "command"));
    assertEquals("'foo'", TestUtils.getPropertyValue(gateway, "renameProcessor.expression.expression"));
}
Also used : FtpOutboundGateway(org.springframework.integration.ftp.gateway.FtpOutboundGateway) Test(org.junit.Test)

Example 4 with FtpOutboundGateway

use of org.springframework.integration.ftp.gateway.FtpOutboundGateway in project spring-integration by spring-projects.

the class FtpOutboundGatewayParserTests method testGatewayMPut.

@Test
public void testGatewayMPut() {
    FtpOutboundGateway gateway = TestUtils.getPropertyValue(gateway4, "handler", FtpOutboundGateway.class);
    assertNotNull(TestUtils.getPropertyValue(gateway, "remoteFileTemplate.sessionFactory"));
    assertNotNull(TestUtils.getPropertyValue(gateway, "outputChannel"));
    assertEquals(Command.MPUT, TestUtils.getPropertyValue(gateway, "command"));
    assertEquals("'foo'", TestUtils.getPropertyValue(gateway, "renameProcessor.expression.expression"));
    assertThat(TestUtils.getPropertyValue(gateway, "mputFilter"), Matchers.instanceOf(RegexPatternFileListFilter.class));
    assertSame(generator, TestUtils.getPropertyValue(gateway, "remoteFileTemplate.fileNameGenerator"));
    assertEquals("/foo", TestUtils.getPropertyValue(gateway, "remoteFileTemplate.directoryExpressionProcessor.expression", Expression.class).getExpressionString());
    assertEquals("/bar", TestUtils.getPropertyValue(gateway, "remoteFileTemplate.temporaryDirectoryExpressionProcessor.expression", Expression.class).getExpressionString());
}
Also used : FtpOutboundGateway(org.springframework.integration.ftp.gateway.FtpOutboundGateway) RegexPatternFileListFilter(org.springframework.integration.file.filters.RegexPatternFileListFilter) Test(org.junit.Test)

Example 5 with FtpOutboundGateway

use of org.springframework.integration.ftp.gateway.FtpOutboundGateway in project spring-integration by spring-projects.

the class FtpOutboundGatewayParserTests method testGateway1.

@Test
public void testGateway1() {
    FtpOutboundGateway gateway = TestUtils.getPropertyValue(gateway1, "handler", FtpOutboundGateway.class);
    assertEquals("X", TestUtils.getPropertyValue(gateway, "remoteFileTemplate.remoteFileSeparator"));
    assertNotNull(TestUtils.getPropertyValue(gateway, "remoteFileTemplate.sessionFactory"));
    assertNotNull(TestUtils.getPropertyValue(gateway, "outputChannel"));
    assertEquals("local-test-dir", TestUtils.getPropertyValue(gateway, "localDirectoryExpression.literalValue"));
    assertFalse(TestUtils.getPropertyValue(gateway, "autoCreateLocalDirectory", Boolean.class));
    assertNotNull(TestUtils.getPropertyValue(gateway, "filter"));
    assertEquals(Command.LS, TestUtils.getPropertyValue(gateway, "command"));
    @SuppressWarnings("unchecked") Set<Option> options = TestUtils.getPropertyValue(gateway, "options", Set.class);
    assertTrue(options.contains(Option.NAME_ONLY));
    assertTrue(options.contains(Option.NOSORT));
    Long sendTimeout = TestUtils.getPropertyValue(gateway, "messagingTemplate.sendTimeout", Long.class);
    assertEquals(Long.valueOf(777), sendTimeout);
    assertTrue(TestUtils.getPropertyValue(gateway, "requiresReply", Boolean.class));
    assertThat(TestUtils.getPropertyValue(gateway, "mputFilter"), Matchers.instanceOf(ExpressionFileListFilter.class));
    assertEquals(FileExistsMode.APPEND, TestUtils.getPropertyValue(gateway, "fileExistsMode"));
}
Also used : ExpressionFileListFilter(org.springframework.integration.file.filters.ExpressionFileListFilter) FtpOutboundGateway(org.springframework.integration.ftp.gateway.FtpOutboundGateway) Option(org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.Option) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 FtpOutboundGateway (org.springframework.integration.ftp.gateway.FtpOutboundGateway)5 Method (java.lang.reflect.Method)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 ExpressionFileListFilter (org.springframework.integration.file.filters.ExpressionFileListFilter)1 RegexPatternFileListFilter (org.springframework.integration.file.filters.RegexPatternFileListFilter)1 SimplePatternFileListFilter (org.springframework.integration.file.filters.SimplePatternFileListFilter)1 Option (org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.Option)1 CachingSessionFactory (org.springframework.integration.file.remote.session.CachingSessionFactory)1 GenericMessage (org.springframework.messaging.support.GenericMessage)1