Package com.dumbster.smtp

Examples of com.dumbster.smtp.SmtpMessage


        });
    }

    private SmtpMessage getEmail() {
        Iterator inbox = emailServer.getReceivedEmail();
        SmtpMessage email = (SmtpMessage) inbox.next();
        // clear mock-inbox for other tests
        inbox.remove();
        return email;
    }
View Full Code Here


    private SmtpMessage getMockEmail(String message){
        return getMockEmail(message, "");
    }

    private SmtpMessage getMockEmail(String message, String encoding){
        SmtpMessage email = mock(SmtpMessage.class);
        when(email.getBody()).thenReturn(message);
        when(email.getHeaderValue(EmailHeader.CONTENT_TRANSFER_ENCODING.getValue())).thenReturn(encoding);

        return email;
    }
View Full Code Here

        // Wait till email is received by mock smtp
        DELIVER_CHECK: for (int i = 0; i < REDELIVERY_LIMIT; i++) {
            Thread.sleep(7000);
            if (AbstractEmailServerRunner.emailServer.getReceivedEmailSize() > 0) {
                Iterator inbox = AbstractEmailServerRunner.emailServer.getReceivedEmail();
                SmtpMessage email;
                while(inbox.hasNext()) {
                    email = (SmtpMessage) inbox.next();
                    if(predicate.apply(email)){
                        break DELIVER_CHECK;
                    }
View Full Code Here

     * @return EmailMessage object representing mock email or null if no email found
     */
    public static EmailMessage getFirstEmailFromInbox() {
        Iterator inbox = AbstractEmailServerRunner.emailServer.getReceivedEmail();
        if (inbox.hasNext()) {
            SmtpMessage email = (SmtpMessage) inbox.next();
            inbox.remove();
            return new EmailMessage(email);
        } else {
            return null;
        }
View Full Code Here

     * @return EmailMessage object representing mock email
     */
    private static EmailMessage getLatestEmailByData(Predicate<SmtpMessage> predicate) {
        List<SmtpMessage> foundEmails = new ArrayList<SmtpMessage>();
        Iterator inbox = AbstractEmailServerRunner.emailServer.getReceivedEmail();
        SmtpMessage email;
        while (inbox.hasNext()) {
            email = (SmtpMessage) inbox.next();
            if(predicate.apply(email)){
                foundEmails.add(email);
                inbox.remove();
View Full Code Here

    processor.process(message);

    Assert.assertTrue(server.getReceivedEmailSize() == 1);

    SmtpMessage email = (SmtpMessage) server.getReceivedEmail().next();
    Assert.assertTrue(email.getHeaderValue("Subject").equals("Mokai Message"));
    Assert.assertTrue(email.getHeaderValue("From").equals("mokai@localhost.com"));
    Assert.assertTrue(email.getBody().equals("This is a test"));

    server.stop();
  }
View Full Code Here

    processor.process(message);

    Assert.assertTrue(server.getReceivedEmailSize() == 1);

    SmtpMessage email = (SmtpMessage) server.getReceivedEmail().next();
    Assert.assertTrue(email.getHeaderValue("Subject").equals("This is the subject"));
    Assert.assertTrue(email.getHeaderValue("From").equals("test@localhost"));
    Assert.assertTrue(email.getBody().equals("This is a test"));

    server.stop();
  }
View Full Code Here

     */
    public String getMessageAsString(int intMsgNo)
    {
        assertTrue(this.fakeMailServer.getReceivedEmailSize() >= intMsgNo);
        Iterator emailIter = fakeMailServer.getReceivedEmail();
        SmtpMessage emailMessage = null;
        for (int intCurMsg = 0; intCurMsg < intMsgNo; intCurMsg++)
        {
            emailMessage = (SmtpMessage) emailIter.next();
        }

        if (emailMessage != null)
        {
            return emailMessage.toString();
        }
        fail("Message note found");
        return "";
    }
View Full Code Here

        boolean boolSaveToFile)
        throws IOException
    {
        assertTrue(mailServer.getReceivedEmailSize() == 1);
        Iterator emailIter = fakeMailServer.getReceivedEmail();
        SmtpMessage emailMessage = (SmtpMessage) emailIter.next();

        if (boolSaveToFile)
        {
            this.saveEmailToFile(emailMessage);
        }

        // test subject
        assertEquals(strSubject, emailMessage.getHeaderValue("Subject"));

        //test from address
        assertEquals(fromAdd.toString(), emailMessage.getHeaderValue("From"));

        //test to address
        assertTrue(
            toAdd.toString().indexOf(emailMessage.getHeaderValue("To")) != -1);

        //test cc address
        if (ccAdd.size() > 0)
        {
            assertTrue(
                ccAdd.toString().indexOf(emailMessage.getHeaderValue("Cc"))
                    != -1);
        }

        //test bcc address
        if (bccAdd.size() > 0)
        {
            assertTrue(
                bccAdd.toString().indexOf(emailMessage.getHeaderValue("Bcc"))
                    != -1);
        }

        return emailMessage;
    }
View Full Code Here

        List bccAdd,
        boolean boolSaveToFile)
        throws IOException
    {
        // test other properties
        SmtpMessage emailMessage = this.validateSend(
            mailServer,
            strSubject,
            fromAdd,
            toAdd,
            ccAdd,
            bccAdd,
            boolSaveToFile);

        // test message content

        // get sent email content
        String strSentContent =
            content.getContentType();
        // get received email content (chop off the auto-added \n
        // and -- (front and end)
        String strMessageBody =
            emailMessage.getBody().substring(
                BaseEmailTestCase.BODY_START_PAD,
                emailMessage.getBody().length()
                    - BaseEmailTestCase.BODY_END_PAD);
        assertTrue(strMessageBody.indexOf(strSentContent) != -1);
    }
View Full Code Here

TOP

Related Classes of com.dumbster.smtp.SmtpMessage

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.