|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object junit.framework.Assert junit.framework.TestCase com.atlassian.jira.functest.framework.FuncTestCase com.atlassian.jira.webtests.EmailFuncTestCase
public class EmailFuncTestCase
This class extends FuncTestCase by adding methods to test emails being sent from JIRA.
Field Summary | |
---|---|
static String |
DEAFULT_FROM_ADDRESS
|
static String |
DEFAULT_SUBJECT_PREFIX
|
protected com.atlassian.jira.webtests.util.mail.MailService |
mailService
|
static String |
newline
|
Fields inherited from class com.atlassian.jira.functest.framework.FuncTestCase |
---|
administration, assertions, backdoor, environmentData, form, funcTestHelperFactory, locator, log, navigation, oldway_consider_porting, page, parse, tester, text |
Constructor Summary | |
---|---|
EmailFuncTestCase()
|
Method Summary | |
---|---|
protected void |
assertCorrectNumberEmailsSent(int numOfMessages)
|
protected void |
assertEmailBodyContains(javax.mail.internet.MimeMessage email,
String bodySubString)
Asserts that the given email's body contains the bodySubString using indexOf. |
protected void |
assertEmailBodyContains(String emailBody,
String bodySubString)
Assert that the String emailBody contains bodySubString |
protected void |
assertEmailBodyContainsLine(javax.mail.internet.MimeMessage email,
String linePattern)
Asserts that the given email's body contains a line which matches the given string or pattern. |
protected void |
assertEmailBodyDoesntContain(javax.mail.internet.MimeMessage email,
String bodySubString)
Asserts that the given email's body does not contain the bodySubString using indexOf. |
protected void |
assertEmailCcEquals(javax.mail.internet.MimeMessage email,
Collection expectedCcAddresses)
|
protected void |
assertEmailFromEquals(javax.mail.internet.MimeMessage email,
String expectedTo)
|
protected void |
assertEmailHasNumberOfParts(javax.mail.internet.MimeMessage email,
int expectedNumOfParts)
|
protected void |
assertEmailSent(String recipient,
String subject,
String issueComment)
|
protected void |
assertEmailSubjectEquals(javax.mail.internet.MimeMessage email,
String subject)
|
protected void |
assertEmailToEquals(javax.mail.internet.MimeMessage email,
Collection expectedToAddresses)
Assert that the email was addressed to each and everyone of the expectedAddresses |
protected void |
assertEmailToEquals(javax.mail.internet.MimeMessage email,
String expectedTo)
Assert that the email was addressed to the expectedTo |
protected void |
assertRecipientsHaveMessages(Collection<String> recipients)
|
protected void |
configureAndStartMailServers(String from,
String prefix,
JIRAServerSetup... jiraServerSetups)
|
protected void |
configureAndStartSmtpServer()
Use this method to start a com.icegreen.greenmail.smtp.SmtpServer . |
protected void |
configureAndStartSmtpServer(String from,
String prefix)
|
protected void |
flushMailQueueAndWait(int emailCount)
This is useful for writing func tests that test that the correct notifications are being sent. |
protected void |
flushMailQueueAndWait(int emailCount,
int waitPeriodMillis)
Does the same as flushMailQueueAndWait(int) but allows the user to specify the wait period in case a lot
of e-mails are being sent. |
protected List<javax.mail.internet.MimeMessage> |
getMessagesForRecipient(String recipient)
|
protected Collection<String> |
parseEmailAddresses(String emails)
Given a comma seperated list of email addresses, returns a collection of the email addresses. |
protected void |
setupImapService()
|
protected void |
setupImapService(String handlerParameters)
|
protected void |
setupPopService()
|
protected void |
setupPopService(String handlerParameters)
|
protected void |
setUpTest()
Setup for an actual test |
protected void |
startMailService(JIRAServerSetup... jiraServerSetups)
|
void |
tearDownTest()
individual test tear down |
protected void |
waitForMail(int emailCount)
|
Methods inherited from class com.atlassian.jira.functest.framework.FuncTestCase |
---|
builInCustomFieldKey, getAssertions, getEnvironmentData, getTester, getWebClientListener, isDumpHTML, log, log, runBare, runTest, setEnvironmentData, setUp, setUpHttpUnitOptions, shouldSkipSetup, tearDown, xpath |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, setName, toString |
Methods inherited from class junit.framework.Assert |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String DEAFULT_FROM_ADDRESS
public static final String DEFAULT_SUBJECT_PREFIX
public static final String newline
protected com.atlassian.jira.webtests.util.mail.MailService mailService
Constructor Detail |
---|
public EmailFuncTestCase()
Method Detail |
---|
protected void setUpTest()
FuncTestCase
setUpTest
in class FuncTestCase
public void tearDownTest()
FuncTestCase
tearDownTest
in class FuncTestCase
protected void configureAndStartSmtpServer()
com.icegreen.greenmail.smtp.SmtpServer
. This will also configure JIRA to use this SMTP server in the admin section. You should call this after your data import. This will override any existing mail servers setup already.
A simple SMTP server proxy is started by first attempting to start on a default port number. If this port is already used we try that port number plus one and so on for 10 attempts. this allows for multiple tests running in Bamboo concurrently, and also for a particular test machine maybe using that port already.
The tearDown() method will close the TCP socket.
protected void configureAndStartSmtpServer(String from, String prefix)
protected void configureAndStartMailServers(String from, String prefix, JIRAServerSetup... jiraServerSetups)
protected void startMailService(JIRAServerSetup... jiraServerSetups)
protected Collection<String> parseEmailAddresses(String emails)
emails
- comma seperated list of email addresses
protected void assertRecipientsHaveMessages(Collection<String> recipients) throws javax.mail.MessagingException
javax.mail.MessagingException
protected List<javax.mail.internet.MimeMessage> getMessagesForRecipient(String recipient) throws javax.mail.MessagingException
javax.mail.MessagingException
protected void setupPopService()
protected void setupPopService(String handlerParameters)
protected void setupImapService()
protected void setupImapService(String handlerParameters)
protected void flushMailQueueAndWait(int emailCount) throws InterruptedException
emailCount
- number of expected emails to wait to receive
InterruptedException
- if interruptedprotected void flushMailQueueAndWait(int emailCount, int waitPeriodMillis) throws InterruptedException
flushMailQueueAndWait(int)
but allows the user to specify the wait period in case a lot
of e-mails are being sent.
emailCount
- number of expected emails to wait to receivewaitPeriodMillis
- The amout of time to wait in millis until the e-mails should have arrived.
InterruptedException
- if interruptedprotected void waitForMail(int emailCount) throws InterruptedException
InterruptedException
protected void assertEmailBodyContains(javax.mail.internet.MimeMessage email, String bodySubString) throws javax.mail.MessagingException, IOException
email
- email to extract the content body frombodySubString
- expected substring of the email body
javax.mail.MessagingException
- Message error
IOException
- IO errorGreenMailUtil.getBody(javax.mail.Part)
protected void assertEmailBodyContainsLine(javax.mail.internet.MimeMessage email, String linePattern) throws javax.mail.MessagingException, IOException
email
- email to extract the content body fromlinePattern
- expected line or line pattern
javax.mail.MessagingException
- Message error
IOException
- IO errorGreenMailUtil.getBody(javax.mail.Part)
protected void assertEmailBodyDoesntContain(javax.mail.internet.MimeMessage email, String bodySubString) throws javax.mail.MessagingException, IOException
email
- email to extract the content body frombodySubString
- string to not occur in body
javax.mail.MessagingException
- Message error
IOException
- IO errorGreenMailUtil.getBody(javax.mail.Part)
protected void assertEmailBodyContains(String emailBody, String bodySubString) throws javax.mail.MessagingException, IOException
emailBody
- bodybodySubString
- expected substring
javax.mail.MessagingException
- message error
IOException
- IO errorprotected void assertEmailHasNumberOfParts(javax.mail.internet.MimeMessage email, int expectedNumOfParts) throws javax.mail.MessagingException, IOException
javax.mail.MessagingException
IOException
protected void assertEmailToEquals(javax.mail.internet.MimeMessage email, String expectedTo) throws javax.mail.MessagingException
email
- email to assert the value of the to headerexpectedTo
- the single or comma seperated list of expected email addresses
javax.mail.MessagingException
- meesage errorassertEmailToEquals(javax.mail.internet.MimeMessage, java.util.Collection)
protected void assertEmailToEquals(javax.mail.internet.MimeMessage email, Collection expectedToAddresses) throws javax.mail.MessagingException
email
- email to assert the value of the to headerexpectedToAddresses
- collection of expected email addresses
javax.mail.MessagingException
- meesage errorprotected void assertEmailCcEquals(javax.mail.internet.MimeMessage email, Collection expectedCcAddresses) throws javax.mail.MessagingException
javax.mail.MessagingException
protected void assertEmailFromEquals(javax.mail.internet.MimeMessage email, String expectedTo) throws javax.mail.MessagingException
javax.mail.MessagingException
protected void assertEmailSubjectEquals(javax.mail.internet.MimeMessage email, String subject) throws javax.mail.MessagingException
javax.mail.MessagingException
protected void assertEmailSent(String recipient, String subject, String issueComment) throws javax.mail.MessagingException, IOException
javax.mail.MessagingException
IOException
protected void assertCorrectNumberEmailsSent(int numOfMessages) throws javax.mail.MessagingException
javax.mail.MessagingException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |