Search in sources :

Example 11 with FileWritingMessageHandler

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

the class FileOutboundChannelAdapterParserTests method adapterWithOrder.

@Test
public void adapterWithOrder() {
    DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapterWithOrder);
    FileWritingMessageHandler handler = (FileWritingMessageHandler) adapterAccessor.getPropertyValue("handler");
    DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
    assertEquals(555, handlerAccessor.getPropertyValue("order"));
}
Also used : DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) FileWritingMessageHandler(org.springframework.integration.file.FileWritingMessageHandler) Test(org.junit.Test)

Example 12 with FileWritingMessageHandler

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

the class FileOutboundChannelAdapterParserTests method adapterWithDirectoryExpression.

@Test
public void adapterWithDirectoryExpression() {
    FileWritingMessageHandler handler = TestUtils.getPropertyValue(adapterWithDirectoryExpression, "handler", FileWritingMessageHandler.class);
    Method m = ReflectionUtils.findMethod(FileWritingMessageHandler.class, "getTemporaryFileSuffix");
    ReflectionUtils.makeAccessible(m);
    assertEquals(".writing", ReflectionUtils.invokeMethod(m, handler));
    String expectedExpressionString = "'foo/bar'";
    String actualExpressionString = TestUtils.getPropertyValue(handler, "destinationDirectoryExpression", Expression.class).getExpressionString();
    assertEquals(expectedExpressionString, actualExpressionString);
}
Also used : Expression(org.springframework.expression.Expression) FileWritingMessageHandler(org.springframework.integration.file.FileWritingMessageHandler) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 13 with FileWritingMessageHandler

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

the class FileOutboundChannelAdapterParserTests method adapterWithCustomFileNameGenerator.

@Test
public void adapterWithCustomFileNameGenerator() {
    DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapterWithCustomNameGenerator);
    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(expected, actual);
    assertTrue(handlerAccessor.getPropertyValue("fileNameGenerator") instanceof CustomFileNameGenerator);
    assertEquals(".writing", handlerAccessor.getPropertyValue("temporaryFileSuffix"));
    assertEquals(Boolean.FALSE, handlerAccessor.getPropertyValue("flushWhenIdle"));
}
Also used : Expression(org.springframework.expression.Expression) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) FileWritingMessageHandler(org.springframework.integration.file.FileWritingMessageHandler) File(java.io.File) Test(org.junit.Test)

Example 14 with FileWritingMessageHandler

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

the class FileOutboundChannelAdapterParserTests method adapterWithDeleteFlag.

@Test
public void adapterWithDeleteFlag() {
    DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapterWithDeleteFlag);
    FileWritingMessageHandler handler = (FileWritingMessageHandler) adapterAccessor.getPropertyValue("handler");
    DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
    assertEquals(Boolean.TRUE, handlerAccessor.getPropertyValue("deleteSourceFiles"));
}
Also used : DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) FileWritingMessageHandler(org.springframework.integration.file.FileWritingMessageHandler) Test(org.junit.Test)

Example 15 with FileWritingMessageHandler

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

the class FileOutboundChannelAdapterParserTests method adapterWithFlushing.

@Test
public void adapterWithFlushing() {
    DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapterWithFlushing);
    FileWritingMessageHandler handler = (FileWritingMessageHandler) adapterAccessor.getPropertyValue("handler");
    DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
    assertEquals(4096, handlerAccessor.getPropertyValue("bufferSize"));
    assertEquals(12345L, handlerAccessor.getPropertyValue("flushInterval"));
    assertEquals(FileExistsMode.APPEND_NO_FLUSH, handlerAccessor.getPropertyValue("fileExistsMode"));
    assertSame(this.predicate, handlerAccessor.getPropertyValue("flushPredicate"));
}
Also used : DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) FileWritingMessageHandler(org.springframework.integration.file.FileWritingMessageHandler) 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