Author: davsclaus
Date: Mon Dec 1 23:39:51 2008
New Revision: 722394
URL: http://svn.apache.org/viewvc?rev=722394&view=rev
Log:
CAMEL-1099, CAMEL-1135: Fixed bug in file consumer not testing folders. Fixed
failed test in camel-spring.
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
activemq/camel/trunk/components/camel-spring/pom.xml
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/test/TestEndpointTest.java
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/test/TestEndpointTest-context.xml
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java?rev=722394&r1=722393&r2=722394&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
Mon Dec 1 23:39:51 2008
@@ -100,14 +100,15 @@
if (!fileOrDirectory.isDirectory()) {
addFile(fileOrDirectory, fileList);
- } else if (processDir) {
+ // must test matching for directories as well as we want to skip
directories starting with a dot etc.
+ } else if (processDir && matchFile(fileOrDirectory)) {
// directory that can be recursive
if (LOG.isTraceEnabled()) {
LOG.trace("Polling directory " + fileOrDirectory);
}
File[] files = fileOrDirectory.listFiles();
for (File file : files) {
- // recursive add the files
+ // recursive scan and add the files
scanFilesToPoll(file, isRecursive(), fileList);
}
} else {
@@ -218,7 +219,8 @@
File file, boolean failureHandled) {
try {
if (LOG.isDebugEnabled()) {
- LOG.debug("Committing file strategy: " + processStrategy + "
for file: " + file + (failureHandled ? " that was handled by the failure
processor." : ""));
+ LOG.debug("Committing file strategy: " + processStrategy + "
for file: "
+ + file + (failureHandled ? " that was handled by the
failure processor." : ""));
}
processStrategy.commit(endpoint, exchange, file);
} catch (Exception e) {
@@ -247,22 +249,26 @@
* @return true to include the file, false to skip it
*/
protected boolean validateFile(File file) {
- if (endpoint.isIdempotent() &&
!endpoint.getIdempotentRepository().add(file.getName())) {
+ if (!matchFile(file)) {
+ return false;
+ } else if (endpoint.isIdempotent() &&
!endpoint.getIdempotentRepository().add(file.getName())) {
// skip as we have already processed it
return false;
}
- return matchFile(file);
+ // file matched
+ return true;
}
/**
* Strategy to perform file matching based on endpoint configuration.
* <p/>
- * Will always return false for certain files:
+ * Will always return <tt>false</tt> for certain files/folders:
* <ul>
* <li>Starting with a dot</li>
* <li>lock files</li>
* </ul>
+ * And then <tt>true</tt> for directories.
*
* @param file the file
* @return true if the file is matche, false if not
Modified: activemq/camel/trunk/components/camel-spring/pom.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/pom.xml?rev=722394&r1=722393&r2=722394&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/pom.xml (original)
+++ activemq/camel/trunk/components/camel-spring/pom.xml Mon Dec 1 23:39:51
2008
@@ -172,7 +172,6 @@
<excludes>
<!-- TODO FIXME ASAP -->
<exclude>**/XXXTest.*</exclude>
- <exclude>**/TestEndpointTest.*</exclude>
</excludes>
</configuration>
</plugin>
Modified:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/test/TestEndpointTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/test/TestEndpointTest.java?rev=722394&r1=722393&r2=722394&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/test/TestEndpointTest.java
(original)
+++
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/test/TestEndpointTest.java
Mon Dec 1 23:39:51 2008
@@ -39,7 +39,7 @@
@Autowired
protected CamelContext camelContext;
- @EndpointInject(uri =
"test:file://src/test/data?noop=true&idempotent=true&consumer.recursive=true&consumer.delay=2000")
+ @EndpointInject(uri =
"test:file://src/test/data?noop=true&idempotent=true&consumer.recursive=true&consumer.initialDelay=2000")
protected TestEndpoint endpoint;
public void testMocksAreValid() throws Exception {
Modified:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/test/TestEndpointTest-context.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/test/TestEndpointTest-context.xml?rev=722394&r1=722393&r2=722394&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/test/TestEndpointTest-context.xml
(original)
+++
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/test/TestEndpointTest-context.xml
Mon Dec 1 23:39:51 2008
@@ -25,8 +25,8 @@
<!-- START SNIPPET: example -->
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
- <from
uri="file://src/test/data?noop=true&idempotent=true&consumer.recursive=true&consumer.delay=2000"/>
- <to
uri="test:file://src/test/data?noop=true&idempotent=true&consumer.recursive=true&consumer.delay=2000"/>
+ <from
uri="file://src/test/data?noop=true&idempotent=true&consumer.recursive=true&consumer.initialDelay=2000"/>
+ <to
uri="test:file://src/test/data?noop=true&idempotent=true&consumer.recursive=true&consumer.initialDelay=2000"/>
</route>
</camelContext>
<!-- END SNIPPET: example -->