INT-2235-updated

added default filter as AcceptOnceCollectionFilter, chanhged parser to allow filter= to allow null filter
This commit is contained in:
Oleg Zhurakousky
2011-11-23 14:49:46 -05:00
committed by Mark Fisher
parent 6fbdd71aae
commit 34c51eb635
5 changed files with 101 additions and 95 deletions

View File

@@ -16,11 +16,6 @@
package org.springframework.integration.resource;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.Collection;
@@ -36,6 +31,12 @@ import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.util.CollectionFilter;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
* @author Oleg Zhurakousky
* @since 2.1
@@ -114,6 +115,22 @@ public class ResourceInboundChannelAdapterParserTests {
assertNotNull(message);
assertTrue(customFilter.invoked);
}
@Test
public void testUsageWithEmptyFilter() throws Exception{
File baseDir = new File(System.getProperty("java.io.tmpdir"));
for (int i = 0; i < 10; i++) {
File f = new File(baseDir, "testUsageWithRf"+i);
f.createNewFile();
}
ApplicationContext context = new ClassPathXmlApplicationContext("ResourcePatternResolver-config-usage-emptyref.xml", this.getClass());
SourcePollingChannelAdapter resourceAdapter = context.getBean("resourceAdapterDefault", SourcePollingChannelAdapter.class);
ResourceRetrievingMessageSource source = TestUtils.getPropertyValue(resourceAdapter, "source", ResourceRetrievingMessageSource.class);
assertNotNull(source);
assertNull(TestUtils.getPropertyValue(source, "filter"));
}
public static class TestCollectionFilter implements CollectionFilter<Resource> {

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsd">
<int:resource-inbound-channel-adapter id="resourceAdapterDefault" channel="resultChannel"
pattern="file:#{T(java.lang.System).getProperty('java.io.tmpdir') + T(java.lang.System).getProperty('file.separator') + 'testUsage*'}"
filter="" auto-startup="false">
<int:poller fixed-rate="500"/>
</int:resource-inbound-channel-adapter>
<int:channel id="resultChannel">
<int:queue/>
</int:channel>
</beans>