本文整理汇总了Java中org.subethamail.wiser.Wiser类的典型用法代码示例。如果您正苦于以下问题:Java Wiser类的具体用法?Java Wiser怎么用?Java Wiser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Wiser类属于org.subethamail.wiser包,在下文中一共展示了Wiser类的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 = "e[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: setUp
import org.subethamail.wiser.Wiser; //导入依赖的package包/类
/** */
@Before
public void setUp() throws Exception
{
this.fallthrough = new Wiser(FALLTHROUGH_PORT);
this.fallthrough.start();
this.smtp = new Wiser(2525);
this.smtp.start();
this.admin = new AdminMixin();
Properties props = new Properties();
props.setProperty("mail.smtp.host", "localhost");
props.setProperty("mail.smtp.port", "2500");
this.sess = Session.getDefaultInstance(props);
//this.admin.getEegor().enableTestMode("localhost:2525");
}
示例6: 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"));
}
示例7: 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());
}
示例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: setUp
import org.subethamail.wiser.Wiser; //导入依赖的package包/类
/** */
@Override
protected void setUp() throws Exception
{
super.setUp();
Properties props = new Properties();
props.setProperty("mail.smtp.host", "localhost");
props.setProperty("mail.smtp.port", Integer.toString(PORT));
this.session = Session.getInstance(props);
this.wiser = new Wiser();
this.wiser.setPort(PORT);
this.wiser.start();
}
示例10: testRequestRecoveryToken
import org.subethamail.wiser.Wiser; //导入依赖的package包/类
@Test
public void testRequestRecoveryToken() throws Exception {
String username = "admin";
MockHttpServletRequest request = newGet("/updatePassword");
request.addParameter("username", username);
// start SMTP Server
Wiser wiser = new Wiser();
wiser.setPort(getSmtpPort());
wiser.start();
controller.requestRecoveryToken(username, request);
// verify an account information e-mail was sent
wiser.stop();
assertTrue(wiser.getMessages().size() == 1);
// verify that success messages are in the session
assertNotNull(request.getSession().getAttribute(Constants.SUCCESS_MESSAGES_KEY));
}
示例11: testResetPassword
import org.subethamail.wiser.Wiser; //导入依赖的package包/类
@Test
public void testResetPassword() throws Exception {
String username = "admin";
User user = userManager.getUserByUsername(username);
String token = userManager.generateRecoveryToken(user);
String password = "new-pass";
MockHttpServletRequest request = newGet("/updatePassword");
request.addParameter("username", username);
request.addParameter("token", token);
request.addParameter("password", password);
Wiser wiser = new Wiser();
wiser.setPort(getSmtpPort());
wiser.start();
ModelAndView mav = controller.onSubmit(username, token, null, password, request);
wiser.stop();
assertTrue(wiser.getMessages().size() == 1);
assertNotNull(request.getSession().getAttribute(Constants.SUCCESS_MESSAGES_KEY));
assertNull(request.getSession().getAttribute(Constants.ERRORS_MESSAGES_KEY));
}
示例12: testExecute
import org.subethamail.wiser.Wiser; //导入依赖的package包/类
@Test
public void testExecute() throws Exception {
MockHttpServletRequest request = newGet("/passwordHint.html");
request.addParameter("username", "user");
// start SMTP Server
Wiser wiser = new Wiser();
wiser.setPort(getSmtpPort());
wiser.start();
c.handleRequest(request);
// verify an account information e-mail was sent
wiser.stop();
assertTrue(wiser.getMessages().size() == 1);
// verify that success messages are in the session
assertNotNull(request.getSession().getAttribute(Constants.SUCCESS_MESSAGES_KEY));
}
示例13: 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());
}
示例14: 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));
}
示例15: 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);
}
}
}
}