Package org.apache.commons.mail.mocks

Examples of org.apache.commons.mail.mocks.MockMultiPartEmailConcrete


    /** */
    protected void setUp()
    {
        super.setUp();
        // reusable objects to be used across multiple tests
        this.email = new MockMultiPartEmailConcrete();
        try
        {
            testFile = File.createTempFile("testfile", ".txt");
        }
        catch (IOException ioe)
View Full Code Here


            attachment.setPath(testFile.getAbsolutePath());
            attachment.setDisposition(EmailAttachment.ATTACHMENT);
            attachment.setName("Test_Attachment");
            attachment.setDescription("Test Attachment Desc");

            MockMultiPartEmailConcrete testEmail =
                new MockMultiPartEmailConcrete();
            testEmail.setHostName(this.strTestMailServer);
            testEmail.setSmtpPort(this.getMailServerPort());
            testEmail.setFrom(this.strTestMailFrom);
            testEmail.addTo(this.strTestMailTo);
            testEmail.attach(attachment);
            testEmail.setSubType("subType");

            if (EmailUtils.isNotEmpty(this.strTestUser)
                && EmailUtils.isNotEmpty(this.strTestPasswd))
            {
                testEmail.setAuthentication(
                    this.strTestUser,
                    this.strTestPasswd);
            }

            testEmail.setSubject(strSubject);

            testEmail.setMsg("Test Message");

            Hashtable ht = new Hashtable();
            ht.put("X-Priority", "2");
            ht.put("Disposition-Notification-To", this.strTestMailFrom);
            ht.put("X-Mailer", "Sendmail");

            testEmail.setHeaders(ht);

            testEmail.send();

            this.fakeMailServer.stop();
            // validate message
            validateSend(
                this.fakeMailServer,
                strSubject,
                testEmail.getMsg(),
                testEmail.getFromAddress(),
                testEmail.getToList(),
                testEmail.getCcList(),
                testEmail.getBccList(),
                true);

            // validate attachment
            validateSend(
                this.fakeMailServer,
                strSubject,
                attachment.getName(),
                testEmail.getFromAddress(),
                testEmail.getToList(),
                testEmail.getCcList(),
                testEmail.getBccList(),
                false);
        }

        catch (IOException e)
        {
View Full Code Here

     */
    public void testAddPart() throws Exception
    {

        // setup
        this.email = new MockMultiPartEmailConcrete();
        String strMessage = "hello";
        String strContentType = "text/plain";

        // add part
        this.email.addPart(strMessage, strContentType);
View Full Code Here

     */
    public void testAddPart2() throws Exception
    {

        // setup
        this.email = new MockMultiPartEmailConcrete();
        String strSubtype = "subtype/abc123";

        // add part
        this.email.addPart(new MimeMultipart(strSubtype));

View Full Code Here

TOP

Related Classes of org.apache.commons.mail.mocks.MockMultiPartEmailConcrete

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.