INT-356: Changed namespace parsing to resolve incompatible MessageCreator problem. type attribute on ftpsource no longer supported.
This commit is contained in:
@@ -51,7 +51,7 @@ public class FileSourceParserTests {
|
||||
FileSource fileSource = (FileSource) context.getBean("fileSourceDefault");
|
||||
DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(fileSource);
|
||||
File directory = (File) sourceAccessor.getPropertyValue("directory");
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
assertEquals(System.getProperty("java.io.tmpdir"), directory.getAbsolutePath());
|
||||
assertTrue(messageCreator instanceof FileMessageCreator);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class FileSourceParserTests {
|
||||
FileSource fileSource = (FileSource) context.getBean("fileSourceText");
|
||||
DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(fileSource);
|
||||
File directory = (File) sourceAccessor.getPropertyValue("directory");
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
assertEquals(System.getProperty("java.io.tmpdir"), directory.getAbsolutePath());
|
||||
assertTrue(messageCreator instanceof TextFileMessageCreator);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class FileSourceParserTests {
|
||||
FileSource fileSource = (FileSource) context.getBean("fileSourceBinary");
|
||||
DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(fileSource);
|
||||
File directory = (File) sourceAccessor.getPropertyValue("directory");
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
assertEquals(System.getProperty("java.io.tmpdir"), directory.getAbsolutePath());
|
||||
assertTrue(messageCreator instanceof ByteArrayFileMessageCreator);
|
||||
}
|
||||
@@ -84,28 +84,29 @@ public class FileSourceParserTests {
|
||||
FileSource fileSource = (FileSource) context.getBean("fileSourceFile");
|
||||
DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(fileSource);
|
||||
File directory = (File) sourceAccessor.getPropertyValue("directory");
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
assertEquals(System.getProperty("java.io.tmpdir"), directory.getAbsolutePath());
|
||||
assertTrue(messageCreator instanceof FileMessageCreator);
|
||||
}
|
||||
|
||||
@Test(expected=ConfigurationException.class)
|
||||
public void testInvalidFileSource() throws Throwable {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext("invalidFileSourceTests.xml", this.getClass());
|
||||
fail();
|
||||
} catch (BeanDefinitionStoreException e) {
|
||||
throw e.getCause();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileSourceWithCustomMessageCreator() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("fileSourceParserTests.xml", this.getClass());
|
||||
FileSource fileSource = (FileSource) context.getBean("fileSourceWithCustomMessageCreator");
|
||||
DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(fileSource);
|
||||
File directory = (File) sourceAccessor.getPropertyValue("directory");
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
assertEquals(System.getProperty("java.io.tmpdir"), directory.getAbsolutePath());
|
||||
assertTrue(messageCreator instanceof CustomMessageCreator);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileSourceWithTypeAndCustomMessageCreator() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("fileSourceParserTests.xml", this.getClass());
|
||||
FileSource fileSource = (FileSource) context.getBean("fileSourceTypeAndCustom");
|
||||
DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(fileSource);
|
||||
File directory = (File) sourceAccessor.getPropertyValue("directory");
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
assertEquals(System.getProperty("java.io.tmpdir"), directory.getAbsolutePath());
|
||||
assertTrue(messageCreator instanceof CustomMessageCreator);
|
||||
}
|
||||
@@ -138,12 +139,13 @@ public class FileSourceParserTests {
|
||||
assertTrue(filter.accept(null, "foo.txt"));
|
||||
}
|
||||
|
||||
@Test(expected=ConfigurationException.class)
|
||||
@Test(expected = ConfigurationException.class)
|
||||
public void testFileSourceWithFileFilterAndFilenameFilterNotAllowed() throws Throwable {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext("fileSourceWithTooManyFilters.xml", this.getClass());
|
||||
fail();
|
||||
} catch (BeanDefinitionStoreException e) {
|
||||
}
|
||||
catch (BeanDefinitionStoreException e) {
|
||||
throw e.getCause();
|
||||
}
|
||||
}
|
||||
@@ -152,8 +154,9 @@ public class FileSourceParserTests {
|
||||
public void testFileSourceWithFileAndNotDirectory() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext("fileSourceWithFileDirectory.xml", this.getClass());
|
||||
fail();
|
||||
} catch (BeanCreationException ex) {
|
||||
fail();
|
||||
}
|
||||
catch (BeanCreationException ex) {
|
||||
assertTrue(ex.getCause().getCause().getMessage().indexOf("is not a directory") > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
<si:file-source id="fileSourceWithCustomFilenameFilter" filename-filter="customFilenameFilter" directory="${java.io.tmpdir}"/>
|
||||
|
||||
<si:file-source id="fileSourceWithRegexFilter" filename-pattern="fo+\.[tx]{3}" directory="${java.io.tmpdir}"/>
|
||||
|
||||
<si:file-source id="fileSourceTypeAndCustom" type="text" message-creator="customMessageCreator" directory="${java.io.tmpdir}"/>
|
||||
|
||||
<bean id="customMessageCreator" class="org.springframework.integration.adapter.file.config.CustomMessageCreator"/>
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<?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="fileSourceCustom" type="text"
|
||||
message-creator="customMessageCreator" directory="${java.io.tmpdir}"/>
|
||||
|
||||
<bean id="customMessageCreator"
|
||||
class="org.springframework.integration.adapter.file.config.CustomMessageCreator"/>
|
||||
|
||||
<context:property-placeholder/>
|
||||
|
||||
</beans>
|
||||
@@ -234,7 +234,7 @@ public class FtpSourceTests {
|
||||
recorded.await();
|
||||
recievedFiles = ftpSource.receive();
|
||||
receivesDone.countDown();
|
||||
//make sure onSend happens after all receives
|
||||
// make sure onSend happens after all receives
|
||||
receivesDone.await();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
@@ -245,7 +245,12 @@ public class FtpSourceTests {
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
receivesDone.await();
|
||||
try {
|
||||
receivesDone.await();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
verify(globalMocks);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import static org.junit.Assert.fail;
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -34,6 +33,7 @@ import org.springframework.integration.adapter.file.FileMessageCreator;
|
||||
import org.springframework.integration.adapter.file.TextFileMessageCreator;
|
||||
import org.springframework.integration.adapter.file.config.CustomMessageCreator;
|
||||
import org.springframework.integration.adapter.ftp.FtpSource;
|
||||
import org.springframework.integration.message.DefaultMessageCreator;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -55,63 +55,7 @@ public class FtpSourceParserTests {
|
||||
assertEquals("testUser", accessor.getPropertyValue("username"));
|
||||
assertEquals("testPassword", accessor.getPropertyValue("password"));
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
assertTrue(messageCreator instanceof FileMessageCreator);
|
||||
DirectFieldAccessor messageCreatorAccessor = new DirectFieldAccessor(messageCreator);
|
||||
assertEquals(messageCreatorAccessor.getPropertyValue("deleteFileAfterCreation"), false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFtpSourceTextType() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("ftpSourceParserTests.xml", this.getClass());
|
||||
FtpSource ftpSource = (FtpSource) context.getBean("ftpSourceText");
|
||||
DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(ftpSource);
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(sourceAccessor.getPropertyValue("clientPool"));
|
||||
assertEquals("testHost", accessor.getPropertyValue("host"));
|
||||
assertEquals(2121, accessor.getPropertyValue("port"));
|
||||
assertEquals(new File("/local"), sourceAccessor.getPropertyValue("localWorkingDirectory"));
|
||||
assertEquals("/remote", accessor.getPropertyValue("remoteWorkingDirectory"));
|
||||
assertEquals("testUser", accessor.getPropertyValue("username"));
|
||||
assertEquals("testPassword", accessor.getPropertyValue("password"));
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
assertTrue(messageCreator instanceof TextFileMessageCreator);
|
||||
DirectFieldAccessor messageCreatorAccessor = new DirectFieldAccessor(messageCreator);
|
||||
assertEquals(messageCreatorAccessor.getPropertyValue("deleteFileAfterCreation"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFtpSourceBinaryType() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("ftpSourceParserTests.xml", this.getClass());
|
||||
FtpSource ftpSource = (FtpSource) context.getBean("ftpSourceBinary");
|
||||
DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(ftpSource);
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(sourceAccessor.getPropertyValue("clientPool"));
|
||||
assertEquals("testHost", accessor.getPropertyValue("host"));
|
||||
assertEquals(2121, accessor.getPropertyValue("port"));
|
||||
assertEquals(new File("/local"), sourceAccessor.getPropertyValue("localWorkingDirectory"));
|
||||
assertEquals("/remote", accessor.getPropertyValue("remoteWorkingDirectory"));
|
||||
assertEquals("testUser", accessor.getPropertyValue("username"));
|
||||
assertEquals("testPassword", accessor.getPropertyValue("password"));
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
assertTrue(messageCreator instanceof ByteArrayFileMessageCreator);
|
||||
DirectFieldAccessor messageCreatorAccessor = new DirectFieldAccessor(messageCreator);
|
||||
assertEquals(messageCreatorAccessor.getPropertyValue("deleteFileAfterCreation"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFtpSourceFileType() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("ftpSourceParserTests.xml", this.getClass());
|
||||
FtpSource ftpSource = (FtpSource) context.getBean("ftpSourceFile");
|
||||
DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(ftpSource);
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(sourceAccessor.getPropertyValue("clientPool"));
|
||||
assertEquals("testHost", accessor.getPropertyValue("host"));
|
||||
assertEquals(2121, accessor.getPropertyValue("port"));
|
||||
assertEquals(new File("/local"), sourceAccessor.getPropertyValue("localWorkingDirectory"));
|
||||
assertEquals("/remote", accessor.getPropertyValue("remoteWorkingDirectory"));
|
||||
assertEquals("testUser", accessor.getPropertyValue("username"));
|
||||
assertEquals("testPassword", accessor.getPropertyValue("password"));
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
assertTrue(messageCreator instanceof FileMessageCreator);
|
||||
DirectFieldAccessor messageCreatorAccessor = new DirectFieldAccessor(messageCreator);
|
||||
assertEquals(messageCreatorAccessor.getPropertyValue("deleteFileAfterCreation"), false);
|
||||
assertTrue(messageCreator instanceof DefaultMessageCreator);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,19 +72,6 @@ public class FtpSourceParserTests {
|
||||
assertEquals("testPassword", accessor.getPropertyValue("password"));
|
||||
Object messageCreator = sourceAccessor.getPropertyValue("messageCreator");
|
||||
assertTrue(messageCreator instanceof CustomMessageCreator);
|
||||
// not testing for deleteFileAfterCreation - this is completely left up
|
||||
// to the implementation
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidFtpSource() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext("invalidFtpSourceTests.xml", this.getClass());
|
||||
fail();
|
||||
}
|
||||
catch (BeanDefinitionStoreException e) {
|
||||
assertTrue(e.getCause() instanceof ConfigurationException);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
remote-working-directory="/remote"
|
||||
username="testUser"
|
||||
password="testPassword"
|
||||
type="text"/>
|
||||
/>
|
||||
|
||||
<si:ftp-source id="ftpSourceBinary"
|
||||
host="testHost"
|
||||
@@ -31,7 +31,7 @@
|
||||
remote-working-directory="/remote"
|
||||
username="testUser"
|
||||
password="testPassword"
|
||||
type="binary"/>
|
||||
/>
|
||||
|
||||
<si:ftp-source id="ftpSourceFile"
|
||||
host="testHost"
|
||||
@@ -40,7 +40,7 @@
|
||||
remote-working-directory="/remote"
|
||||
username="testUser"
|
||||
password="testPassword"
|
||||
type="file"/>
|
||||
/>
|
||||
|
||||
<si:ftp-source id="ftpSourceCustom"
|
||||
host="testHost"
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?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:ftp-source id="ftpSourceCustom"
|
||||
host="testHost"
|
||||
port="2121"
|
||||
local-working-directory="/local"
|
||||
remote-working-directory="/remote"
|
||||
username="testUser"
|
||||
password="testPassword"
|
||||
message-creator="customMessageCreator"
|
||||
type="text"/>
|
||||
|
||||
<bean id="customMessageCreator"
|
||||
class="org.springframework.integration.adapter.file.config.CustomMessageCreator"/>
|
||||
|
||||
<context:property-placeholder/>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user