Package com.alibaba.citrus.service.mail.builder.content

Examples of com.alibaba.citrus.service.mail.builder.content.AttachmentContent$AttachmentSource


public class AttachmentContentTests extends AbstractMailBuilderTests {
    private AttachmentContent content;

    @Before
    public void init() {
        content = new AttachmentContent();
    }
View Full Code Here


        htmlText.setId("htmlText");

        TextTemplateContent plainTextTemplate = new TextTemplateContent("mail/mytemplate.vm", "text/plain");
        plainTextTemplate.setId("plainTextTemplate");

        AttachmentContent textAttachment = new AttachmentContent("testfile.txt");
        textAttachment.setId("textAttachment");

        HTMLTemplateContent htmlTemplate = new HTMLTemplateContent("mail/complexhtml.vm");
        htmlTemplate.setId("htmlTemplate");

        plainTextTemplate.setTemplateService(templateService);
        plainTextTemplate.setPullService(pullService);

        htmlTemplate.setTemplateService(templateService);
        htmlTemplate.setPullService(pullService);
        htmlTemplate.setResourceLoader(factory);
        htmlTemplate.addInlineResource("image", "/");

        textAttachment.setResourceLoader(factory);

        // ����builder
        builder.setContent(attachable);
        {
            attachable.addContent(alternative);
View Full Code Here

        htmlText.setId("htmlText");

        TextTemplateContent plainTextTemplate = new TextTemplateContent("mail/mytemplate.vm", "text/plain");
        plainTextTemplate.setId("plainTextTemplate");

        AttachmentContent textAttachment = new AttachmentContent("testfile.txt");
        textAttachment.setId("textAttachment");

        HTMLTemplateContent htmlTemplate = new HTMLTemplateContent("mail/complexhtml.vm");
        htmlTemplate.setId("htmlTemplate");

        plainTextTemplate.setTemplateService(templateService);
        plainTextTemplate.setPullService(pullService);

        htmlTemplate.setTemplateService(templateService);
        htmlTemplate.setPullService(pullService);
        htmlTemplate.setResourceLoader(factory);
        htmlTemplate.addInlineResource("image", "/");

        textAttachment.setResourceLoader(factory);

        // 加入builder
        builder.setContent(attachable);
        {
            attachable.addContent(alternative);
View Full Code Here

    @Test
    public void resource() throws Exception {
        // null resourceName
        try {
            new AttachmentContent((String) null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("resourceName"));
        }

        try {
            new AttachmentContent((String) null, null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("resourceName"));
        }

        try {
            content.setResource(null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("resourceName"));
        }

        try {
            content.setResource("  ");
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("resourceName"));
        }

        // no resourceLoader
        content = new AttachmentContent("testfile.txt");
        builder.setContent(content);

        try {
            getMessageAsText();
            fail();
        } catch (MailBuilderException e) {
            assertThat(e, exception("Could not find resource \"testfile.txt\": no resourceLoader specified"));
        }

        // resource not found
        content = new AttachmentContent("notExist.txt");
        content.setResourceLoader(factory);
        builder.setContent(content);

        try {
            getMessageAsText();
            fail();
        } catch (MailBuilderException e) {
            assertThat(e, exception("Could not find resource \"notExist.txt\""));
        }

        // stream only resource
        content = new AttachmentContent("/asStream/testfile.txt");
        content.setResourceLoader(factory);
        builder.setContent(content);

        assert_AppOctet_testfile_base64();

        // Resource: text, default name
        content = new AttachmentContent("testfile.txt");
        content.setResourceLoader(factory);
        builder.setContent(content);

        assert_TextPlain_testfile_QuotedPrintable();

        // Resource: gif image, name specified
        content = new AttachmentContent("java.gif", "我的图片.gif");
        content.setResourceLoader(factory);
        builder.setContent(content);

        assert_ImageGif_javagif_我的图片_base64();
View Full Code Here

    @Test
    public void mailBuilder() throws Exception {
        // null mailBuilder
        try {
            new AttachmentContent((MailBuilder) null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("mailBuilder"));
        }

        try {
            content.setMail((MailBuilder) null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("mailBuilder"));
        }

        // mailBuilder
        MailBuilder attached = new MailBuilder();

        attached.setSubject("附件标题");
        attached.setContent(new TextContent("我爱北京敏感词", "text/plain"));

        content = new AttachmentContent(attached);
        builder.setContent(content);

        assert_Mail_我爱北京敏感词();

        // toString
View Full Code Here

    @Test
    public void mail() throws Exception {
        // null message
        try {
            new AttachmentContent((Message) null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("mail"));
        }

        try {
            content.setMail((Message) null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("mail"));
        }

        // message
        MailBuilder attached = new MailBuilder();

        attached.setSubject("附件标题");
        attached.setContent(new TextContent("我爱北京敏感词", "text/plain"));

        Message mail = attached.getMessage(rawSession);

        content = new AttachmentContent(mail);
        builder.setContent(content);

        assert_Mail_我爱北京敏感词();

        // toString
View Full Code Here

        MailService service = createMock(MailService.class);
        expect(service.getMailBuilder("attachedMail")).andReturn(attached);
        expect(service.getMailBuilder("notExistMail")).andThrow(new MailNotFoundException());
        replay(service);

        content = new AttachmentContent();
        content.setMail("attachedMail");
        builder.setContent(content);
        builder.setMailService(service);

        assert_Mail_我爱北京敏感词();

        // notExist ref
        content = new AttachmentContent();
        content.setMail("notExistMail");
        builder.setContent(content);
        builder.setMailService(service);

        try {
View Full Code Here

public class AttachmentContentTests extends AbstractMailBuilderTests {
    private AttachmentContent content;

    @Before
    public void init() {
        content = new AttachmentContent();
    }
View Full Code Here

    @Test
    public void url() throws Exception {
        // null url
        try {
            new AttachmentContent((URL) null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("url"));
        }

        try {
            new AttachmentContent((URL) null, null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("url"));
        }

        try {
            content.setURL(null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("url"));
        }

        // URL: text, default name
        URL url = new File(srcdir, "testfile.txt").toURI().toURL();

        content = new AttachmentContent(url);
        builder.setContent(content);

        assert_TextPlain_testfile_QuotedPrintable();

        // URL: gif image, name specified
        url = new File(srcdir, "java.gif").toURI().toURL();

        content = new AttachmentContent(url, "我的图片.gif");
        builder.setContent(content);

        assert_ImageGif_javagif_我的图片_base64();

        // toString
View Full Code Here

    @Test
    public void file() throws Exception {
        // null file
        try {
            new AttachmentContent((File) null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("file"));
        }

        try {
            new AttachmentContent((File) null, null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("file"));
        }

        try {
            content.setFile(null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("file"));
        }

        // File: text, default name
        File file = new File(srcdir, "testfile.txt");

        content = new AttachmentContent(file);
        builder.setContent(content);

        assert_TextPlain_testfile_QuotedPrintable();

        // File: gif image, name specified
        file = new File(srcdir, "java.gif");

        content = new AttachmentContent(file, "我的图片.gif");
        builder.setContent(content);

        assert_ImageGif_javagif_我的图片_base64();

        // toString
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.mail.builder.content.AttachmentContent$AttachmentSource

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.