File Cleanup - JPA to RMI
This commit is contained in:
@@ -17,11 +17,13 @@
|
||||
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
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
public class FailedMailConfigurationTests {
|
||||
@@ -30,13 +32,13 @@ public class FailedMailConfigurationTests {
|
||||
*/
|
||||
@Test(expected = XmlBeanDefinitionStoreException.class)
|
||||
public void testImapIdleWithNoDeleteMessageAttribute() {
|
||||
new ClassPathXmlApplicationContext("failed-imap-config.xml", this.getClass());
|
||||
new ClassPathXmlApplicationContext("failed-imap-config.xml", this.getClass()).close();
|
||||
}
|
||||
/**
|
||||
* 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());
|
||||
new ClassPathXmlApplicationContext("failed-adapter-config.xml", this.getClass()).close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -22,18 +22,19 @@ import static org.junit.Assert.assertNotNull;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.integration.endpoint.PollingConsumer;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
import org.springframework.integration.mail.MailSendingMessageHandler;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.mail.MailSender;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -46,7 +47,7 @@ public class MailOutboundChannelAdapterParserTests {
|
||||
|
||||
@Test
|
||||
public void adapterWithMailSenderReference() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"mailOutboundChannelAdapterParserTests.xml", this.getClass());
|
||||
Object adapter = context.getBean("adapterWithMailSenderReference.adapter");
|
||||
MailSendingMessageHandler handler = (MailSendingMessageHandler)
|
||||
@@ -55,22 +56,24 @@ public class MailOutboundChannelAdapterParserTests {
|
||||
MailSender mailSender = (MailSender) fieldAccessor.getPropertyValue("mailSender");
|
||||
assertNotNull(mailSender);
|
||||
assertEquals(23, fieldAccessor.getPropertyValue("order"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void advised() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"mailOutboundChannelAdapterParserTests.xml", this.getClass());
|
||||
Object adapter = context.getBean("advised.adapter");
|
||||
MessageHandler handler = (MessageHandler)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("handler");
|
||||
handler.handleMessage(new GenericMessage<String>("foo"));
|
||||
assertEquals(1, adviceCalled);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adapterWithHostProperty() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"mailOutboundChannelAdapterParserTests.xml", this.getClass());
|
||||
Object adapter = context.getBean("adapterWithHostProperty.adapter");
|
||||
MailSendingMessageHandler handler = (MailSendingMessageHandler)
|
||||
@@ -78,20 +81,22 @@ public class MailOutboundChannelAdapterParserTests {
|
||||
DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(handler);
|
||||
MailSender mailSender = (MailSender) fieldAccessor.getPropertyValue("mailSender");
|
||||
assertNotNull(mailSender);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adapterWithPollableChannel() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"mailOutboundChannelAdapterParserTests.xml", this.getClass());
|
||||
PollingConsumer pc = context.getBean("adapterWithPollableChannel", PollingConsumer.class);
|
||||
QueueChannel pollableChannel = TestUtils.getPropertyValue(pc, "inputChannel", QueueChannel.class);
|
||||
assertEquals("pollableChannel", pollableChannel.getComponentName());
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adapterWithJavaMailProperties() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"MailOutboundWithJavamailProperties-context.xml", this.getClass());
|
||||
Object adapter = context.getBean("adapterWithHostProperty.adapter");
|
||||
MailSendingMessageHandler handler = (MailSendingMessageHandler)
|
||||
@@ -103,6 +108,7 @@ public class MailOutboundChannelAdapterParserTests {
|
||||
assertEquals(7, javaMailProperties.size());
|
||||
assertNotNull(javaMailProperties);
|
||||
assertEquals("true", javaMailProperties.get("mail.smtps.auth"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
public static class FooAdvice extends AbstractRequestHandlerAdvice {
|
||||
|
||||
@@ -73,7 +73,8 @@ public class MailToStringTransformerParserTests {
|
||||
@Test(expected = BeanDefinitionStoreException.class)
|
||||
public void topLevelTransformerMissingInput() {
|
||||
try {
|
||||
new ClassPathXmlApplicationContext("mailToStringTransformerWithoutInputChannel.xml", this.getClass());
|
||||
new ClassPathXmlApplicationContext("mailToStringTransformerWithoutInputChannel.xml", this.getClass())
|
||||
.close();
|
||||
}
|
||||
catch (BeanDefinitionStoreException e) {
|
||||
assertTrue(e.getMessage().contains("input-channel"));
|
||||
|
||||
@@ -12,27 +12,27 @@
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<int:channel id="inputChannel"/>
|
||||
|
||||
|
||||
<int-mail:header-enricher input-channel="inputChannel" output-channel="mailChannel">
|
||||
<int-mail:to value="mailto"/>
|
||||
<int-mail:from value="mailfrom"/>
|
||||
<int-mail:subject value="With Content Type"/>
|
||||
<int-mail:content-type value="text/html"/>
|
||||
</int-mail:header-enricher>
|
||||
|
||||
|
||||
<int:channel id="mailChannel"/>
|
||||
|
||||
<int-mail:outbound-channel-adapter channel="mailChannel"
|
||||
|
||||
<int-mail:outbound-channel-adapter channel="mailChannel"
|
||||
host="smtp.gmail.com"
|
||||
port="587"
|
||||
username="user"
|
||||
password="password"
|
||||
java-mail-properties="javaMailProperties"/>
|
||||
|
||||
|
||||
<util:properties id="javaMailProperties">
|
||||
<prop key="mail.debug">true</prop>
|
||||
<prop key="mail.smtps.auth">true</prop>
|
||||
<prop key="mail.smtp.starttls.enable">true</prop>
|
||||
</util:properties>
|
||||
<prop key="mail.smtps.auth">true</prop>
|
||||
<prop key="mail.smtp.starttls.enable">true</prop>
|
||||
</util:properties>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -36,19 +36,20 @@ import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.mail.MailHeaders;
|
||||
import org.springframework.integration.mail.MailSendingMessageHandler;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
public class MessageWithContentTypeTests {
|
||||
@@ -56,12 +57,14 @@ public class MessageWithContentTypeTests {
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSendEmail() throws Exception {
|
||||
ApplicationContext ac = new ClassPathXmlApplicationContext("MessageWithContentTypeTests-context.xml", this.getClass());
|
||||
ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext(
|
||||
"MessageWithContentTypeTests-context.xml", this.getClass());
|
||||
MessageChannel inputChannel = ac.getBean("inputChannel", MessageChannel.class);
|
||||
StringWriter writer = new StringWriter();
|
||||
FileReader reader = new FileReader("src/test/java/org/springframework/integration/mail/config/test.html");
|
||||
FileCopyUtils.copy(reader, writer);
|
||||
inputChannel.send(new GenericMessage<String>(writer.getBuffer().toString()));
|
||||
ac.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,6 +83,7 @@ public class MessageWithContentTypeTests {
|
||||
// MOCKS
|
||||
when(sender.createMimeMessage()).thenReturn(mMessage);
|
||||
doAnswer(new Answer<Object>() {
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||
MimeMessage mimeMessage = (MimeMessage) invocation.getArguments()[0];
|
||||
assertEquals("text/html", mimeMessage.getDataHandler().getContentType());
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
xmlns:int-mail="http://www.springframework.org/schema/integration/mail">
|
||||
|
||||
<int:channel id="receiveChannel"/>
|
||||
|
||||
|
||||
<int-mail:inbound-channel-adapter store-uri="imaps://[username]:[password]@imap.gmail.com/INBOX"
|
||||
channel="receiveChannel">
|
||||
<int:poller max-messages-per-poll="1">
|
||||
<int:interval-trigger interval="5000"/>
|
||||
</int:poller>
|
||||
</int-mail:inbound-channel-adapter>
|
||||
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
xmlns:int-mail="http://www.springframework.org/schema/integration/mail">
|
||||
|
||||
<int:channel id="receiveChannel"/>
|
||||
|
||||
|
||||
<int-mail:imap-idle-channel-adapter store-uri="imaps://[username]:[password]@imap.gmail.com/INBOX"
|
||||
channel="receiveChannel"/>
|
||||
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
xmlns:task="http://www.springframework.org/schema/task"
|
||||
xmlns:util="http://www.springframework.org/schema/util">
|
||||
|
||||
<!--
|
||||
|
||||
<!--
|
||||
|
||||
IMAP and IMAP IDLE sample configuration to use with Gmail
|
||||
There is no test to back this up, just a sample config to use with your tests
|
||||
-->
|
||||
@@ -23,30 +23,28 @@
|
||||
auto-startup="true"
|
||||
should-delete-messages="false"
|
||||
java-mail-properties="javaMailProperties"/>
|
||||
|
||||
|
||||
<int-mail:inbound-channel-adapter id="imapAdapter"
|
||||
store-uri="imaps://[username]:[password]@imap.gmail.com/INBOX"
|
||||
java-mail-properties="javaMailProperties"
|
||||
channel="receiveChannel"
|
||||
should-delete-messages="true"
|
||||
java-mail-properties="javaMailProperties"
|
||||
channel="receiveChannel"
|
||||
should-delete-messages="true"
|
||||
auto-startup="true">
|
||||
<int:poller max-messages-per-poll="1">
|
||||
<int:interval-trigger interval="5000"/>
|
||||
</int:poller>
|
||||
<int:poller max-messages-per-poll="1" fixed-delay="5000" />
|
||||
</int-mail:inbound-channel-adapter>
|
||||
|
||||
|
||||
<int:channel id="receiveChannel"/>
|
||||
|
||||
|
||||
<int:service-activator input-channel="receiveChannel">
|
||||
<bean class="org.springframework.integration.mail.config.GoogleTest.SampleReceiver"/>
|
||||
</int:service-activator>
|
||||
|
||||
|
||||
<util:properties id="javaMailProperties">
|
||||
<prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
|
||||
<prop key="mail.imap.socketFactory.fallback">false</prop>
|
||||
<prop key="mail.store.protocol">imaps</prop>
|
||||
<prop key="mail.debug">false</prop>
|
||||
</util:properties>
|
||||
|
||||
|
||||
<task:executor id="executor" pool-size="5"/>
|
||||
</beans>
|
||||
|
||||
@@ -10,17 +10,17 @@
|
||||
<int-mail:outbound-channel-adapter id="adapterWithMailSenderReference"
|
||||
order="23"
|
||||
mail-sender="mailSender"/>
|
||||
|
||||
|
||||
<int-mail:outbound-channel-adapter id="adapterWithPollableChannel" channel="pollableChannel"
|
||||
order="23"
|
||||
mail-sender="mailSender">
|
||||
<int:poller fixed-rate="100" max-messages-per-poll="4"/>
|
||||
</int-mail:outbound-channel-adapter>
|
||||
|
||||
|
||||
<int:channel id="pollableChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
|
||||
<int-mail:outbound-channel-adapter id="adapterWithHostProperty"
|
||||
host="somehost" username="someuser" password="somepassword"/>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user