diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/AbstractInboundRemoteFileSystemSynchronizingMessageSource.java b/spring-integration-file/src/main/java/org/springframework/integration/file/AbstractInboundRemoteFileSystemSynchronizingMessageSource.java
index e3e9af69c9..0c908a29dc 100644
--- a/spring-integration-file/src/main/java/org/springframework/integration/file/AbstractInboundRemoteFileSystemSynchronizingMessageSource.java
+++ b/spring-integration-file/src/main/java/org/springframework/integration/file/AbstractInboundRemoteFileSystemSynchronizingMessageSource.java
@@ -9,6 +9,7 @@ import org.springframework.integration.endpoint.MessageProducerSupport;
import org.springframework.integration.file.entries.*;
import java.io.File;
+import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.regex.Pattern;
@@ -92,10 +93,14 @@ public abstract class AbstractInboundRemoteFileSystemSynchronizingMessageSource<
this.synchronizer.setFilter(this.remotePredicate);
}
- if (this.autoCreateDirectories) {
- if ((this.localDirectory != null) && !this.localDirectory.exists() && this.localDirectory.getFile().mkdirs())
- logger.debug("the localDirectory " + this.localDirectory + " doesn't exist");
- }
+ if (this.localDirectory != null && !this.localDirectory.exists()){
+ if (this.autoCreateDirectories){
+ logger.debug("The '" + localDirectory + "' directory doesn't exist. Creating " + this.localDirectory);
+ this.localDirectory.getFile().mkdirs();
+ } else {
+ throw new FileNotFoundException(localDirectory.getFilename());
+ }
+ }
/**
* Handles making sure the remote files get here in one piece
@@ -118,7 +123,7 @@ public abstract class AbstractInboundRemoteFileSystemSynchronizingMessageSource<
if (e instanceof RuntimeException){
throw (RuntimeException)e;
} else {
- throw new MessagingException("Failure during initialization of " + this.getComponentName(), e);
+ throw new MessagingException("Failure during initialization of MessageSource for: " + this.getComponentType(), e);
}
}
diff --git a/spring-integration-sftp/.project b/spring-integration-sftp/.project
index e92ee4a1ac..baeb3bf435 100644
--- a/spring-integration-sftp/.project
+++ b/spring-integration-sftp/.project
@@ -15,8 +15,14 @@
+
+ org.springframework.ide.eclipse.core.springbuilder
+
+
+
+ org.springframework.ide.eclipse.core.springnature
org.maven.ide.eclipse.maven2Nature
org.eclipse.jdt.core.javanature
diff --git a/spring-integration-sftp/pom.xml b/spring-integration-sftp/pom.xml
index e51907f177..6c3c6a6df3 100644
--- a/spring-integration-sftp/pom.xml
+++ b/spring-integration-sftp/pom.xml
@@ -85,5 +85,9 @@
commons-io
1.4
+
+ org.mockito
+ mockito-all
+
diff --git a/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-2.0.xsd b/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-2.0.xsd
index 9a6ca08ef9..2fc8aa5baa 100644
--- a/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-2.0.xsd
+++ b/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-2.0.xsd
@@ -97,7 +97,7 @@
-
+
diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/SftpParserTests-inbound-all-fail.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/SftpParserTests-inbound-all-fail.xml
new file mode 100644
index 0000000000..1c1d0a9c22
--- /dev/null
+++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/SftpParserTests-inbound-all-fail.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/SftpParserTests-inbound-all.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/SftpParserTests-inbound-all.xml
new file mode 100644
index 0000000000..5bf980fd50
--- /dev/null
+++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/SftpParserTests-inbound-all.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/SftpParserTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/SftpParserTests.java
new file mode 100644
index 0000000000..832ba8e4ed
--- /dev/null
+++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/SftpParserTests.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2002-2010 the original author or authors.
+ *
+ * Licensed 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.springframework.integration.sftp;
+
+import static junit.framework.Assert.assertTrue;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.beans.factory.BeanCreationException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @author Oleg Zhurakousky
+ *
+ */
+public class SftpParserTests {
+
+ @Before
+ public void prepare(){
+ new File("target/foo").delete();
+ }
+
+ @Test
+ public void testLocalFilesAutoCreationTrue() throws Exception{
+ assertTrue(!new File("target/foo").exists());
+ new ClassPathXmlApplicationContext("SftpParserTests-inbound-all.xml", this.getClass());
+ assertTrue(new File("target/foo").exists());
+ assertTrue(!new File("target/bar").exists());
+ }
+ @Test(expected=BeanCreationException.class)
+ public void testLocalFilesAutoCreationFalse() throws Exception{
+ assertTrue(!new File("target/bar").exists());
+ new ClassPathXmlApplicationContext("SftpParserTests-inbound-all-fail.xml", this.getClass());
+ }
+ @Test
+ public void testLocalFilesAreFound() throws Exception{
+ assertTrue(new File("target").exists());
+ new ClassPathXmlApplicationContext("SftpParserTests-inbound-all.xml", this.getClass());
+ assertTrue(new File("target").exists());
+ }
+
+ @After
+ public void cleanUp() throws Exception{
+ new File("target/foo").delete();
+ }
+}