diff --git a/spring-integration-mail/.springBeans b/spring-integration-mail/.springBeans
new file mode 100644
index 0000000000..6f4c287497
--- /dev/null
+++ b/spring-integration-mail/.springBeans
@@ -0,0 +1,13 @@
+
+
+ 1
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-mail/src/main/resources/org/springframework/integration/mail/config/spring-integration-mail-2.0.xsd b/spring-integration-mail/src/main/resources/org/springframework/integration/mail/config/spring-integration-mail-2.0.xsd
index 6d35bc7d6a..6f7629ec20 100644
--- a/spring-integration-mail/src/main/resources/org/springframework/integration/mail/config/spring-integration-mail-2.0.xsd
+++ b/spring-integration-mail/src/main/resources/org/springframework/integration/mail/config/spring-integration-mail-2.0.xsd
@@ -108,6 +108,21 @@
+
+
+
+
+
+
+
+
+ If a (synchronous) downstream exception is thrown and an error-channel is specified,
+ the MessageHandlingException will be sent to this channel. Otherwise, any such exception
+ will simply be logged as a warning by the channel adapter.
+
+
+
diff --git a/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java b/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java
index 6feb01f1f0..2be8e63c20 100644
--- a/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java
+++ b/spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java
@@ -15,8 +15,8 @@
*/
package org.springframework.integration.mail;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -39,7 +39,10 @@ import org.mockito.stubbing.Answer;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.integration.channel.DirectChannel;
+import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.PollableChannel;
+import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.mail.config.ImapIdleChannelAdapterParserTests;
import org.springframework.integration.test.util.TestUtils;
@@ -48,6 +51,7 @@ import com.sun.mail.imap.IMAPFolder;
/**
* @author Oleg Zhurakousky
+ * @author Gary Russell
*
*/
public class ImapMailReceiverTests {
@@ -285,4 +289,59 @@ public class ImapMailReceiverTests {
assertNotNull(componentHistoryRecord);
assertEquals("mail:imap-idle-channel-adapter", componentHistoryRecord.get("type"));
}
+
+ @Test
+ public void testIdleChannelAdapterException() throws Exception{
+ ApplicationContext context =
+ new ClassPathXmlApplicationContext("ImapIdleChannelAdapterParserTests-context.xml", ImapIdleChannelAdapterParserTests.class);
+ ImapIdleChannelAdapter adapter = context.getBean("simpleAdapter", ImapIdleChannelAdapter.class);
+
+ DirectChannel channel = new DirectChannel();
+ channel.subscribe(new AbstractReplyProducingMessageHandler() {
+ protected Object handleRequestMessage(org.springframework.integration.Message> requestMessage) {
+ throw new RuntimeException("Failed");
+ }
+ });
+ adapter.setOutputChannel(channel);
+ QueueChannel errorChannel = new QueueChannel();
+ adapter.setErrorChannel(errorChannel);
+
+ AbstractMailReceiver receiver = new ImapMailReceiver();
+ receiver = spy(receiver);
+ receiver.afterPropertiesSet();
+ DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
+ adapterAccessor.setPropertyValue("mailReceiver", receiver);
+
+ MimeMessage mailMessage = mock(MimeMessage.class);
+ Flags flags = mock(Flags.class);
+ when(mailMessage.getFlags()).thenReturn(flags);
+ final Message[] messages = new Message[]{mailMessage};
+
+ doAnswer(new Answer