當前位置: 首頁>>代碼示例>>Java>>正文


Java Wiser類代碼示例

本文整理匯總了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.
	}
}
 
開發者ID:emily-e,項目名稱:webframework,代碼行數:22,代碼來源:SmtpTest.java

示例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);
            }
        }
    }
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:20,代碼來源:EmailSendTaskTest.java

示例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);
            }
        }
    }
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:20,代碼來源:EmailTestCase.java

示例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();        
}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:24,代碼來源:MailerTest.java

示例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");
}
 
開發者ID:voodoodyne,項目名稱:subetha,代碼行數:20,代碼來源:FallthroughByHand.java

示例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"));
   }
 
開發者ID:gisgraphy,項目名稱:gisgraphy,代碼行數:19,代碼來源:PasswordHintActionTest.java

示例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());
   }
 
開發者ID:gisgraphy,項目名稱:gisgraphy,代碼行數:26,代碼來源:MailEngineTest.java

示例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();
	}
}
 
開發者ID:voodoodyne,項目名稱:subethasmtp,代碼行數:21,代碼來源:TimeoutTest.java

示例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();
}
 
開發者ID:voodoodyne,項目名稱:subethasmtp,代碼行數:17,代碼來源:MessageContentTest.java

示例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));
}
 
開發者ID:SMVBE,項目名稱:ldadmin,代碼行數:21,代碼來源:UpdatePasswordControllerTest.java

示例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));
}
 
開發者ID:SMVBE,項目名稱:ldadmin,代碼行數:25,代碼來源:UpdatePasswordControllerTest.java

示例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));
}
 
開發者ID:SMVBE,項目名稱:ldadmin,代碼行數:20,代碼來源:PasswordHintControllerTest.java

示例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());
}
 
開發者ID:SMVBE,項目名稱:ldadmin,代碼行數:25,代碼來源:MailEngineTest.java

示例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));
}
 
開發者ID:SMVBE,項目名稱:ldadmin,代碼行數:23,代碼來源:PasswordTokenManagerTest.java

示例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);
      }
    }
  }
}
 
開發者ID:logicalhacking,項目名稱:SecureBPMN,代碼行數:20,代碼來源:EmailSendTaskTest.java


注:本文中的org.subethamail.wiser.Wiser類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。