use of javax.mail.Provider in project Activiti by Activiti.
the class JndiEmailTest method setUp.
@BeforeClass
public void setUp() {
Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.provider.class", MockEmailTransport.class.getName());
props.put("mail.smtp.class", MockEmailTransport.class.getName());
props.put("mail.smtp.provider.vendor", "test");
props.put("mail.smtp.provider.version", "0.0.0");
Provider provider = new Provider(Type.TRANSPORT, "smtp", MockEmailTransport.class.getName(), "test", "1.0");
Session mailSession = Session.getDefaultInstance(props);
SimpleNamingContextBuilder builder = null;
try {
mailSession.setProvider(provider);
builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
builder.bind("java:comp/env/Session", mailSession);
} catch (NamingException e) {
logger.error("Naming error in email setup", e);
} catch (NoSuchProviderException e) {
logger.error("provider error in email setup", e);
}
}
use of javax.mail.Provider in project spring-boot by spring-projects.
the class MailHealthIndicatorTests method setup.
@Before
public void setup() {
Session session = Session.getDefaultInstance(new Properties());
session.addProvider(new Provider(Type.TRANSPORT, "success", SuccessTransport.class.getName(), "Test", "1.0.0"));
this.mailSender = mock(JavaMailSenderImpl.class);
given(this.mailSender.getHost()).willReturn("smtp.acme.org");
given(this.mailSender.getPort()).willReturn(25);
given(this.mailSender.getSession()).willReturn(session);
this.indicator = new MailHealthIndicator(this.mailSender);
}
Aggregations