use of org.springframework.mail.MailSender in project spring-integration by spring-projects.
the class MailOutboundChannelAdapterParserTests method adapterWithJavaMailProperties.
@Test
public void adapterWithJavaMailProperties() {
ConfigurableApplicationContext 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);
Properties javaMailProperties = (Properties) TestUtils.getPropertyValue(mailSender, "javaMailProperties");
assertEquals(7, javaMailProperties.size());
assertNotNull(javaMailProperties);
assertEquals("true", javaMailProperties.get("mail.smtps.auth"));
context.close();
}
use of org.springframework.mail.MailSender in project spring-integration by spring-projects.
the class MailOutboundChannelAdapterParserTests method adapterWithHostProperty.
@Test
public void adapterWithHostProperty() {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("mailOutboundChannelAdapterParserTests.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);
context.close();
}
use of org.springframework.mail.MailSender in project spring-thymeleaf-simplefinance by heitkergm.
the class Application method sendStartupEmail.
private static void sendStartupEmail(final ApplicationContext ctx) {
MailSender mailer = ctx.getBean(MailSender.class);
SimpleMailMessage msg = new SimpleMailMessage();
String envProp = System.getenv("MAIL_TO");
String recipient;
recipient = envProp != null ? envProp : ctx.getMessage("mail.to", new Object[] {}, Locale.getDefault());
msg.setFrom(ctx.getMessage("mail.sender", new Object[] {}, Locale.getDefault()));
msg.setTo(recipient);
msg.setSubject(ctx.getMessage("mail.subject", new Object[] {}, Locale.getDefault()));
msg.setText(ctx.getMessage("mail.upmsg", new Object[] {}, Locale.getDefault()));
mailer.send(msg);
}
use of org.springframework.mail.MailSender in project spring-integration by spring-projects.
the class MailOutboundChannelAdapterParserTests method adapterWithMailSenderReference.
@Test
public void adapterWithMailSenderReference() {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("mailOutboundChannelAdapterParserTests.xml", this.getClass());
Object adapter = context.getBean("adapterWithMailSenderReference.adapter");
MailSendingMessageHandler handler = (MailSendingMessageHandler) new DirectFieldAccessor(adapter).getPropertyValue("handler");
DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(handler);
MailSender mailSender = (MailSender) fieldAccessor.getPropertyValue("mailSender");
assertNotNull(mailSender);
assertEquals(23, fieldAccessor.getPropertyValue("order"));
context.close();
}
use of org.springframework.mail.MailSender in project spring-cloud-connectors by spring-cloud.
the class SmtpServiceConnectorCreatorTest method cloudMailSenderCreation.
@Test
public void cloudMailSenderCreation() throws Exception {
SmtpServiceInfo serviceInfo = createServiceInfo();
MailSender dataSource = testCreator.create(serviceInfo, null);
assertConnectorProperties(serviceInfo, dataSource);
}
Aggregations