Search in sources :

Example 1 with SftpOutboundGateway

use of org.springframework.integration.sftp.gateway.SftpOutboundGateway in project spring-integration by spring-projects.

the class SftpOutboundGatewayParserTests method advised.

@Test
public void advised() {
    SftpOutboundGateway gateway = TestUtils.getPropertyValue(advised, "handler", SftpOutboundGateway.class);
    gateway.handleMessage(new GenericMessage<String>("foo"));
    assertEquals(1, adviceCalled);
}
Also used : SftpOutboundGateway(org.springframework.integration.sftp.gateway.SftpOutboundGateway) Test(org.junit.Test)

Example 2 with SftpOutboundGateway

use of org.springframework.integration.sftp.gateway.SftpOutboundGateway in project spring-integration by spring-projects.

the class SftpOutboundGatewayParserTests method testGatewayMv.

@Test
public void testGatewayMv() {
    SftpOutboundGateway gateway = TestUtils.getPropertyValue(gateway3, "handler", SftpOutboundGateway.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 : SftpOutboundGateway(org.springframework.integration.sftp.gateway.SftpOutboundGateway) Test(org.junit.Test)

Example 3 with SftpOutboundGateway

use of org.springframework.integration.sftp.gateway.SftpOutboundGateway in project spring-integration by spring-projects.

the class SftpOutboundGatewayParserTests method testGateway1.

@Test
public void testGateway1() {
    SftpOutboundGateway gateway = TestUtils.getPropertyValue(gateway1, "handler", SftpOutboundGateway.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((Boolean) TestUtils.getPropertyValue(gateway, "autoCreateLocalDirectory"));
    assertTrue(TestUtils.getPropertyValue(gateway, "requiresReply", 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);
    assertThat(TestUtils.getPropertyValue(gateway, "mputFilter"), Matchers.instanceOf(RegexPatternFileListFilter.class));
}
Also used : SftpOutboundGateway(org.springframework.integration.sftp.gateway.SftpOutboundGateway) Option(org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.Option) RegexPatternFileListFilter(org.springframework.integration.file.filters.RegexPatternFileListFilter) Test(org.junit.Test)

Example 4 with SftpOutboundGateway

use of org.springframework.integration.sftp.gateway.SftpOutboundGateway in project spring-integration by spring-projects.

the class SftpOutboundGatewayParserTests method testGateway2.

@Test
public void testGateway2() throws Exception {
    SftpOutboundGateway gateway = TestUtils.getPropertyValue(gateway2, "handler", SftpOutboundGateway.class);
    assertEquals("X", TestUtils.getPropertyValue(gateway, "remoteFileTemplate.remoteFileSeparator"));
    assertNotNull(TestUtils.getPropertyValue(gateway, "remoteFileTemplate.sessionFactory"));
    assertTrue(TestUtils.getPropertyValue(gateway, "remoteFileTemplate.sessionFactory") instanceof CachingSessionFactory);
    assertNotNull(TestUtils.getPropertyValue(gateway, "outputChannel"));
    assertEquals("local-test-dir", TestUtils.getPropertyValue(gateway, "localDirectoryExpression.literalValue"));
    assertFalse((Boolean) TestUtils.getPropertyValue(gateway, "autoCreateLocalDirectory"));
    assertEquals(Command.GET, TestUtils.getPropertyValue(gateway, "command"));
    assertFalse(TestUtils.getPropertyValue(gateway, "requiresReply", Boolean.class));
    @SuppressWarnings("unchecked") Set<String> options = TestUtils.getPropertyValue(gateway, "options", Set.class);
    assertTrue(options.contains(Option.PRESERVE_TIMESTAMP));
    // INT-3129
    assertNotNull(TestUtils.getPropertyValue(gateway, "localFilenameGeneratorExpression"));
    final AtomicReference<Method> genMethod = new AtomicReference<Method>();
    ReflectionUtils.doWithMethods(SftpOutboundGateway.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 : SftpOutboundGateway(org.springframework.integration.sftp.gateway.SftpOutboundGateway) GenericMessage(org.springframework.messaging.support.GenericMessage) CachingSessionFactory(org.springframework.integration.file.remote.session.CachingSessionFactory) AtomicReference(java.util.concurrent.atomic.AtomicReference) Method(java.lang.reflect.Method) SimplePatternFileListFilter(org.springframework.integration.file.filters.SimplePatternFileListFilter) Test(org.junit.Test)

Example 5 with SftpOutboundGateway

use of org.springframework.integration.sftp.gateway.SftpOutboundGateway in project spring-integration by spring-projects.

the class SftpOutboundGatewayParserTests method testGatewayMPut.

@Test
public void testGatewayMPut() {
    SftpOutboundGateway gateway = TestUtils.getPropertyValue(gateway4, "handler", SftpOutboundGateway.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 : SftpOutboundGateway(org.springframework.integration.sftp.gateway.SftpOutboundGateway) RegexPatternFileListFilter(org.springframework.integration.file.filters.RegexPatternFileListFilter) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 SftpOutboundGateway (org.springframework.integration.sftp.gateway.SftpOutboundGateway)5 RegexPatternFileListFilter (org.springframework.integration.file.filters.RegexPatternFileListFilter)2 Method (java.lang.reflect.Method)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)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