Search in sources :

Example 6 with FileWritingMessageHandler

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

the class AutoCreateDirectoryIntegrationTests method customOutboundGateway.

@Test
public void customOutboundGateway() throws Exception {
    Object gateway = context.getBean("customOutboundGateway");
    DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(gateway);
    FileWritingMessageHandler handler = (FileWritingMessageHandler) gatewayAccessor.getPropertyValue("handler");
    assertTrue(new File(BASE_PATH + File.separator + "customOutboundGateway").exists());
    assertEquals(Boolean.FALSE, new DirectFieldAccessor(handler).getPropertyValue("autoCreateDirectory"));
}
Also used : DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) FileWritingMessageHandler(org.springframework.integration.file.FileWritingMessageHandler) File(java.io.File) Test(org.junit.Test)

Example 7 with FileWritingMessageHandler

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

the class AutoCreateDirectoryIntegrationTests method customOutbound.

@Test
public void customOutbound() throws Exception {
    Object adapter = context.getBean("customOutbound");
    DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
    FileWritingMessageHandler handler = (FileWritingMessageHandler) adapterAccessor.getPropertyValue("handler");
    assertTrue(new File(BASE_PATH + File.separator + "customOutbound").exists());
    assertEquals(Boolean.FALSE, new DirectFieldAccessor(handler).getPropertyValue("autoCreateDirectory"));
}
Also used : DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) FileWritingMessageHandler(org.springframework.integration.file.FileWritingMessageHandler) File(java.io.File) Test(org.junit.Test)

Example 8 with FileWritingMessageHandler

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

the class AutoCreateDirectoryIntegrationTests method defaultOutbound.

@Test
public void defaultOutbound() throws Exception {
    Object adapter = context.getBean("defaultOutbound");
    DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
    FileWritingMessageHandler handler = (FileWritingMessageHandler) adapterAccessor.getPropertyValue("handler");
    assertEquals(Boolean.TRUE, new DirectFieldAccessor(handler).getPropertyValue("autoCreateDirectory"));
    assertTrue(new File(BASE_PATH + File.separator + "defaultOutbound").exists());
}
Also used : DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) FileWritingMessageHandler(org.springframework.integration.file.FileWritingMessageHandler) File(java.io.File) Test(org.junit.Test)

Example 9 with FileWritingMessageHandler

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

the class FileOutboundChannelAdapterParserTests method adapterWithCharset.

@Test
public void adapterWithCharset() {
    DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapterWithCharset);
    FileWritingMessageHandler handler = (FileWritingMessageHandler) adapterAccessor.getPropertyValue("handler");
    DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
    assertEquals(Charset.forName("UTF-8"), handlerAccessor.getPropertyValue("charset"));
}
Also used : DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) FileWritingMessageHandler(org.springframework.integration.file.FileWritingMessageHandler) Test(org.junit.Test)

Example 10 with FileWritingMessageHandler

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

the class FileOutboundChannelAdapterParserTests method simpleAdapter.

@Test
public void simpleAdapter() {
    DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(simpleAdapter);
    FileWritingMessageHandler handler = (FileWritingMessageHandler) adapterAccessor.getPropertyValue("handler");
    DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
    File expected = new File(System.getProperty("java.io.tmpdir"));
    Expression destinationDirectoryExpression = (Expression) handlerAccessor.getPropertyValue("destinationDirectoryExpression");
    File actual = new File(destinationDirectoryExpression.getExpressionString());
    assertEquals(".foo", TestUtils.getPropertyValue(handler, "temporaryFileSuffix", String.class));
    assertThat(actual, is(expected));
    DefaultFileNameGenerator fileNameGenerator = (DefaultFileNameGenerator) handlerAccessor.getPropertyValue("fileNameGenerator");
    assertNotNull(fileNameGenerator);
    Expression expression = TestUtils.getPropertyValue(fileNameGenerator, "expression", Expression.class);
    assertNotNull(expression);
    assertEquals("'foo.txt'", expression.getExpressionString());
    assertEquals(Boolean.FALSE, handlerAccessor.getPropertyValue("deleteSourceFiles"));
    assertEquals(Boolean.TRUE, handlerAccessor.getPropertyValue("flushWhenIdle"));
    if (FileUtils.IS_POSIX) {
        assertThat(TestUtils.getPropertyValue(handler, "permissions", Set.class).size(), equalTo(9));
    }
    assertEquals(Boolean.TRUE, handlerAccessor.getPropertyValue("preserveTimestamp"));
}
Also used : Expression(org.springframework.expression.Expression) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) FileWritingMessageHandler(org.springframework.integration.file.FileWritingMessageHandler) File(java.io.File) DefaultFileNameGenerator(org.springframework.integration.file.DefaultFileNameGenerator) Test(org.junit.Test)

Aggregations

FileWritingMessageHandler (org.springframework.integration.file.FileWritingMessageHandler)17 Test (org.junit.Test)13 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)11 File (java.io.File)8 Expression (org.springframework.expression.Expression)4 Bean (org.springframework.context.annotation.Bean)3 DefaultFileNameGenerator (org.springframework.integration.file.DefaultFileNameGenerator)2 Method (java.lang.reflect.Method)1 ServiceActivator (org.springframework.integration.annotation.ServiceActivator)1