Package org.subethamail.wiser

Examples of org.subethamail.wiser.WiserMessage


        if(!wiserMessages.isEmpty())
          fail("incorrect send method");
      }
      else
      {
        WiserMessage wiserMessage = wiserMessages.get(0);
        String from = wiserMessage.getEnvelopeSender();
          assertEquals("not correct from", "from@domain",from);
          String to = wiserMessage.getEnvelopeReceiver();
          assertEquals("not correct to", "address1",to);
          String contentType = wiserMessage.getMimeMessage().getContentType();
          assertTrue("not correct content type", contentType.startsWith("text/html"));
         
          wiserMessage = wiserMessages.get(1);
        from = wiserMessage.getEnvelopeSender();
          assertEquals("not correct from", "from@domain",from);
          to = wiserMessage.getEnvelopeReceiver();
          assertEquals("not correct to", "address2",to);
          contentType = wiserMessage.getMimeMessage().getContentType();
          assertTrue("not correct content type", contentType.startsWith("text/html"));
      }
    } catch(QwertoMailerException qme)
    {
      if(emailsTo == null || emailsTo.isEmpty())
        ;//pass
      else
      {
        qme.printStackTrace();
        fail(qme.getMessage());
      }
    } catch (Exception e)
    {
      e.printStackTrace();
      fail(e.getMessage())
    }
    //--------------------
    try
    {
      emlFile = new File("test_files/test_multipart_alt.eml");
      MessageContent message = new MessageContent(emlFile);
      message.setAddressFrom("from", "from@domain", "utf-8");
      sender.send(message, emailsTo);

      //check results
      List<WiserMessage> wiserMessages = wiser.getMessages();
      if(emailsTo.equals(invalidTo))
      {
        if(!wiserMessages.isEmpty())
          fail("incorrect send method");
      }
      else
      {
        WiserMessage wiserMessage = wiserMessages.get(2);
        String from = wiserMessage.getEnvelopeSender();
          assertEquals("not correct from", "from@domain",from);
          String to = wiserMessage.getEnvelopeReceiver();
          assertEquals("not correct to", "address1",to);
          String contentType = wiserMessage.getMimeMessage().getContentType();
          assertTrue("not correct content type", contentType.startsWith("multipart/alternative"));
         
          wiserMessage = wiserMessages.get(3);
        from = wiserMessage.getEnvelopeSender();
          assertEquals("not correct from", "from@domain",from);
          to = wiserMessage.getEnvelopeReceiver();
          assertEquals("not correct to", "address2",to);
          contentType = wiserMessage.getMimeMessage().getContentType();
          assertTrue("not correct content type", contentType.startsWith("multipart/alternative"));
      }
    } catch(QwertoMailerException qme)
    {
      if(emailsTo == null || emailsTo.isEmpty())
        ;//pass
      else
      {
        qme.printStackTrace();
        fail(qme.getMessage());
      }
    } catch (Exception e)
    {
      e.printStackTrace();
      fail(e.getMessage())
    }
    //--------------------
    try
    {
      emlFile = new File("test_files/test_multipart_mixed.eml");
      MessageContent message = new MessageContent(emlFile);
      message.setAddressFrom("from", "from@domain", "utf-8");
      sender.send(message, emailsTo);

      //check results
      List<WiserMessage> wiserMessages = wiser.getMessages();
      if(emailsTo.equals(invalidTo))
      {
        if(!wiserMessages.isEmpty())
          fail("incorrect send method");
      }
      else
      {
        WiserMessage wiserMessage = wiserMessages.get(4);
        String from = wiserMessage.getEnvelopeSender();
          assertEquals("not correct from", "from@domain",from);
          String to = wiserMessage.getEnvelopeReceiver();
          assertEquals("not correct to", "address1",to);
          String contentType = wiserMessage.getMimeMessage().getContentType();
          assertTrue("not correct content type", contentType.startsWith("multipart/mixed"));
         
          wiserMessage = wiserMessages.get(5);
        from = wiserMessage.getEnvelopeSender();
          assertEquals("not correct from", "from@domain",from);
          to = wiserMessage.getEnvelopeReceiver();
          assertEquals("not correct to", "address2",to);
          contentType = wiserMessage.getMimeMessage().getContentType();
          assertTrue("not correct content type", contentType.startsWith("multipart/mixed"));
      }
    } catch(QwertoMailerException qme)
    {
      if(emailsTo == null || emailsTo.isEmpty())
View Full Code Here


    public String getMessageAsString(int intMsgNo)
    {
        List<?> receivedMessages = fakeMailServer.getMessages();
        assertTrue("mail server didn't get enough messages", receivedMessages.size() >= intMsgNo);

        WiserMessage emailMessage = (WiserMessage) receivedMessages.get(intMsgNo);

        if (emailMessage != null)
        {
            try
            {
View Full Code Here

        boolean boolSaveToFile)
        throws IOException
    {
        assertTrue("mail server doesn't contain expected message",
                mailServer.getMessages().size() == 1);
        WiserMessage emailMessage = mailServer.getMessages().get(0);

        if (boolSaveToFile)
        {
            try
            {
                this.saveEmailToFile(emailMessage);
            }
            catch(MessagingException me)
            {
                IllegalStateException ise =
                    new IllegalStateException("caught MessagingException during saving the email");
                ise.initCause(me);
                throw ise;
            }
        }

        try
        {
            // get the MimeMessage
            MimeMessage mimeMessage = emailMessage.getMimeMessage();

            // test subject
            assertEquals("got wrong subject from mail",
                    strSubject, mimeMessage.getHeader("Subject", null));
View Full Code Here

        List<InternetAddress> bccAdd,
        boolean boolSaveToFile)
        throws IOException
    {
        // test other properties
        WiserMessage emailMessage = this.validateSend(
            mailServer,
            strSubject,
            fromAdd,
            toAdd,
            ccAdd,
View Full Code Here

        List<InternetAddress> bccAdd,
        boolean boolSaveToFile)
        throws IOException
    {
        // test other properties
        WiserMessage emailMessage = this.validateSend(
            mailServer,
            strSubject,
            fromAdd,
            toAdd,
            ccAdd,
View Full Code Here

        emailService.sendDomainUserAccessRequestEmail(domainUserRequest.getId());

        assertEquals(1, wiser.getMessages().size());

        if (wiser.getMessages().size() > 0) {
            WiserMessage wMsg = wiser.getMessages().get(0);
            MimeMessage msg = wMsg.getMimeMessage();

            assertNotNull(msg);
            assertEquals("Knappsack: Domain Access Request", msg.getSubject());
            assertEquals("notifications@knappsack.com", msg.getFrom()[0].toString());
            assertEquals(user.getEmail(),
View Full Code Here

        emailService.sendActivationEmail(user.getId());

        assertEquals(1, wiser.getMessages().size());

        if (wiser.getMessages().size() > 0) {
            WiserMessage wMsg = wiser.getMessages().get(0);
            MimeMessage msg = wMsg.getMimeMessage();

            assertNotNull(msg);
            assertEquals("Knappsack: Account Activation", msg.getSubject());
            assertEquals("notifications@knappsack.com", msg.getFrom()[0].toString());
            assertEquals(user.getEmail(),
View Full Code Here

        emailService.sendInvitationsEmail(user.getId(), invitationIds);

        assertEquals(1, wiser.getMessages().size());

        if (wiser.getMessages().size() > 0) {
            WiserMessage wMsg = wiser.getMessages().get(0);
            MimeMessage msg = wMsg.getMimeMessage();

            assertNotNull(msg);
            assertEquals(String.format("%s: Invitation to Knappsack", organization.getName()), msg.getSubject());
            assertEquals("notifications@knappsack.com", msg.getFrom()[0].toString());
            assertEquals(user.getEmail(),
View Full Code Here

        User user = getUserWithSecurityContext();
        emailService.sendPasswordResetEmail(user.getId(), "password");
        assertEquals(1, wiser.getMessages().size());

        if (wiser.getMessages().size() > 0) {
            WiserMessage wMsg = wiser.getMessages().get(0);
            MimeMessage msg = wMsg.getMimeMessage();

            assertNotNull(msg);
            assertEquals("Knappsack: Password Changed", msg.getSubject());
            assertEquals("notifications@knappsack.com", msg.getFrom()[0].toString());
            assertEquals(user.getEmail(),
View Full Code Here

        emailService.sendDomainUserAccessConfirmationEmail(model);

        assertEquals(1, wiser.getMessages().size());

        if (wiser.getMessages().size() > 0) {
            WiserMessage wMsg = wiser.getMessages().get(0);
            MimeMessage msg = wMsg.getMimeMessage();

            assertNotNull(msg);
            assertEquals("Knappsack: Domain Access Request Accepted", msg.getSubject());
            assertEquals("notifications@knappsack.com", msg.getFrom()[0].toString());
            assertEquals(user.getEmail(),
View Full Code Here

TOP

Related Classes of org.subethamail.wiser.WiserMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.