Component docs - fixed issue with file not including all of them
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b76ae186 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b76ae186 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b76ae186 Branch: refs/heads/camel-2.16.x Commit: b76ae1868e40c6384e0322a178f7e0a08dbba2c6 Parents: 920a0d5 Author: Claus Ibsen <davscl...@apache.org> Authored: Sat Jan 2 23:38:25 2016 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sat Jan 2 23:54:32 2016 +0100 ---------------------------------------------------------------------- .../component/file/GenericFileEndpoint.java | 37 +++++++++++++------- .../AntPathMatcherGenericFileFilterTest.java | 12 ------- 2 files changed, 24 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/b76ae186/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java index c81e2d3..434af2f 100644 --- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java +++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java @@ -145,6 +145,8 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple protected IdempotentRepository<String> idempotentRepository; @UriParam(label = "consumer,filter") protected GenericFileFilter<T> filter; + @UriParam(label = "consumer,filter", defaultValue = "true") + protected boolean antFilterCaseSensitive = true; protected volatile AntPathMatcherGenericFileFilter<T> antFilter; @UriParam(label = "consumer,filter") protected String antInclude; @@ -451,10 +453,6 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple */ public void setAntInclude(String antInclude) { this.antInclude = antInclude; - if (this.antFilter == null) { - this.antFilter = new AntPathMatcherGenericFileFilter<T>(); - } - this.antFilter.setIncludes(antInclude); } public String getAntExclude() { @@ -467,20 +465,17 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple */ public void setAntExclude(String antExclude) { this.antExclude = antExclude; - if (this.antFilter == null) { - this.antFilter = new AntPathMatcherGenericFileFilter<T>(); - } - this.antFilter.setExcludes(antExclude); + } + + public boolean isAntFilterCaseSensitive() { + return antFilterCaseSensitive; } /** - * Sets case sensitive flag on {@link org.apache.camel.component.file.AntPathMatcherFileFilter} + * Sets case sensitive flag on ant fiter */ public void setAntFilterCaseSensitive(boolean antFilterCaseSensitive) { - if (this.antFilter == null) { - this.antFilter = new AntPathMatcherGenericFileFilter<T>(); - } - this.antFilter.setCaseSensitive(antFilterCaseSensitive); + this.antFilterCaseSensitive = antFilterCaseSensitive; } public GenericFileFilter<T> getAntFilter() { @@ -1417,6 +1412,22 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple throw new IllegalArgumentException("IdempotentRepository must be configured when using readLock=idempotent"); } + if (antInclude != null) { + if (antFilter == null) { + antFilter = new AntPathMatcherGenericFileFilter<>(); + } + antFilter.setIncludes(antInclude); + } + if (antExclude != null) { + if (antFilter == null) { + antFilter = new AntPathMatcherGenericFileFilter<>(); + } + antFilter.setExcludes(antExclude); + } + if (antFilter != null) { + antFilter.setCaseSensitive(antFilterCaseSensitive); + } + // idempotent repository may be used by others, so add it as a service so its stopped when CamelContext stops if (idempotentRepository != null) { getCamelContext().addService(idempotentRepository, true); http://git-wip-us.apache.org/repos/asf/camel/blob/b76ae186/camel-core/src/test/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilterTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilterTest.java b/camel-core/src/test/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilterTest.java index 229bee8..1e4c36a 100644 --- a/camel-core/src/test/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilterTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilterTest.java @@ -49,7 +49,6 @@ public class AntPathMatcherGenericFileFilterTest extends ContextTestSupport { public void testInclude() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result1"); mock.expectedBodiesReceivedInAnyOrder("Hello World"); - mock.setExpectedMessageCount(1); template.sendBodyAndHeader("file://target/files/ant-path-1/x/y/z", "Hello World", Exchange.FILE_NAME, "report.txt"); template.sendBodyAndHeader("file://target/files/ant-path-1/x/y/z", "Hello World 2", Exchange.FILE_NAME, "b.TXT"); @@ -60,7 +59,6 @@ public class AntPathMatcherGenericFileFilterTest extends ContextTestSupport { public void testExclude() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result2"); mock.expectedBodiesReceivedInAnyOrder("Hello World 2", "Hello World 3", "Hello World 4"); - mock.setExpectedMessageCount(3); template.sendBodyAndHeader("file://target/files/ant-path-2/x/y/z", "Hello World 1", Exchange.FILE_NAME, "report.bak"); template.sendBodyAndHeader("file://target/files/ant-path-2/x/y/z", "Hello World 2", Exchange.FILE_NAME, "report.txt"); @@ -73,7 +71,6 @@ public class AntPathMatcherGenericFileFilterTest extends ContextTestSupport { public void testIncludesAndExcludes() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result3"); mock.expectedBodiesReceivedInAnyOrder("Hello World 2", "Hello World 4"); - mock.setExpectedMessageCount(2); template.sendBodyAndHeader("file://target/files/ant-path-3/x/y/z", "Hello World 1", Exchange.FILE_NAME, "a.pdf"); template.sendBodyAndHeader("file://target/files/ant-path-3/x/y/z", "Hello World 2", Exchange.FILE_NAME, "m.pdf"); @@ -94,7 +91,6 @@ public class AntPathMatcherGenericFileFilterTest extends ContextTestSupport { public void testIncludesAndExcludesAndFilter() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result4"); mock.expectedBodiesReceivedInAnyOrder("Hello World 3"); - mock.setExpectedMessageCount(1); template.sendBodyAndHeader("file://target/files/ant-path-4/x/y/z", "Hello World 1", Exchange.FILE_NAME, "a.txt"); template.sendBodyAndHeader("file://target/files/ant-path-4/x/y/z", "Hello World 2", Exchange.FILE_NAME, "b.txt"); @@ -108,7 +104,6 @@ public class AntPathMatcherGenericFileFilterTest extends ContextTestSupport { public void testIncludeAndAntFilterNotCaseSensitive() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result5"); mock.expectedBodiesReceivedInAnyOrder("Hello World"); - mock.setExpectedMessageCount(1); template.sendBodyAndHeader("file://target/files/ant-path-5/x/y/z", "Hello World", Exchange.FILE_NAME, "report.TXT"); @@ -118,7 +113,6 @@ public class AntPathMatcherGenericFileFilterTest extends ContextTestSupport { public void testExcludeAndAntFilterNotCaseSensitive() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result6"); mock.expectedBodiesReceivedInAnyOrder("Hello World 2", "Hello World 4"); - mock.setExpectedMessageCount(2); template.sendBodyAndHeader("file://target/files/ant-path-6/x/y/z", "Hello World 1", Exchange.FILE_NAME, "report.bak"); template.sendBodyAndHeader("file://target/files/ant-path-6/x/y/z", "Hello World 2", Exchange.FILE_NAME, "report.txt"); @@ -131,7 +125,6 @@ public class AntPathMatcherGenericFileFilterTest extends ContextTestSupport { public void testIncludesAndExcludesAndAntFilterNotCaseSensitive() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result7"); mock.expectedBodiesReceivedInAnyOrder("Hello World 2", "Hello World 4", "Hello World 8", "Hello World 10"); - mock.setExpectedMessageCount(4); template.sendBodyAndHeader("file://target/files/ant-path-7/x/y/z", "Hello World 1", Exchange.FILE_NAME, "a.pdf"); template.sendBodyAndHeader("file://target/files/ant-path-7/x/y/z", "Hello World 2", Exchange.FILE_NAME, "m.pdf"); @@ -152,7 +145,6 @@ public class AntPathMatcherGenericFileFilterTest extends ContextTestSupport { public void testIncludesAndExcludesAndFilterAndAntFilterNotCaseSensitive() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result8"); mock.expectedBodiesReceivedInAnyOrder("Hello World 3", "Hello World 4"); - mock.setExpectedMessageCount(2); template.sendBodyAndHeader("file://target/files/ant-path-8/x/y/z", "Hello World 1", Exchange.FILE_NAME, "a.txt"); template.sendBodyAndHeader("file://target/files/ant-path-8/x/y/z", "Hello World 2", Exchange.FILE_NAME, "b.txt"); @@ -177,10 +169,6 @@ public class AntPathMatcherGenericFileFilterTest extends ContextTestSupport { from("file://target/files/ant-path-4?recursive=true&antInclude=**/*.txt&antExclude=**/a*&filter=#filter").convertBodyTo(String.class).to("mock:result4"); from("file://target/files/ant-path-8?recursive=true&antInclude=**/*.txt&antExclude=**/a*&filter=#caseInsensitiveFilter").convertBodyTo(String.class).to("mock:result8"); - - - - } }; }