Skip to content

Commit

Permalink
INTEXT-87: Add local-filter attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
artembilan committed Apr 26, 2018
1 parent d938146 commit c5602c4
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,26 @@
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="local-filter" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type
type="org.springframework.integration.file.filters.FileListFilter" />
</tool:annotation>
</xsd:appinfo>
<xsd:documentation>
Allows you to specify a reference to a
[org.springframework.integration.file.filters.FileListFilter]
bean. This filter is applied to files after they have been
retrieved. The default is an AcceptOnceFileListFilter which means that,
even if a new instance of a file is retrieved from the remote server,
a message won't be generated. The filter provided here is combined
with a filter that prevents the message source from processing
files that are currently being downloaded.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="local-directory" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,53 +1,58 @@
<?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:p="http://www.springframework.org/schema/p"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-smb="http://www.springframework.org/schema/integration/smb"
xsi:schemaLocation="http://www.springframework.org/schema/beans
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-smb="http://www.springframework.org/schema/integration/smb"
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.xsd
http://www.springframework.org/schema/integration/smb
http://www.springframework.org/schema/integration/smb/spring-integration-smb.xsd">

<bean id="smbSessionFactory"
class="org.springframework.integration.smb.config.SmbInboundChannelAdapterParserTests.TestSessionFactoryBean"/>
class="org.springframework.integration.smb.config.SmbInboundChannelAdapterParserTests.TestSessionFactoryBean"/>

<bean id="acceptAllFilter" class="org.springframework.integration.file.filters.AcceptAllFileListFilter"/>

<int-smb:inbound-channel-adapter id="smbInbound"
channel="smbChannel"
session-factory="smbSessionFactory"
charset="UTF-8"
auto-create-local-directory="true"
delete-remote-files="true"
filename-pattern="*.txt"
local-directory="file:test-temp/local-1"
remote-file-separator=""
comparator="comparator"
temporary-file-suffix=".working.tmp"
remote-directory="test-temp/remote-1">
auto-startup="false"
channel="smbChannel"
session-factory="smbSessionFactory"
charset="UTF-8"
auto-create-local-directory="true"
delete-remote-files="true"
filename-pattern="*.txt"
local-filter="acceptAllFilter"
local-directory="file:test-temp/local-1"
remote-file-separator=""
comparator="comparator"
temporary-file-suffix=".working.tmp"
remote-directory="test-temp/remote-1">
</int-smb:inbound-channel-adapter>

<bean id="comparator" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="java.util.Comparator"/>
</bean>

<int-smb:inbound-channel-adapter
channel="smbChannel"
session-factory="smbSessionFactory"
charset="UTF-8"
auto-create-local-directory="true"
delete-remote-files="true"
filter="entryListFilter"
local-directory="file:test-temp/local-2"
remote-directory="test-temp/remote-2">
channel="smbChannel"
auto-startup="false"
session-factory="smbSessionFactory"
charset="UTF-8"
auto-create-local-directory="true"
delete-remote-files="true"
filter="entryListFilter"
local-directory="file:test-temp/local-2"
remote-directory="test-temp/remote-2">
</int-smb:inbound-channel-adapter>

<int-smb:inbound-channel-adapter id="simpleAdapter"
channel="smbChannel"
session-factory="smbSessionFactory"
local-directory="file:test-temp/local-3"
remote-directory="test-temp/remote-3">
channel="smbChannel"
auto-startup="false"
session-factory="smbSessionFactory"
local-directory="file:test-temp/local-3"
remote-directory="test-temp/remote-3">
</int-smb:inbound-channel-adapter>

<int:channel id="smbChannel">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -69,7 +70,6 @@ public void testSmbInboundChannelAdapterComplete() {
assertNotNull(queue.comparator());
assertEquals("smbInbound", adapter.getComponentName());
assertEquals("smb:inbound-channel-adapter", adapter.getComponentType());
assertNotNull(TestUtils.getPropertyValue(adapter, "poller"));
assertEquals(applicationContext.getBean("smbChannel"), TestUtils.getPropertyValue(adapter, "outputChannel"));
SmbInboundFileSynchronizingMessageSource inbound =
(SmbInboundFileSynchronizingMessageSource) TestUtils.getPropertyValue(adapter, "source");
Expand All @@ -90,6 +90,10 @@ public void testSmbInboundChannelAdapterComplete() {
assertThat(filtersIterator.next(), instanceOf(SmbPersistentAcceptOnceFileListFilter.class));
Object sessionFactory = TestUtils.getPropertyValue(fisync, "remoteFileTemplate.sessionFactory");
assertTrue(SmbSessionFactory.class.isAssignableFrom(sessionFactory.getClass()));

FileListFilter<?> acceptAllFilter = this.applicationContext.getBean("acceptAllFilter", FileListFilter.class);
assertTrue(TestUtils.getPropertyValue(inbound, "fileSource.scanner.filter.fileFilters", Collection.class)
.contains(acceptAllFilter));
}

@Test
Expand Down

0 comments on commit c5602c4

Please sign in to comment.