Search in sources :

Example 11 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.

the class AsyncEmailTaskTest method testSimpleTextMailSendTask.

// copied from org.activiti.engine.test.bpmn.mail.EmailSendTaskTest
@Deployment
public void testSimpleTextMailSendTask() throws Exception {
    runtimeService.startProcessInstanceByKey("simpleTextOnly");
    List<WiserMessage> messages = wiser.getMessages();
    assertEquals(0, messages.size());
    waitForJobExecutorToProcessAllJobs(5000L, 25L);
    messages = wiser.getMessages();
    assertEquals(1, messages.size());
    WiserMessage message = messages.get(0);
    EmailServiceTaskTest.assertEmailSend(message, false, "Hello Kermit!", "This a text only e-mail.", "activiti@localhost", Arrays.asList("kermit@activiti.org"), null);
}
Also used : WiserMessage(org.subethamail.wiser.WiserMessage) Deployment(org.activiti.engine.test.Deployment)

Example 12 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project kernel by exoplatform.

the class TestMailService method isEmailMessageSent.

/**
 * Utility method to check if you really sent message
 * to dummy mail server. Basically it simply checks if
 * there is an email with defined 'subject' header.
 * @param subject
 * @return
 * @throws MessagingException
 */
private boolean isEmailMessageSent(String subject) throws MessagingException {
    if (mailServer.getMessages().size() > 0) {
        Iterator<WiserMessage> it = new ArrayList<WiserMessage>(mailServer.getMessages()).iterator();
        WiserMessage message;
        while (it.hasNext()) {
            message = it.next();
            if (message.getMimeMessage().getSubject() != null && message.getMimeMessage().getSubject().equals(subject)) {
                return true;
            }
        }
    }
    return false;
}
Also used : WiserMessage(org.subethamail.wiser.WiserMessage)

Example 13 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project sonarqube by SonarSource.

the class EmailNotificationChannelTest method shouldSendNonThreadedEmail.

@Test
public void shouldSendNonThreadedEmail() throws Exception {
    configure();
    EmailMessage emailMessage = new EmailMessage().setTo("user@nowhere").setSubject("Foo").setMessage("Bar");
    underTest.deliver(emailMessage);
    List<WiserMessage> messages = smtpServer.getMessages();
    assertThat(messages).hasSize(1);
    MimeMessage email = messages.get(0).getMimeMessage();
    assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8");
    assertThat(email.getHeader("In-Reply-To", null)).isNull();
    assertThat(email.getHeader("References", null)).isNull();
    assertThat(email.getHeader("List-ID", null)).isEqualTo("SonarQube <sonar.nemo.sonarsource.org>");
    assertThat(email.getHeader("List-Archive", null)).isEqualTo("http://nemo.sonarsource.org");
    assertThat(email.getHeader("From", null)).isEqualTo("SonarQube <server@nowhere>");
    assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>");
    assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Foo");
    assertThat((String) email.getContent()).startsWith("Bar");
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) MimeMessage(javax.mail.internet.MimeMessage) WiserMessage(org.subethamail.wiser.WiserMessage) Test(org.junit.Test)

Example 14 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project sonarqube by SonarSource.

the class EmailNotificationChannelTest method shouldSendThreadedEmail.

@Test
public void shouldSendThreadedEmail() throws Exception {
    configure();
    EmailMessage emailMessage = new EmailMessage().setMessageId("reviews/view/1").setFrom("Full Username").setTo("user@nowhere").setSubject("Review #3").setMessage("I'll take care of this violation.");
    underTest.deliver(emailMessage);
    List<WiserMessage> messages = smtpServer.getMessages();
    assertThat(messages).hasSize(1);
    MimeMessage email = messages.get(0).getMimeMessage();
    assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8");
    assertThat(email.getHeader("In-Reply-To", null)).isEqualTo("<reviews/view/1@nemo.sonarsource.org>");
    assertThat(email.getHeader("References", null)).isEqualTo("<reviews/view/1@nemo.sonarsource.org>");
    assertThat(email.getHeader("List-ID", null)).isEqualTo("SonarQube <sonar.nemo.sonarsource.org>");
    assertThat(email.getHeader("List-Archive", null)).isEqualTo("http://nemo.sonarsource.org");
    assertThat(email.getHeader("From", ",")).isEqualTo("\"Full Username (SonarQube)\" <server@nowhere>");
    assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>");
    assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Review #3");
    assertThat((String) email.getContent()).startsWith("I'll take care of this violation.");
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) MimeMessage(javax.mail.internet.MimeMessage) WiserMessage(org.subethamail.wiser.WiserMessage) Test(org.junit.Test)

Example 15 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project sonarqube by SonarSource.

the class EmailNotificationChannelTest method shouldSendTestEmail.

@Test
public void shouldSendTestEmail() throws Exception {
    configure();
    underTest.sendTestEmail("user@nowhere", "Test Message from SonarQube", "This is a test message from SonarQube.");
    List<WiserMessage> messages = smtpServer.getMessages();
    assertThat(messages).hasSize(1);
    MimeMessage email = messages.get(0).getMimeMessage();
    assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8");
    assertThat(email.getHeader("From", ",")).isEqualTo("SonarQube <server@nowhere>");
    assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>");
    assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Test Message from SonarQube");
    assertThat((String) email.getContent()).startsWith("This is a test message from SonarQube.");
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) WiserMessage(org.subethamail.wiser.WiserMessage) Test(org.junit.Test)

Aggregations

WiserMessage (org.subethamail.wiser.WiserMessage)34 Deployment (org.activiti.engine.test.Deployment)22 HashMap (java.util.HashMap)16 MimeMultipart (javax.mail.internet.MimeMultipart)12 MimeMessage (javax.mail.internet.MimeMessage)11 Test (org.junit.Test)8 File (java.io.File)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 EmailMessage (org.sonar.plugins.emailnotifications.api.EmailMessage)2 Issue (org.sonar.wsclient.issue.Issue)2 Issues (org.sonar.wsclient.issue.Issues)2 PostRequest (org.sonarqube.ws.client.PostRequest)2 SonarScanner (com.sonar.orchestrator.build.SonarScanner)1 BeforeClass (org.junit.BeforeClass)1 QualityGate (org.sonar.wsclient.qualitygate.QualityGate)1 WsClient (org.sonarqube.ws.client.WsClient)1 Wiser (org.subethamail.wiser.Wiser)1 ItUtils.newAdminWsClient (util.ItUtils.newAdminWsClient)1 ItUtils.newUserWsClient (util.ItUtils.newUserWsClient)1