FileSource now uses a Resource, which must point to a directory. 

For namespace support, in order to simplify configuration, if the value provided in the 'directory' attribute of <file-source/> not a URL nor a 'classpath:' value, the parser will force the 'file:' prefix by default.
This commit is contained in:
Marius Bogoevici
2008-06-09 03:32:15 +00:00
parent 7bb68b4033
commit 21b0ac9264
5 changed files with 69 additions and 16 deletions

View File

@@ -16,17 +16,18 @@
package org.springframework.integration.adapter.file.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -135,4 +136,14 @@ public class FileSourceParserTests {
}
}
@Test
public void testFileSourceWithFileAndNotDirectory() {
try {
new ClassPathXmlApplicationContext("fileSourceWithFileDirectory.xml", this.getClass());
fail();
} catch (BeanCreationException ex) {
assertTrue(ex.getCause().getCause().getMessage().indexOf("is not a directory") > 0);
}
}
}

View File

@@ -30,6 +30,4 @@
<bean id="customFilenameFilter" class="org.springframework.integration.adapter.file.config.CustomFilenameFilter"/>
<context:property-placeholder/>
</beans>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:si="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
<si:file-source id="fileSourceDefault" directory="fileSourceWithFileDirectory.xml"/>
</beans>