Permalink
Browse files

Merge pull request #399 from garyrussell/INT-2493

* INT-2493:
  INT-2493 Add Edit For Filter on Get
  • Loading branch information...
2 parents 6dca78a + b317ece commit 0b015830d3464c33e9b0ab3d3ae306c50defcbc5 Oleg Zhurakousky committed Apr 9, 2012
@@ -162,9 +162,9 @@ protected void onInit() {
"command must be one of "
+ StringUtils
.collectionToCommaDelimitedString(this.supportedCommands));
- // NOTE: Filter also not used on GET, need to correct in 2.2.
- if (COMMAND_RM.equals(this.command) || COMMAND_MGET.equals(this.command)) {
- Assert.isNull(this.filter, "Filters are not supported with the rm and mget commands");
+ if (COMMAND_RM.equals(this.command) || COMMAND_MGET.equals(this.command) ||
+ COMMAND_GET.equals(this.command)) {
+ Assert.isNull(this.filter, "Filters are not supported with the rm, get, and mget commands");
}
if (COMMAND_GET.equals(this.command)
|| COMMAND_MGET.equals(this.command)) {
@@ -18,6 +18,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -37,6 +38,7 @@
import org.springframework.integration.MessagingException;
import org.springframework.integration.file.FileHeaders;
import org.springframework.integration.file.filters.AbstractSimplePatternFileListFilter;
+import org.springframework.integration.file.filters.FileListFilter;
import org.springframework.integration.file.remote.AbstractFileInfo;
import org.springframework.integration.file.remote.session.Session;
import org.springframework.integration.file.remote.session.SessionFactory;
@@ -63,6 +65,51 @@ public void testBad() throws Exception {
}
@Test
+ public void testBadFilterGet() throws Exception {
+ SessionFactory sessionFactory = mock(SessionFactory.class);
+ TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
+ (sessionFactory, "get", "payload");
+ gw.setFilter(new TestPatternFilter(""));
+ try {
+ gw.onInit();
+ fail("Exception expected");
+ }
+ catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().startsWith("Filters are not supported"));
+ }
+ }
+
+ @Test
+ public void testBadFilterMGet() throws Exception {
+ SessionFactory sessionFactory = mock(SessionFactory.class);
+ TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
+ (sessionFactory, "mget", "payload");
+ gw.setFilter(new TestPatternFilter(""));
+ try {
+ gw.onInit();
+ fail("Exception expected");
+ }
+ catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().startsWith("Filters are not supported"));
+ }
+ }
+
+ @Test
+ public void testBadFilterRm() throws Exception {
+ SessionFactory sessionFactory = mock(SessionFactory.class);
+ TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
+ (sessionFactory, "rm", "payload");
+ gw.setFilter(new TestPatternFilter(""));
+ try {
+ gw.onInit();
+ fail("Exception expected");
+ }
+ catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().startsWith("Filters are not supported"));
+ }
+ }
+
+ @Test
public void testLs() throws Exception {
SessionFactory sessionFactory = mock(SessionFactory.class);
Session session = mock(Session.class);

0 comments on commit 0b01583

Please sign in to comment.