public class MailService extends Object
Constructor and Description |
---|
MailService(com.atlassian.jira.testkit.client.log.FuncTestLogger log) |
MailService(java.util.function.Supplier<com.atlassian.jira.testkit.client.log.FuncTestLogger> log) |
Modifier and Type | Method and Description |
---|---|
void |
addUser(String email,
String login,
String password)
Adds a user to the mail service.
|
com.icegreen.greenmail.util.GreenMail |
configureAndStartGreenMail(JIRAServerSetup... serverSetups) |
int |
getImapPort() |
int |
getPop3Port() |
javax.mail.internet.MimeMessage |
getReceivedMessage()
Get the first message of all messages received until now.
|
javax.mail.internet.MimeMessage[] |
getReceivedMessages()
Returns an array of all messages received until now.
|
javax.mail.internet.MimeMessage[] |
getReceivedMessagesAndClear()
Returns an array of all messages received until now, clearing the list on the mail server.
|
int |
getSmtpPort() |
com.icegreen.greenmail.store.MailFolder |
getUserInbox(String userEmail)
Get the
inbox for the user with email userEmail. |
boolean |
isRunning()
Returns true if the mail servers are running.
|
void |
removeAllReceivedMessages()
Removes all received mails.
|
void |
sendTextMessage(String to,
String from,
String subject,
String body)
Sends an email with the content type "text/plain" and the given contents using the test SMTP server.
|
void |
stop()
Stops the SMTP and POP3 server.
|
javax.mail.internet.MimeMessage |
waitAndGetReceivedMessage()
Does the same as
getReceivedMessage() but waits until a message is received or until a timeout is
reached. |
boolean |
waitForIncomingMessage(int numberOfMessages)
Wait until the specified number of mails is received or until 10 seconds have passed.
|
boolean |
waitForIncomingMessage(long timeout,
int numberOfMessages)
Wait until the specified number of mails is received or until a timeout is reached.
|
public MailService(com.atlassian.jira.testkit.client.log.FuncTestLogger log)
public MailService(java.util.function.Supplier<com.atlassian.jira.testkit.client.log.FuncTestLogger> log)
public com.icegreen.greenmail.util.GreenMail configureAndStartGreenMail(JIRAServerSetup... serverSetups) throws BindException
BindException
public void stop()
public boolean isRunning()
public void addUser(String email, String login, String password)
email
- email of the user to be createdlogin
- login of the user to be createdpassword
- password of the user to be createdpublic int getPop3Port()
public int getSmtpPort()
public int getImapPort()
public void sendTextMessage(String to, String from, String subject, String body)
to
- email address this mail should be sent tofrom
- email address this mail should appear to be sent fromsubject
- subject of the emailbody
- body of the emailpublic javax.mail.internet.MimeMessage[] getReceivedMessages()
public javax.mail.internet.MimeMessage[] getReceivedMessagesAndClear() throws com.icegreen.greenmail.store.FolderException
com.icegreen.greenmail.store.FolderException
- if there's a problem clearing the listpublic javax.mail.internet.MimeMessage getReceivedMessage()
public javax.mail.internet.MimeMessage waitAndGetReceivedMessage() throws InterruptedException
getReceivedMessage()
but waits until a message is received or until a timeout is
reached.InterruptedException
public com.icegreen.greenmail.store.MailFolder getUserInbox(String userEmail) throws com.icegreen.greenmail.store.FolderException
inbox
for the user with email userEmail.
NOTE: if the user does not exist, one will be created.userEmail
- the email address of the usercom.icegreen.greenmail.store.FolderException
- if the user doesn't have an inbox on this serverpublic void removeAllReceivedMessages() throws com.icegreen.greenmail.store.FolderException
com.icegreen.greenmail.store.FolderException
public boolean waitForIncomingMessage(int numberOfMessages) throws InterruptedException
InterruptedException
public boolean waitForIncomingMessage(long timeout, int numberOfMessages) throws InterruptedException
InterruptedException
Copyright © 2002-2019 Atlassian. All Rights Reserved.