INT-1475, addressed the issue. Made 'should-delete-messages' required by the schema and added tests to validate it. Added more tests for Pop3MailReceiever. Modified documentation to explain the change and reasoning behind the change

This commit is contained in:
Oleg Zhurakousky
2010-09-23 20:43:44 -04:00
parent c521fc9531
commit 76fc874be4
7 changed files with 106 additions and 26 deletions

View File

@@ -15,18 +15,12 @@
*/
package org.springframework.integration.mail;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Properties;
import javax.mail.Flags;
import javax.mail.Flags.Flag;
import javax.mail.Folder;
import javax.mail.Message;
@@ -34,18 +28,9 @@ import javax.mail.internet.MimeMessage;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
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.core.PollableChannel;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.mail.config.ImapIdleChannelAdapterParserTests;
import org.springframework.integration.test.util.TestUtils;
import com.sun.mail.imap.IMAPFolder;
/**
* @author Oleg Zhurakousky
@@ -124,8 +109,8 @@ public class Pop3MailReceiverTests {
verify(msg1, times(0)).setFlag(Flag.DELETED, true);
verify(msg2, times(0)).setFlag(Flag.DELETED, true);
}
@Test @Ignore
public void receieveAndDontSetDeleteFlagWithUrl() throws Exception{
@Test
public void receieveAndDontSetDeleteWithUrl() throws Exception{
AbstractMailReceiver receiver = new Pop3MailReceiver("pop3://some.host");
receiver = spy(receiver);
receiver.afterPropertiesSet();
@@ -160,7 +145,7 @@ public class Pop3MailReceiverTests {
verify(msg2, times(0)).setFlag(Flag.DELETED, true);
}
@Test
public void receieveAndDontSetDeleteFlagWithoutUrl() throws Exception{
public void receieveAndDontSetDeleteWithoutUrl() throws Exception{
AbstractMailReceiver receiver = new Pop3MailReceiver();
receiver = spy(receiver);
receiver.afterPropertiesSet();

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2002-2009 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.mail.config;
import org.junit.Test;
import org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* @author Oleg Zhurakousky
*
*/
public class FailedMailConfigurationTests {
/**
* validates that if 'should-delete-messages' is not set the context fails
*/
@Test(expected=XmlBeanDefinitionStoreException.class)
public void testImapIdleWithNoDeleteMessageAttribute(){
new ClassPathXmlApplicationContext("failed-imap-config.xml", this.getClass());
}
/**
* validates that if 'should-delete-messages' is not set the context fails
*/
@Test(expected=XmlBeanDefinitionStoreException.class)
public void testAdapterWithNoDeleteMessageAttribute(){
new ClassPathXmlApplicationContext("failed-adapter-config.xml", this.getClass());
}
}

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.0.xsd"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-mail="http://www.springframework.org/schema/integration/mail">
<int:channel id="recieveChannel"/>
<int-mail:inbound-channel-adapter store-uri="imaps://[username]:[password]@imap.gmail.com/INBOX"
channel="recieveChannel">
<int:poller max-messages-per-poll="1">
<int:interval-trigger interval="5000"/>
</int:poller>
</int-mail:inbound-channel-adapter>
</beans>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.0.xsd"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-mail="http://www.springframework.org/schema/integration/mail">
<int:channel id="recieveChannel"/>
<int-mail:imap-idle-channel-adapter store-uri="imaps://[username]:[password]@imap.gmail.com/INBOX"
channel="recieveChannel"/>
</beans>