INT-1856 added support for filename-generator-expression to outbound file adapters, added tests
This commit is contained in:
@@ -18,7 +18,8 @@
|
||||
<file:outbound-channel-adapter id="simpleAdapter"
|
||||
channel="testChannel"
|
||||
directory="${java.io.tmpdir}"
|
||||
temporary-file-suffix=".foo"/>
|
||||
temporary-file-suffix=".foo"
|
||||
filename-generator-expression="'foo.txt'"/>
|
||||
|
||||
<file:outbound-channel-adapter id="adapterWithCustomNameGenerator"
|
||||
channel="testChannel"
|
||||
|
||||
@@ -16,22 +16,27 @@
|
||||
|
||||
package org.springframework.integration.file.config;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.file.DefaultFileNameGenerator;
|
||||
import org.springframework.integration.file.FileWritingMessageHandler;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Marius Bogoevici
|
||||
@@ -66,7 +71,11 @@ public class FileOutboundChannelAdapterParserTests {
|
||||
File actual = (File) handlerAccessor.getPropertyValue("destinationDirectory");
|
||||
assertEquals(".foo", handler.getTemporaryFileSuffix());
|
||||
assertThat(actual, is(expected));
|
||||
assertThat(handlerAccessor.getPropertyValue("fileNameGenerator"), is(DefaultFileNameGenerator.class));
|
||||
DefaultFileNameGenerator fileNameGenerator = (DefaultFileNameGenerator) handlerAccessor.getPropertyValue("fileNameGenerator");
|
||||
assertNotNull(fileNameGenerator);
|
||||
String expression = (String) TestUtils.getPropertyValue(fileNameGenerator, "expression");
|
||||
assertNotNull(expression);
|
||||
assertEquals("'foo.txt'", expression);
|
||||
assertEquals(Boolean.FALSE, handlerAccessor.getPropertyValue("deleteSourceFiles"));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
request-channel="someChannel"
|
||||
directory="${java.io.tmpdir}"
|
||||
auto-startup="false"
|
||||
order="777"/>
|
||||
order="777"
|
||||
filename-generator-expression="'foo.txt'"/>
|
||||
|
||||
<context:property-placeholder />
|
||||
|
||||
|
||||
@@ -21,11 +21,14 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.integration.file.DefaultFileNameGenerator;
|
||||
import org.springframework.integration.file.FileWritingMessageHandler;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -47,6 +50,11 @@ public class FileOutboundGatewayParserTests {
|
||||
assertEquals(Boolean.FALSE, gatewayAccessor.getPropertyValue("autoStartup"));
|
||||
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
|
||||
assertEquals(777, handlerAccessor.getPropertyValue("order"));
|
||||
DefaultFileNameGenerator fileNameGenerator = (DefaultFileNameGenerator) handlerAccessor.getPropertyValue("fileNameGenerator");
|
||||
assertNotNull(fileNameGenerator);
|
||||
String expression = (String) TestUtils.getPropertyValue(fileNameGenerator, "expression");
|
||||
assertNotNull(expression);
|
||||
assertEquals("'foo.txt'", expression);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user