INT-1712 fixed the way MailOutboundChannelAdapterParser sets the javaMailProperties
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
</configSuffixes>
|
||||
<enableImports><![CDATA[false]]></enableImports>
|
||||
<configs>
|
||||
<config>src/test/java/org/springframework/integration/mail/config/MailOutboundWithJavamailProperties-context.xml</config>
|
||||
</configs>
|
||||
<configSets>
|
||||
</configSets>
|
||||
|
||||
@@ -64,8 +64,9 @@ public class MailOutboundChannelAdapterParser extends AbstractOutboundChannelAda
|
||||
if (StringUtils.hasText(port)) {
|
||||
mailSenderBuilder.addPropertyValue("port", port);
|
||||
}
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(
|
||||
mailSenderBuilder, element, "java-mail-properties", "javaMailProperties");
|
||||
|
||||
String mailSenderBeanName = BeanDefinitionReaderUtils.registerWithGeneratedName(
|
||||
mailSenderBuilder.getBeanDefinition(), parserContext.getRegistry());
|
||||
builder.addConstructorArgReference(mailSenderBeanName);
|
||||
|
||||
@@ -54,5 +54,17 @@ public class MailOutboundChannelAdapterParserTests {
|
||||
MailSender mailSender = (MailSender) fieldAccessor.getPropertyValue("mailSender");
|
||||
assertNotNull(mailSender);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adapterWithJavaMailProperties() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"MailOutboundWithJavamailProperties-context.xml", this.getClass());
|
||||
Object adapter = context.getBean("adapterWithHostProperty.adapter");
|
||||
MailSendingMessageHandler handler = (MailSendingMessageHandler)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("handler");
|
||||
DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(handler);
|
||||
MailSender mailSender = (MailSender) fieldAccessor.getPropertyValue("mailSender");
|
||||
assertNotNull(mailSender);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.0.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"
|
||||
xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
|
||||
xmlns:util="http://www.springframework.org/schema/util">
|
||||
|
||||
<int-mail:outbound-channel-adapter
|
||||
id="adapterWithHostProperty" host="somehost" username="someuser"
|
||||
password="somepassword" java-mail-properties="javaMailProperties"/>
|
||||
|
||||
<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.transport.protocol">smtps</prop>
|
||||
<prop key="mail.smtps.auth">true</prop>
|
||||
<prop key="mail.smtp.starttls.enable">true</prop>
|
||||
<prop key="mail.debug">false</prop>
|
||||
</util:properties>
|
||||
</beans>
|
||||
Reference in New Issue
Block a user