Search in sources :

Example 1 with FileToStringTransformer

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

the class Files method toStringTransformer.

/**
 * Create a {@link FileToStringTransformer} instance with provided {@code charset} and delete files flag.
 * @param charset The charset.
 * @param deleteFiles true to delete the file.
 * @return the {@link FileToStringTransformer}.
 */
public static FileToStringTransformer toStringTransformer(String charset, boolean deleteFiles) {
    FileToStringTransformer transformer = new FileToStringTransformer();
    if (charset != null) {
        transformer.setCharset(charset);
    }
    transformer.setDeleteFiles(deleteFiles);
    return transformer;
}
Also used : FileToStringTransformer(org.springframework.integration.file.transformer.FileToStringTransformer)

Example 2 with FileToStringTransformer

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

the class FileToStringTransformerParserTests method checkDeleteFilesValue.

@Test
public void checkDeleteFilesValue() {
    DirectFieldAccessor endpointAccessor = new DirectFieldAccessor(endpoint);
    MessageTransformingHandler handler = (MessageTransformingHandler) endpointAccessor.getPropertyValue("handler");
    DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
    FileToStringTransformer transformer = (FileToStringTransformer) handlerAccessor.getPropertyValue("transformer");
    DirectFieldAccessor transformerAccessor = new DirectFieldAccessor(transformer);
    assertEquals(Boolean.TRUE, transformerAccessor.getPropertyValue("deleteFiles"));
}
Also used : MessageTransformingHandler(org.springframework.integration.transformer.MessageTransformingHandler) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) FileToStringTransformer(org.springframework.integration.file.transformer.FileToStringTransformer) Test(org.junit.Test)

Aggregations

FileToStringTransformer (org.springframework.integration.file.transformer.FileToStringTransformer)2 Test (org.junit.Test)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 MessageTransformingHandler (org.springframework.integration.transformer.MessageTransformingHandler)1