use of org.springframework.integration.file.FileWritingMessageHandler in project spring-integration by spring-projects.
the class FileOutboundGatewayParserTests method checkOrderedGateway.
@Test
public void checkOrderedGateway() throws Exception {
DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(ordered);
FileWritingMessageHandler handler = (FileWritingMessageHandler) gatewayAccessor.getPropertyValue("handler");
assertEquals(Boolean.FALSE, gatewayAccessor.getPropertyValue("autoStartup"));
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
assertEquals(777, handlerAccessor.getPropertyValue("order"));
assertEquals(Boolean.TRUE, handlerAccessor.getPropertyValue("requiresReply"));
DefaultFileNameGenerator fileNameGenerator = (DefaultFileNameGenerator) handlerAccessor.getPropertyValue("fileNameGenerator");
assertNotNull(fileNameGenerator);
Expression expression = TestUtils.getPropertyValue(fileNameGenerator, "expression", Expression.class);
assertNotNull(expression);
assertEquals("'foo.txt'", expression.getExpressionString());
Long sendTimeout = TestUtils.getPropertyValue(handler, "messagingTemplate.sendTimeout", Long.class);
assertEquals(Long.valueOf(777), sendTimeout);
}
use of org.springframework.integration.file.FileWritingMessageHandler in project spring-integration by spring-projects.
the class FileOutboundGatewayParserTests method testOutboundGatewayWithDirectoryExpression.
@Test
public void testOutboundGatewayWithDirectoryExpression() throws Exception {
FileWritingMessageHandler handler = TestUtils.getPropertyValue(gatewayWithDirectoryExpression, "handler", FileWritingMessageHandler.class);
assertEquals("'build/foo'", TestUtils.getPropertyValue(handler, "destinationDirectoryExpression", Expression.class).getExpressionString());
handler.handleMessage(new GenericMessage<String>("foo"));
assertEquals(1, adviceCalled);
}
use of org.springframework.integration.file.FileWritingMessageHandler in project spring-boot by spring-projects.
the class SampleIntegrationApplication method fileWriter.
@Bean
public FileWritingMessageHandler fileWriter() {
FileWritingMessageHandler writer = new FileWritingMessageHandler(new File("target/output"));
writer.setExpectReply(false);
return writer;
}
use of org.springframework.integration.file.FileWritingMessageHandler in project spring-integration by spring-projects.
the class FileWritingMessageHandlerFactoryBean method createHandler.
@Override
protected FileWritingMessageHandler createHandler() {
final FileWritingMessageHandler handler;
if (this.directory != null && this.directoryExpression != null) {
throw new IllegalStateException("Cannot set both directory and directoryExpression");
} else if (this.directory != null) {
handler = new FileWritingMessageHandler(this.directory);
} else if (this.directoryExpression != null) {
handler = new FileWritingMessageHandler(this.directoryExpression);
} else {
throw new IllegalStateException("Either directory or directoryExpression must not be null");
}
if (this.charset != null) {
handler.setCharset(this.charset);
}
if (this.fileNameGenerator != null) {
handler.setFileNameGenerator(this.fileNameGenerator);
}
if (this.deleteSourceFiles != null) {
handler.setDeleteSourceFiles(this.deleteSourceFiles);
}
if (this.autoCreateDirectory != null) {
handler.setAutoCreateDirectory(this.autoCreateDirectory);
}
if (this.requiresReply != null) {
handler.setRequiresReply(this.requiresReply);
}
if (this.sendTimeout != null) {
handler.setSendTimeout(this.sendTimeout);
}
if (this.temporaryFileSuffix != null) {
handler.setTemporaryFileSuffix(this.temporaryFileSuffix);
}
handler.setExpectReply(this.expectReply);
if (this.appendNewLine != null) {
handler.setAppendNewLine(this.appendNewLine);
}
if (this.fileExistsMode != null) {
handler.setFileExistsMode(this.fileExistsMode);
}
if (this.bufferSize != null) {
handler.setBufferSize(this.bufferSize);
}
if (this.flushInterval != null) {
handler.setFlushInterval(this.flushInterval);
}
if (this.flushWhenIdle != null) {
handler.setFlushWhenIdle(this.flushWhenIdle);
}
if (this.flushPredicate != null) {
handler.setFlushPredicate(this.flushPredicate);
}
if (this.chmod != null) {
handler.setChmodOctal(this.chmod);
}
if (this.preserveTimestamp != null) {
handler.setPreserveTimestamp(this.preserveTimestamp);
}
return handler;
}
use of org.springframework.integration.file.FileWritingMessageHandler in project spring-integration by spring-projects.
the class AutoCreateDirectoryIntegrationTests method defaultOutboundGateway.
@Test
public void defaultOutboundGateway() throws Exception {
Object gateway = context.getBean("defaultOutboundGateway");
DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(gateway);
FileWritingMessageHandler handler = (FileWritingMessageHandler) gatewayAccessor.getPropertyValue("handler");
assertEquals(Boolean.TRUE, new DirectFieldAccessor(handler).getPropertyValue("autoCreateDirectory"));
assertTrue(new File(BASE_PATH + File.separator + "defaultOutboundGateway").exists());
}
Aggregations