Skip to content

Commit

Permalink
Merge pull request spring-projects#399 from garyrussell/INT-2493
Browse files Browse the repository at this point in the history
* INT-2493:
  INT-2493 Add Edit For Filter on Get
  • Loading branch information
olegz committed Apr 9, 2012
2 parents 6dca78a + b317ece commit 0b01583
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -62,6 +64,51 @@ public void testBad() throws Exception {
gw.afterPropertiesSet();
}

@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);
Expand Down

0 comments on commit 0b01583

Please sign in to comment.