Author: davsclaus
Date: Thu Aug 19 11:02:56 2010
New Revision: 987124
URL: http://svn.apache.org/viewvc?rev=987124&view=rev
Log:
CAMEL-3063: File consumer accept current dir as starting directory. Thanks to
Daniel Bevenius for the patch.
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCurrentDirTest.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java?rev=987124&r1=987123&r2=987124&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
Thu Aug 19 11:02:56 2010
@@ -52,12 +52,13 @@ public class FileEndpoint extends Generi
ObjectHelper.notNull(file, "file");
// we assume its a file if the name has a dot in it (eg foo.txt)
- if (file.getName().contains(".")) {
+ boolean isDirectory = file.isDirectory();
+ if (!isDirectory && file.getName().contains(".")) {
throw new IllegalArgumentException("Only directory is supported.
Endpoint must be configured with a valid starting directory: " + file);
}
// auto create starting directory if needed
- if (!file.exists() && !file.isDirectory()) {
+ if (!file.exists() && !isDirectory) {
if (isAutoCreate()) {
if (log.isDebugEnabled()) {
log.debug("Creating non existing starting directory: " +
file);
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCurrentDirTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCurrentDirTest.java?rev=987124&view=auto
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCurrentDirTest.java
(added)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCurrentDirTest.java
Thu Aug 19 11:02:56 2010
@@ -0,0 +1,41 @@
+/**
+ * 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.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class FileConsumerCurrentDirTest extends ContextTestSupport {
+
+ public void testCurrentDir() throws Exception {
+ // just see if the route can be started and poll in files
+ Thread.sleep(1000);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("file:.?noop=true").to("mock:result");
+ }
+ };
+ }
+}