Merge pull request #72 from olegz/INT-2106
added support for poller to outbound mail adapter
This commit is contained in:
@@ -26,6 +26,9 @@
|
||||
Defines an outbound mail-sending Channel Adapter.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:sequence>
|
||||
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="channel" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
Defines an outbound mail-sending Channel Adapter.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:sequence>
|
||||
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="channel" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
|
||||
@@ -16,20 +16,22 @@
|
||||
|
||||
package org.springframework.integration.mail.config;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
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.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.endpoint.PollingConsumer;
|
||||
import org.springframework.integration.mail.MailSendingMessageHandler;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.mail.MailSender;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@@ -60,6 +62,15 @@ public class MailOutboundChannelAdapterParserTests {
|
||||
assertNotNull(mailSender);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adapterWithPollableChannel() {
|
||||
ApplicationContext 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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adapterWithJavaMailProperties() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:mail="http://www.springframework.org/schema/integration/mail"
|
||||
xmlns:integration="http://wwww.springframework.org/schema/integration"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/mail
|
||||
http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd">
|
||||
xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.1.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<mail:outbound-channel-adapter id="adapterWithMailSenderReference"
|
||||
<int-mail:outbound-channel-adapter id="adapterWithMailSenderReference"
|
||||
order="23"
|
||||
mail-sender="mailSender"/>
|
||||
|
||||
<mail:outbound-channel-adapter id="adapterWithHostProperty"
|
||||
|
||||
<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"/>
|
||||
|
||||
<bean id="mailSender" class="org.springframework.integration.mail.StubJavaMailSender">
|
||||
@@ -25,4 +32,4 @@
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user