You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/11/25 14:24:13 UTC
[3/5] camel git commit: Changes to make the file endpoint include &
exclude patterns case insensitive by default
Changes to make the file endpoint include & exclude patterns case insensitive by default
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b27dc454
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b27dc454
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b27dc454
Branch: refs/heads/master
Commit: b27dc454cb73aef9b30311ca1b2bf07661886c5b
Parents: b4d0521
Author: dwarakart <dw...@gmail.com>
Authored: Sun Nov 22 18:40:42 2015 +0000
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Nov 25 14:00:55 2015 +0100
----------------------------------------------------------------------
.../component/file/GenericFileConsumer.java | 22 +------
.../component/file/GenericFileEndpoint.java | 14 -----
...ileConsumerExcludeNameCaseSensitiveTest.java | 58 ------------------
.../file/FileConsumerExcludeNameTest.java | 6 +-
...rIncludeAndExcludeNameCaseSensitiveTest.java | 64 --------------------
.../FileConsumerIncludeAndExcludeNameTest.java | 4 +-
...ileConsumerIncludeNameCaseSensitiveTest.java | 64 --------------------
.../file/FileConsumerIncludeNameTest.java | 4 +-
8 files changed, 10 insertions(+), 226 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b27dc454/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
index 7fc75d4..8d80a12 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
@@ -597,34 +597,18 @@ public abstract class GenericFileConsumer<T> extends ScheduledBatchPollingConsum
return true;
}
- // Check for case sensitive flag
- boolean caseSensitive = true;
- if (ObjectHelper.isNotEmpty(endpoint.getCaseSensitive())) {
- caseSensitive = endpoint.getCaseSensitive();
- }
-
if (ObjectHelper.isNotEmpty(endpoint.getExclude())) {
- String excludePattern = endpoint.getExclude();
- if (caseSensitive == false ) {
- if (name.toUpperCase().matches(excludePattern.toUpperCase())) {
- return false;
- }
- } else if (name.matches(excludePattern)) {
+ if (name.toUpperCase().matches(endpoint.getExclude().toUpperCase())) {
return false;
}
}
if (ObjectHelper.isNotEmpty(endpoint.getInclude())) {
- String includePattern = endpoint.getInclude();
- if (caseSensitive == false) {
- if (!name.toUpperCase().matches(includePattern.toUpperCase())) {
- return false;
- }
- } else if (!name.matches(includePattern)) {
+ if (!name.toUpperCase().matches(endpoint.getInclude().toUpperCase())) {
return false;
}
}
-
+//Msno
// use file expression for a simple dynamic file filter
if (endpoint.getFileName() != null) {
fileExpressionResult = evaluateFileExpression();
http://git-wip-us.apache.org/repos/asf/camel/blob/b27dc454/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 7183847..c81e2d3 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
@@ -129,8 +129,6 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple
protected String include;
@UriParam(label = "consumer,filter")
protected String exclude;
- @UriParam(label = "consumer,filter", defaultValue = "true")
- protected Boolean caseSensitive;
@UriParam(label = "consumer,filter")
protected Expression move;
@UriParam(label = "consumer")
@@ -443,18 +441,6 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple
this.exclude = exclude;
}
- public Boolean getCaseSensitive() {
- return caseSensitive;
- }
-
- /**
- * Is used to determine if the include & exclude patterns are case sensitive or not
- * @param caseSensitive
- */
- public void setCaseSensitive(Boolean caseSensitive) {
- this.caseSensitive = caseSensitive;
- }
-
public String getAntInclude() {
return antInclude;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/b27dc454/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameCaseSensitiveTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameCaseSensitiveTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameCaseSensitiveTest.java
deleted file mode 100644
index bb243ff..0000000
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameCaseSensitiveTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.file;
-
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-
-/**
- * Unit test that file consumer will exclude pre and postfixes
- */
-public class FileConsumerExcludeNameCaseSensitiveTest extends ContextTestSupport {
-
- public void testExludePreAndPostfixes() throws Exception {
- deleteDirectory("target/exclude");
- prepareFiles();
-
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedBodiesReceived("Reports", "Reports", "Reports3");
- mock.expectedMessageCount(3);
- mock.assertIsSatisfied();
- }
-
- private void prepareFiles() throws Exception {
- String url = "file://target/exclude";
- template.sendBodyAndHeader(url, "Hello World", Exchange.FILE_NAME, "hello.xml");
- template.sendBodyAndHeader(url, "Reports", Exchange.FILE_NAME, "report1.txt");
- template.sendBodyAndHeader(url, "Bye World", Exchange.FILE_NAME, "secret.txt");
- template.sendBodyAndHeader(url, "Reports", Exchange.FILE_NAME, "report2.txt");
- template.sendBodyAndHeader(url, "Reports3", Exchange.FILE_NAME, "Report3.txt");
- template.sendBodyAndHeader(url, "Secret2", Exchange.FILE_NAME, "Secret2.txt");
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from("file://target/exclude/?exclude=^secret.*|.*xml$&caseSensitive=false")
- .convertBodyTo(String.class).to("mock:result");
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/b27dc454/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameTest.java
index cda3e5a..fd8d7cc 100644
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameTest.java
@@ -31,8 +31,8 @@ public class FileConsumerExcludeNameTest extends ContextTestSupport {
prepareFiles();
MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedBodiesReceived("Reports", "Reports", "Reports3", "Secret2");
- mock.expectedMessageCount(4);
+ mock.expectedBodiesReceived("Reports", "Reports", "Reports3");
+ mock.expectedMessageCount(3);
mock.assertIsSatisfied();
}
@@ -49,7 +49,7 @@ public class FileConsumerExcludeNameTest extends ContextTestSupport {
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
- from("file://target/exclude/?exclude=^secret.*|.*xml$&caseSensitive=true")
+ from("file://target/exclude/?exclude=^secret.*|.*xml$")
.convertBodyTo(String.class).to("mock:result");
}
};
http://git-wip-us.apache.org/repos/asf/camel/blob/b27dc454/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameCaseSensitiveTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameCaseSensitiveTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameCaseSensitiveTest.java
deleted file mode 100644
index f4593ec..0000000
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameCaseSensitiveTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.file;
-
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-
-/**
- * Unit test that file consumer will include/exclude pre and postfixes
- */
-public class FileConsumerIncludeAndExcludeNameCaseSensitiveTest extends ContextTestSupport {
-
- @Override
- protected void setUp() throws Exception {
- deleteDirectory("target/includeexclude");
- super.setUp();
- }
-
- public void testIncludePreAndPostfixes() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedBodiesReceivedInAnyOrder("Report 2", "Report 3", "Report 4");
- mock.expectedMessageCount(3);
-
- sendFiles();
-
- mock.assertIsSatisfied();
- }
-
- private void sendFiles() throws Exception {
- String url = "file://target/includeexclude";
- template.sendBodyAndHeader(url, "Hello World", Exchange.FILE_NAME, "hello.txt");
- template.sendBodyAndHeader(url, "Report 1", Exchange.FILE_NAME, "report1.xml");
- template.sendBodyAndHeader(url, "Report 2", Exchange.FILE_NAME, "report2.txt");
- template.sendBodyAndHeader(url, "Report 3", Exchange.FILE_NAME, "report3.txt");
- template.sendBodyAndHeader(url, "Report 4", Exchange.FILE_NAME, "Report4.txt");
- template.sendBodyAndHeader(url, "Secret", Exchange.FILE_NAME, "Secret.txt");
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from("file://target/includeexclude/?include=report.*txt&exclude=hello.*&caseSensitive=false")
- .convertBodyTo(String.class).to("mock:result");
- }
- };
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/b27dc454/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameTest.java
index 5ee697b..b9ad5a2 100644
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameTest.java
@@ -34,8 +34,8 @@ public class FileConsumerIncludeAndExcludeNameTest extends ContextTestSupport {
public void testIncludePreAndPostfixes() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(2);
- mock.expectedBodiesReceivedInAnyOrder("Report 2", "Report 3");
+ mock.expectedBodiesReceivedInAnyOrder("Report 2", "Report 3", "Report 4");
+ mock.expectedMessageCount(3);
sendFiles();
http://git-wip-us.apache.org/repos/asf/camel/blob/b27dc454/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameCaseSensitiveTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameCaseSensitiveTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameCaseSensitiveTest.java
deleted file mode 100644
index a6b54a1..0000000
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameCaseSensitiveTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.file;
-
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-
-/**
- * Unit test that file consumer will include pre and postfixes
- */
-public class FileConsumerIncludeNameCaseSensitiveTest extends ContextTestSupport {
-
- @Override
- protected void setUp() throws Exception {
- deleteDirectory("target/include");
- super.setUp();
- }
-
- public void testIncludePreAndPostfixes() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedBodiesReceived("Reports", "Reports", "Reports3");
- mock.expectedMessageCount(3);
-
- sendFiles();
-
- mock.assertIsSatisfied();
- }
-
- private void sendFiles() throws Exception {
- String url = "file://target/include";
- template.sendBodyAndHeader(url, "Hello World", Exchange.FILE_NAME, "hello.xml");
- template.sendBodyAndHeader(url, "Reports", Exchange.FILE_NAME, "report1.txt");
- template.sendBodyAndHeader(url, "Bye World", Exchange.FILE_NAME, "secret.txt");
- template.sendBodyAndHeader(url, "Reports", Exchange.FILE_NAME, "report2.txt");
- template.sendBodyAndHeader(url, "Reports3", Exchange.FILE_NAME, "Report3.txt");
- template.sendBodyAndHeader(url, "Secret2", Exchange.FILE_NAME, "Secret2.txt");
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from("file://target/include/?include=^report.*txt$&caseSensitive=false")
- .convertBodyTo(String.class).to("mock:result");
- }
- };
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/b27dc454/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameTest.java
index 50820f3..902622d 100644
--- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameTest.java
@@ -34,8 +34,8 @@ public class FileConsumerIncludeNameTest extends ContextTestSupport {
public void testIncludePreAndPostfixes() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedBodiesReceived("Reports", "Reports");
- mock.expectedMessageCount(2);
+ mock.expectedBodiesReceived("Reports", "Reports", "Reports3");
+ mock.expectedMessageCount(3);
sendFiles();