本文整理汇总了Java中org.subethamail.wiser.Wiser.setPort方法的典型用法代码示例。如果您正苦于以下问题:Java Wiser.setPort方法的具体用法?Java Wiser.setPort怎么用?Java Wiser.setPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.subethamail.wiser.Wiser
的用法示例。
在下文中一共展示了Wiser.setPort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
final Wiser wiser = new Wiser();
wiser.setPort(2500);
wiser.start();
final SmtpSender mailer = new SmtpSender("localhost", 2500, "test", "asdf", "localhost", SmtpSender.Security.TRY_TLS);
final MessageStruct msg = new MessageStruct();
msg.Sender = "[email protected]";
msg.Recipient = "[email protected]";
msg.Subject = "Test";
msg.Message = "The message.";
msg.MailId = 0L;
try (final SmtpSender.Connection conn = mailer.getConnection()) {
mailer.send(conn, msg);
}
wiser.stop();
try (final SmtpSender.Connection conn = mailer.getConnection()) {
throw new AssertionError("Connection should fail now that there is no running mail server.");
} catch (final Exception ex) {
// Expected.
}
}
示例2: setUp
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
boolean serverUpAndRunning = false;
while (!serverUpAndRunning) {
wiser = new Wiser();
wiser.setPort(5025);
try {
wiser.start();
serverUpAndRunning = true;
} catch (RuntimeException e) { // Fix for slow port-closing Jenkins
if (e.getMessage().toLowerCase().contains("BindException")) {
Thread.sleep(250L);
}
}
}
}
示例3: setUp
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
boolean serverUpAndRunning = false;
while (!serverUpAndRunning) {
wiser = new Wiser();
wiser.setPort(5025);
try {
wiser.start();
serverUpAndRunning = true;
} catch (RuntimeException e) { // Fix for slow port-closing Jenkins
if (e.getMessage().toLowerCase().contains("bindexception")) {
Thread.sleep(250L);
}
}
}
}
示例4: testSendMessage
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
/**
* Test that a Mailer can be retrieved via the KEWServiceLocator and can be used
* to send an e-mail message to the SMTP server.
*/
@Test
public void testSendMessage() {
// Initialize SMTP server
Wiser smtpServer = new Wiser();
smtpServer.setPort(55000);
smtpServer.start();
// Test that a Mailer can be retrieved via the KEWServiceLocator
Mailer mailer = null;
mailer = CoreApiServiceLocator.getMailer();
assertNotNull(mailer);
// Test that an e-mail message gets sent to the SMTP server
mailer.sendEmail(new EmailFrom(sender), new EmailTo(recipient), new EmailSubject(subject), new EmailBody(messageBody), false);
Assert.assertEquals(1, smtpServer.getMessages().size());
// Shutdown the SMTP server
smtpServer.stop();
}
示例5: testExecute
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test
public void testExecute() throws Exception {
// start SMTP Server
Wiser wiser = new Wiser();
wiser.setPort(2525);
wiser.start();
passwordHintAction.setUsername("user");
assertEquals("success", passwordHintAction.execute());
assertFalse(passwordHintAction.hasActionErrors());
// verify an account information e-mail was sent
wiser.stop();
assertTrue(wiser.getMessages().size() == 1);
// verify that success messages are in the request
assertNotNull(passwordHintAction.getSession().getAttribute("messages"));
}
示例6: testSend
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test
public void testSend() throws Exception {
// mock smtp server
Wiser wiser = new Wiser();
// set the port to a random value so there's no conflicts between tests
int port = 2525 + (int) (Math.random() * 100);
mailSender.setPort(port);
wiser.setPort(port);
wiser.start();
Date dte = new Date();
this.mailMessage.setTo("[email protected]");
String emailSubject = "grepster testSend: " + dte;
String emailBody = "Body of the grepster testSend message sent at: "
+ dte;
this.mailMessage.setSubject(emailSubject);
this.mailMessage.setText(emailBody);
this.mailEngine.send(this.mailMessage);
wiser.stop();
assertTrue(wiser.getMessages().size() == 1);
WiserMessage wm = wiser.getMessages().get(0);
assertEquals(emailSubject, wm.getMimeMessage().getSubject());
assertEquals(emailBody, wm.getMimeMessage().getContent());
}
示例7: setUp
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
boolean serverUpAndRunning = false;
while (!serverUpAndRunning) {
wiser = new Wiser();
wiser.setPort(5025);
try {
wiser.start();
serverUpAndRunning = true;
} catch (RuntimeException e) { // Fix for slow port-closing Jenkins
if (e.getMessage().toLowerCase().contains("BindException")) {
Thread.sleep(250L);
}
}
}
}
示例8: testTimeout
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
/** */
@Test
public void testTimeout() throws Exception {
Wiser wiser = new Wiser();
wiser.setPort(PORT);
wiser.getServer().setConnectionTimeout(1000);
wiser.start();
SMTPClient client = new SMTPClient("localhost", PORT);
client.sendReceive("HELO foo");
Thread.sleep(2000);
try {
client.sendReceive("HELO bar");
fail();
} catch (SocketException e) {
// expected
} finally {
wiser.stop();
}
}
示例9: testSend
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test
public void testSend() throws Exception {
// mock smtp server
Wiser wiser = new Wiser();
// set the port to a random value so there's no conflicts between tests
int port = 2525 + (int)(Math.random() * 100);
mailSender.setPort(port);
wiser.setPort(port);
wiser.start();
Date dte = new Date();
this.mailMessage.setTo("[email protected]");
String emailSubject = "grepster testSend: " + dte;
String emailBody = "Body of the grepster testSend message sent at: " + dte;
this.mailMessage.setSubject(emailSubject);
this.mailMessage.setText(emailBody);
this.mailEngine.send(this.mailMessage);
wiser.stop();
assertTrue(wiser.getMessages().size() == 1);
WiserMessage wm = wiser.getMessages().get(0);
assertEquals(emailSubject, wm.getMimeMessage().getSubject());
assertEquals(emailBody, wm.getMimeMessage().getContent());
}
示例10: testConsumeRecoveryToken
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test
public void testConsumeRecoveryToken() throws Exception {
final User user = userManager.getUserByUsername("user");
final Integer version = user.getVersion();
final String token = passwordTokenManager.generateRecoveryToken(user);
Assert.assertNotNull(token);
Assert.assertTrue(passwordTokenManager.isRecoveryTokenValid(user, token));
// start SMTP Server
final Wiser wiser = new Wiser();
wiser.setPort(smtpPort);
wiser.start();
userManager.updatePassword(user.getUsername(), null, token, "user", "");
wiser.stop();
assertTrue(wiser.getMessages().size() == 1);
Assert.assertTrue(user.getVersion() > version);
Assert.assertFalse(passwordTokenManager.isRecoveryTokenValid(user, token));
}
示例11: create
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@BeforeClass
public void create() throws Exception {
wiser = new Wiser();
wiser.setHostname("localhost");
wiser.setPort(25000);
queryService = LensServices.get().getService(QueryExecutionService.NAME);
Map<String, String> sessionconf = new HashMap<>();
sessionconf.put("test.session.key", "svalue");
sessionconf.put(LensConfConstants.QUERY_MAIL_NOTIFY, "true");
sessionconf.put(LensConfConstants.QUERY_RESULT_EMAIL_CC, "[email protected],[email protected],[email protected]");
lensSessionId = queryService.openSession("[email protected]", "bar", sessionconf); // @localhost should be removed
// automatically
createTable(TEST_TABLE);
loadData(TEST_TABLE, TestResourceFile.TEST_DATA2_FILE.getValue());
wiser.start();
}
示例12: setUp
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
boolean serverUpAndRunning = false;
while (!serverUpAndRunning) {
wiser = new Wiser();
wiser.setPort(5025);
try {
wiser.start();
serverUpAndRunning = true;
} catch (RuntimeException e) { // Fix for slow port-closing Jenkins
if (e.getMessage().toLowerCase().contains("bindexception")) {
Thread.sleep(250L);
}
}
}
}
示例13: setUp
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
int port = processEngineConfiguration.getMailServerPort();
boolean serverUpAndRunning = false;
while (!serverUpAndRunning) {
wiser = new Wiser();
wiser.setPort(port);
try {
LOG.info("Starting Wiser mail server on port: " + port);
wiser.start();
serverUpAndRunning = true;
LOG.info("Wiser mail server listening on port: " + port);
} catch (RuntimeException e) { // Fix for slow port-closing Jenkins
if (e.getMessage().toLowerCase().contains("BindException")) {
Thread.sleep(250L);
}
}
}
}
示例14:
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Bean(initMethod = "start", destroyMethod = "stop")
/* */ Wiser wiser() {
/* 49 */ Wiser answer = new Wiser();
/* 50 */ answer.setPort(this.mailEasyConfig.getSmtpPort());
/* 51 */ answer.setHostname(this.mailEasyConfig.getSmtpHost());
/* 52 */ return answer;
/* */ }
示例15: setupClass
import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@BeforeClass
public static void setupClass() throws IOException {
Properties p = new Properties();
try {
p.load(AbstractTestCase.class.getResourceAsStream("/mail.properties"));
wiser = new Wiser();
wiser.setHostname(p.getProperty("mail.host"));
wiser.setPort(Integer.valueOf(p.getProperty("mail.port")));
wiser.start();
} catch (IOException e) {
throw e;
}
}