public class EmailBaseFuncTestCase extends BaseJiraFuncTest implements FunctTestConstants
Modifier and Type | Class and Description |
---|---|
protected static class |
EmailBaseFuncTestCase.MailBox |
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_FROM_ADDRESS |
static String |
DEFAULT_SUBJECT_PREFIX |
static String |
HTML_FORMAT_REGEX |
protected MailService |
mailService |
static String |
newline |
assertions, backdoor, environmentData, initClass, navigation, tester, testRule
ADMIN_EMAIL, ADMIN_FULLNAME, ADMIN_PASSWORD, ADMIN_USERNAME, ADMINISTER, AFFECTS_VERSIONS_FIELD_ID, ANYONE, ASSIGN_FIELD_SCREEN, ASSIGN_FIELD_SCREEN_NAME, ASSIGN_ISSUE, ASSIGNABLE_USER, ASSIGNEE_FIELD_ID, ATTACHMENT_FIELD_ID, BIGPIPE_KILLSWITCH_FLAG, BOB_EMAIL, BOB_FULLNAME, BOB_PASSWORD, BOB_USERNAME, BRAZIL_LOCALE_ID, BROWSE, BUILT_IN_CUSTOM_FIELD_KEY, BULK_CHANGE, BUTTON_CANCEL, BUTTON_CONFIRM, BUTTON_NAME_NEXT, BUTTON_NEXT, CHANGE_HISTORY, CHINA_LOCALE_ID, CLONERS_INWARD_LINK_NAME, CLONERS_LINK_TYPE_NAME, CLONERS_OUTWARD_LINK_NAME, CLOSE_ISSUE, COMMENT_DELETE_ALL, COMMENT_DELETE_OWN, COMMENT_EDIT_ALL, COMMENT_EDIT_OWN, COMMENT_ISSUE, COMPONENT_NAME_FOUR, COMPONENT_NAME_ONE, COMPONENT_NAME_THREE, COMPONENT_NAME_TWO, COMPONENTS_FIELD_ID, CREATE_ATTACHMENT, CREATE_ISSUE, CREATE_ISSUE_OPERATION_SCREEN, CREATE_SHARED_OBJECTS, CURRENT_USER, CUSTOM_FIELD_CASCADING_SELECT_SEARCHER, CUSTOM_FIELD_CHECKBOX_SEARCHER, CUSTOM_FIELD_CONFIGURATION, CUSTOM_FIELD_DATE_RANGE, CUSTOM_FIELD_EXACT_NUMBER, CUSTOM_FIELD_EXACT_TEXT_SEARCHER, CUSTOM_FIELD_GROUP_PICKER_SEARCHER, CUSTOM_FIELD_LABEL_SEARCHER, CUSTOM_FIELD_MULTI_SELECT_SEARCHER, CUSTOM_FIELD_NUMBER_RANGE, CUSTOM_FIELD_PREFIX, CUSTOM_FIELD_PROJECT_SEARCHER, CUSTOM_FIELD_RADIO_SEARCHER, CUSTOM_FIELD_SELECT_SEARCHER, CUSTOM_FIELD_TEXT_SEARCHER, CUSTOM_FIELD_TYPE_CASCADINGSELECT, CUSTOM_FIELD_TYPE_CHECKBOX, CUSTOM_FIELD_TYPE_DATEPICKER, CUSTOM_FIELD_TYPE_DATETIME, CUSTOM_FIELD_TYPE_FLOAT, CUSTOM_FIELD_TYPE_FREETEXT, CUSTOM_FIELD_TYPE_GROUPPICKER, CUSTOM_FIELD_TYPE_LABELS, CUSTOM_FIELD_TYPE_MULTICHECKBOXES, CUSTOM_FIELD_TYPE_MULTIGROUPPICKER, CUSTOM_FIELD_TYPE_MULTISELECT, CUSTOM_FIELD_TYPE_MULTIUSERPICKER, CUSTOM_FIELD_TYPE_PROJECT, CUSTOM_FIELD_TYPE_RADIO, CUSTOM_FIELD_TYPE_READONLYTEXT, CUSTOM_FIELD_TYPE_SELECT, CUSTOM_FIELD_TYPE_TEXTFIELD, CUSTOM_FIELD_TYPE_URL, CUSTOM_FIELD_TYPE_USERPICKER, CUSTOM_FIELD_TYPE_VERSION, CUSTOM_FIELD_USER_PICKER_GROUP_SEARCHER, CUSTOM_FIELD_USER_PICKER_SEARCHER, CUSTOM_FIELD_VERSION_SEARCHER, CUSTOM_SUB_TASK_SUMMARY, CUSTOM_SUB_TASK_TYPE_DESCRIPTION, CUSTOM_SUB_TASK_TYPE_NAME, CZECH_LOCALE_ID, DARK_FEATURE_DISABLE_LANDING_PAGE_REDIRECT_FLAG, DEFAULT_ASSIGNEE_ERROR_MESSAGE, DEFAULT_FIELD_CONFIGURATION, DEFAULT_FIELD_SCREEN_NAME, DEFAULT_ISSUE_TYPE_SCREEN_SCHEME, DEFAULT_OPERATION_SCREEN, DEFAULT_PERM_SCHEME, DEFAULT_PERM_SCHEME_ID, DEFAULT_SCREEN_SCHEME, DEFAULT_TEXT_RENDERER, DELETE_ISSUE, DENMARK_LOCALE_ID, DUE_DATE_FIELD_ID, EDIT_ISSUE, EDIT_ISSUE_OPERATION_SCREEN, EVENT_TYPE_ACTIVE_STATUS, EVENT_TYPE_INACTIVE_STATUS, FIELD_ASSIGNEE, FIELD_COMMENT, FIELD_COMPONENTS, FIELD_FIX_VERSIONS, FIELD_OPERATION, FIELD_PRIORITY, FIELD_SCHEME_DESC, FIELD_SCHEME_NAME, FIELD_TABLE_ID, FIELD_VERSIONS, FIELD_WORKFLOW, FIX_VERSIONS_FIELD_ID, FORMAT_DAYS, FORMAT_HOURS, FORMAT_PRETTY, FRANCE_LOCALE_ID, FRED_EMAIL, FRED_FULLNAME, FRED_PASSWORD, FRED_USERNAME, FRENCH_LOCALISED, FS, FUNC_TEST_PLUGIN_REST_PATH, GERMAN_LOCALISED, GERMANY_LOCALE_ID, GLOBAL_ADMIN, GROUP_LABEL_ADMIN, GROUP_LABEL_FUNC_TEST, GROUP_LABEL_JIRA_CORE, GROUP_LABEL_MULTI, HTM, HUNGARY_LOCALE_ID, ISSUE_ALL, ISSUE_BUG, ISSUE_IMAGE_BUG, ISSUE_IMAGE_GENERIC, ISSUE_IMAGE_IMPROVEMENT, ISSUE_IMAGE_NEWFEATURE, ISSUE_IMAGE_SUB_TASK, ISSUE_IMAGE_TASK, ISSUE_IMPROVEMENT, ISSUE_NEWFEATURE, ISSUE_TAB_ALL, ISSUE_TAB_CHANGE_HISTORY, ISSUE_TAB_COMMENTS, ISSUE_TAB_WORK_LOG, ISSUE_TASK, ISSUE_TYPE_ALL, ISSUE_TYPE_ALL_SUB_TASK, ISSUE_TYPE_ANY, ISSUE_TYPE_BUG, ISSUE_TYPE_IMPROVEMENT, ISSUE_TYPE_NEWFEATURE, ISSUE_TYPE_SUB_TASK, ISSUE_TYPE_TASK, ISSUETABLE_EDIT_ROW, ISSUETABLE_HEADER_ROW, ISSUETABLE_ID, ITALY_LOCALE_ID, JAPAN_LOCALE_ID, JIRA_ADMIN_GROUP, JIRA_ADMIN_ROLE, JIRA_ADMIN_ROLE_ID, JIRA_DEV_GROUP, JIRA_DEV_ROLE, JIRA_DEV_ROLE_ID, JIRA_FORM_NAME, JIRA_USERS_GROUP, JIRA_USERS_ROLE, JIRA_USERS_ROLE_ID, KOREA_LOCALE_ID, LABEL_ISSUE_NAVIGATOR, LINK_ASSIGN_ISSUE, LINK_BULK_CHANGE_ALL, LINK_BULK_CHANGE_CURR_PG, LINK_CLONE_ISSUE, LINK_DELETE_ISSUE, LINK_EDIT_ISSUE, LINK_ISSUE, LINK_NEXT_PG, MANAGE_GROUP_FILTER_SUBSCRIPTIONS, MANAGE_WATCHER_LIST, minorPriority, MODIFY_REPORTER, MOON_LOCALE, MOVE_DOWN, MOVE_ISSUE, MOVE_TO_FIRST, MOVE_TO_LAST, MOVE_UP, NETHERLANDS_LOCALE_ID, NORWAY_LOCALE_ID, PERM_SCHEME_DESC, PERM_SCHEME_ID, PERM_SCHEME_NAME, POLAND_LOCALE_ID, PRIORITY_BLOCKER, PRIORITY_CRITICAL, PRIORITY_FIELD_ID, PRIORITY_IMAGE_BLOCKER, PRIORITY_IMAGE_CRITICAL, PRIORITY_IMAGE_MAJOR, PRIORITY_IMAGE_MINOR, PRIORITY_IMAGE_TRIVIAL, PRIORITY_MAJOR, PRIORITY_MINOR, PRIORITY_TRIVIAL, PROJECT_ADMIN, PROJECT_HOMOSAP, PROJECT_HOMOSAP_KEY, PROJECT_MONKEY, PROJECT_MONKEY_KEY, PROJECT_NEO, PROJECT_NEO_KEY, PROJECT_TAB_CHANGE_LOG, PROJECT_TAB_COMPONENTS, PROJECT_TAB_OPEN_ISSUES, PROJECT_TAB_ROAD_MAP, PROJECT_TAB_VERSIONS, RADIO_OPERATION_DELETE, RADIO_OPERATION_EDIT, RADIO_OPERATION_MOVE, RADIO_OPERATION_WORKFLOW, REPORTER_FIELD_ID, RESOLUTION_FIELD_ID, RESOLVE_FIELD_SCREEN_NAME, RESOLVE_ISSUE, RUSSIA_LOCALE_ID, SCHEDULE_ISSUE, SCREEN_TABLE_NAME_COLUMN_INDEX, SECURITY_LEVEL_FIELD_ID, SECURITY_LEVEL_ONE_DESC, SECURITY_LEVEL_ONE_NAME, SECURITY_LEVEL_THREE_DESC, SECURITY_LEVEL_THREE_NAME, SECURITY_LEVEL_TWO_DESC, SECURITY_LEVEL_TWO_NAME, SECURITY_SCHEME_DESC, SECURITY_SCHEME_NAME, SET_ISSUE_SECURITY, SLOVAKIA_LOCALE_ID, SPAIN_LOCALE_ID, STATUS_IN_PROGRESS, STATUS_NAME, STATUS_OPEN, STATUS_RESOLVED, STEP_CHOOSE_ISSUES, STEP_CHOOSE_OPERATION, STEP_CONFIRMATION, STEP_NAME, STEP_OPERATION_DETAILS, STEP_PREFIX, SUB_TASK_DEFAULT_TYPE, SUB_TASK_SUMMARY, Summary, SWEDEN_LOCALE_ID, SYS_ADMIN_PASSWORD, SYS_ADMIN_USERNAME, SYSTEM_ADMINISTER, TEST_FIELD_SCREEN, TRANSIION_NAME_APPROVE, TRANSIION_NAME_CLOSE, TRANSIION_NAME_REOPEN, TRANSIION_NAME_RESOLVE, TRANSIION_NAME_START_PROGRESS, TRANSIION_NAME_STOP_PROGRESS, UK_LOCALE_ID, UNKNOWN, UNKNOWN_ID, US_LOCALE_ID, USE, USER_PICKER, VERSION_NAME_FIVE, VERSION_NAME_FOUR, VERSION_NAME_ONE, VERSION_NAME_THREE, VERSION_NAME_TWO, VERSIONS_FIELD_ID, VIEW_ISSUE_OPERATION_SCREEN, VIEW_VERSION_CONTROL, VIEW_VOTERS_AND_WATCHERS, WIKI_STYLE_RENDERER, WORK_ISSUE, WORKFLOW_ADDED, WORKFLOW_COPIED, WORKFLOW_SCHEME
Constructor and Description |
---|
EmailBaseFuncTestCase() |
Modifier and Type | Method and Description |
---|---|
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 |
assertEmailReceivedWithBodyContainingLine(int expectedMatchingEmailsCount,
Collection<javax.mail.internet.MimeMessage> emails,
String... linePattern) |
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 |
assertMessageAndType(javax.mail.internet.MimeMessage message,
String expectedComment,
boolean html) |
protected void |
assertNotMessageAndType(javax.mail.internet.MimeMessage message,
String expectedComment,
boolean html) |
protected void |
assertRecipientsHaveMessages(Collection<String> recipients) |
protected void |
assertSendingMailIsEnabled() |
protected void |
configureAndStartMailServers(String from,
String prefix,
JIRAServerSetup... jiraServerSetups) |
protected void |
configureAndStartSmtpServer()
Use this method to start a
SmtpServer . |
protected void |
configureAndStartSmtpServer(String from,
String prefix) |
protected void |
configureAndStartSmtpServerWithNotify() |
void |
createMailService() |
protected void |
flushMailQueue() |
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 void |
flushMailQueueAndWaitForRecipients(int waitPeriodMillis,
String... recipientAddresses)
Flushes the mail queue and waits for emails to arrive for specified recipients instead of a set number of emails.
|
protected EmailBaseFuncTestCase.MailBox |
getMailBox(String email) |
protected List<javax.mail.internet.MimeMessage> |
getMessagesForRecipient(String recipient) |
static org.hamcrest.TypeSafeMatcher<javax.mail.internet.MimeMessage> |
hasBody(org.hamcrest.Matcher<String> bodyMatcher) |
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 |
startMailService(JIRAServerSetup... jiraServerSetups) |
void |
stopMailService() |
protected void |
waitForMail(int emailCount) |
getAssertions, getBackdoor, getEnvironmentData, getTester
public static final String DEFAULT_FROM_ADDRESS
public static final String DEFAULT_SUBJECT_PREFIX
public static final String newline
public static final String HTML_FORMAT_REGEX
protected MailService mailService
public void createMailService()
public void stopMailService()
protected void configureAndStartSmtpServer()
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 configureAndStartMailServers(String from, String prefix, JIRAServerSetup... jiraServerSetups)
protected void configureAndStartSmtpServerWithNotify()
protected void startMailService(JIRAServerSetup... jiraServerSetups)
protected Collection<String> parseEmailAddresses(String emails)
emails
- comma seperated list of email addressesprotected 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 assertSendingMailIsEnabled()
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 receiveInterruptedException
- 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 amount of time to wait in millis until the e-mails should have arrived.InterruptedException
- if interruptedprotected void flushMailQueueAndWaitForRecipients(int waitPeriodMillis, String... recipientAddresses) throws InterruptedException, javax.mail.MessagingException
waitPeriodMillis
- The amount of time to wait in millis until the e-mails should have arrived.recipientAddresses
- the addresses to wait for or failInterruptedException
- if interruptedjavax.mail.MessagingException
- if there is a problem extracting the sent messagesprotected void flushMailQueue()
protected 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 bodyjavax.mail.MessagingException
- Message errorIOException
- IO errorGreenMailUtil.getBody(javax.mail.Part)
protected void assertEmailBodyContainsLine(javax.mail.internet.MimeMessage email, String... linePattern)
email
- email to extract the content body fromlinePattern
- expected line or line patternjavax.mail.MessagingException
- Message errorIOException
- IO errorGreenMailUtil.getBody(javax.mail.Part)
protected void assertEmailReceivedWithBodyContainingLine(int expectedMatchingEmailsCount, Collection<javax.mail.internet.MimeMessage> emails, String... linePattern)
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 bodyjavax.mail.MessagingException
- Message errorIOException
- IO errorGreenMailUtil.getBody(javax.mail.Part)
protected void assertEmailBodyContains(String emailBody, String bodySubString) throws javax.mail.MessagingException, IOException
emailBody
- bodybodySubString
- expected substringjavax.mail.MessagingException
- message errorIOException
- 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 addressesjavax.mail.MessagingException
- message 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 addressesjavax.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
protected final EmailBaseFuncTestCase.MailBox getMailBox(String email) throws com.icegreen.greenmail.store.FolderException
com.icegreen.greenmail.store.FolderException
protected final void assertMessageAndType(javax.mail.internet.MimeMessage message, String expectedComment, boolean html)
protected final void assertNotMessageAndType(javax.mail.internet.MimeMessage message, String expectedComment, boolean html)
public static org.hamcrest.TypeSafeMatcher<javax.mail.internet.MimeMessage> hasBody(org.hamcrest.Matcher<String> bodyMatcher)
Copyright © 2002-2021 Atlassian. All Rights Reserved.