diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java index 43e06c6f56..88fc719e46 100755 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.springframework.integration.mail; +import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.Properties; @@ -434,8 +435,11 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl */ private class IntegrationMimeMessage extends MimeMessage { + private final MimeMessage source; + public IntegrationMimeMessage(MimeMessage source) throws MessagingException { super(source); + this.source = source; } @Override @@ -448,5 +452,22 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl } } + @Override + public Date getReceivedDate() throws MessagingException { + /* + * Basic MimeMessage always returns null; delegate to the original. + */ + return this.source.getReceivedDate(); + } + + @Override + public int getLineCount() throws MessagingException { + /* + * Basic MimeMessage always returns '-1'; delegate to the original. + */ + return this.source.getLineCount(); + } + } + } 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 59fe8216c1..08361bbb62 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 @@ -157,7 +157,12 @@ public class ImapMailReceiverTests { adapter.setOutputChannel(channel); adapter.setTaskScheduler(taskScheduler); adapter.start(); - assertNotNull(channel.receive(6000)); + @SuppressWarnings("unchecked") + org.springframework.messaging.Message received = + (org.springframework.messaging.Message) channel.receive(6000); + assertNotNull(received); + assertNotNull(received.getPayload().getReceivedDate()); + assertTrue(received.getPayload().getLineCount() > -1); assertNotNull(channel.receive(6000)); // new message after idle assertNull(channel.receive(10000)); // no new message after second and third idle verify(logger).debug("Canceling IDLE"); @@ -755,9 +760,9 @@ public class ImapMailReceiverTests { @Override public void publishEvent(Object event) { - + } - + }); ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); taskScheduler.initialize();