public void testSendMailWithChangedPort() throws Throwable {
MockMessageHandlerFactory myFactory2 = new MockMessageHandlerFactory();
MockAuthenticationHandlerFactory myAuthFactory2 = new MockAuthenticationHandlerFactory();
SMTPServer smtpServer2 = new SMTPServer(myFactory2, myAuthFactory2);
smtpServer2.setPort(25001);
smtpServer2.start();
MailConfig originaryConfig = this._mailManager.getMailConfig();
try {
MailConfig config = this._mailManager.getMailConfig();
config.setSmtpPort(25001);
this._mailManager.updateMailConfig(config);
String[] mailAddresses = JpmailTestHelper.MAIL_ADDRESSES;
this._mailManager.sendMail(MAIL_TEXT, "Mail semplice", mailAddresses, mailAddresses, mailAddresses, SENDER_CODE);
} catch (Throwable t) {
throw t;
} finally {
this._mailManager.updateMailConfig(originaryConfig);
this.checkOriginaryConfig(originaryConfig);
}
myFactory2 = null;
myAuthFactory2 = null;
smtpServer2.stop();
smtpServer2 = null;
}