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

Examples of com.alibaba.citrus.service.mail.builder.content.MultipartContent


        assertSame(builder, content2.getMailBuilder());
    }

    @Test
    public void getContentById() {
        MultipartContent multi1 = new MyMultipart();
        multi1.setId("multi1");

        MultipartContent multi2 = new MyMultipart();
        multi2.setId("multi2");

        MyContent content1 = new MyContent();
        content1.setId("content1");

        MyContent content2 = new MyContent();

        // simple content with id
        builder.setContent(content1);
        assertSame(content1, builder.getContent("content1"));

        // simple content without id
        builder.setContent(content2);
        assertSame(content2, builder.getContent());
        assertNull(builder.getContent("content2"));

        // complex content
        builder.setContent(multi1);
        assertSame(multi1, builder.getContent("multi1"));
        assertNull(builder.getContent("multi2"));
        assertNull(builder.getContent("content1"));
        assertNull(builder.getContent("content2"));

        // content changed
        multi1.addContent(multi2);
        multi1.addContent(content2);
        multi2.addContent(content1);

        assertSame(multi1, builder.getContent("multi1"));
        assertSame(multi2, builder.getContent("multi2"));
        assertSame(content1, builder.getContent("content1"));
        assertNull(builder.getContent("content2"));
View Full Code Here


        assertArrayEquals(new MailContent[] { content1, content2 }, multipart.getContents());
    }

    @Test
    public void clone_() {
        MultipartContent copy = (MultipartContent) multipart.clone();
        MailContent[] contentCopys = copy.getContents();

        assertEquals(2, contentCopys.length);
        assertNotSame(content1, contentCopys[0]);
        assertNotSame(content2, contentCopys[1]);
View Full Code Here

    private MailBuilder createVeryComplexMail() {
        MailBuilder builder = new MailBuilder();

        // ��������contents��
        MultipartContent attachable = new MixedMultipartContent();
        attachable.setId("attachable");

        MultipartContent alternative = new AlternativeMultipartContent();
        alternative.setId("alternative");

        TextContent plainText = new TextContent("�Ұ��������д�", "text/plain");
        plainText.setId("plainText");

        TextContent htmlText = new TextContent("<���������д�>", "text/html");
        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);
            {
                alternative.addContent(plainText);
                alternative.addContent(htmlText);
            }

            attachable.addContent(plainTextTemplate);
            attachable.addContent(textAttachment);
            attachable.addContent(htmlTemplate);
View Full Code Here

        assertArrayEquals(new MailContent[] { content1, content2 }, multipart.getContents());
    }

    @Test
    public void clone_() {
        MultipartContent copy = (MultipartContent) multipart.clone();
        MailContent[] contentCopys = copy.getContents();

        assertEquals(2, contentCopys.length);
        assertNotSame(content1, contentCopys[0]);
        assertNotSame(content2, contentCopys[1]);
View Full Code Here

    private MailBuilder createVeryComplexMail() {
        MailBuilder builder = new MailBuilder();

        // 创建所有contents。
        MultipartContent attachable = new MixedMultipartContent();
        attachable.setId("attachable");

        MultipartContent alternative = new AlternativeMultipartContent();
        alternative.setId("alternative");

        TextContent plainText = new TextContent("我爱北京敏感词", "text/plain");
        plainText.setId("plainText");

        TextContent htmlText = new TextContent("<爱北京敏感词>", "text/html");
        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);
            {
                alternative.addContent(plainText);
                alternative.addContent(htmlText);
            }

            attachable.addContent(plainTextTemplate);
            attachable.addContent(textAttachment);
            attachable.addContent(htmlTemplate);
View Full Code Here

        assertSame(builder, content2.getMailBuilder());
    }

    @Test
    public void getContentById() {
        MultipartContent multi1 = new MyMultipart();
        multi1.setId("multi1");

        MultipartContent multi2 = new MyMultipart();
        multi2.setId("multi2");

        MyContent content1 = new MyContent();
        content1.setId("content1");

        MyContent content2 = new MyContent();

        // simple content with id
        builder.setContent(content1);
        assertSame(content1, builder.getContent("content1"));

        // simple content without id
        builder.setContent(content2);
        assertSame(content2, builder.getContent());
        assertNull(builder.getContent("content2"));

        // complex content
        builder.setContent(multi1);
        assertSame(multi1, builder.getContent("multi1"));
        assertNull(builder.getContent("multi2"));
        assertNull(builder.getContent("content1"));
        assertNull(builder.getContent("content2"));

        // content changed
        multi1.addContent(multi2);
        multi1.addContent(content2);
        multi2.addContent(content1);

        assertSame(multi1, builder.getContent("multi1"));
        assertSame(multi2, builder.getContent("multi2"));
        assertSame(content1, builder.getContent("content1"));
        assertNull(builder.getContent("content2"));
View Full Code Here

    private MailBuilder createVeryComplexMail() {
        MailBuilder builder = new MailBuilder();

        // 创建所有contents。
        MultipartContent attachable = new MixedMultipartContent();
        attachable.setId("attachable");

        MultipartContent alternative = new AlternativeMultipartContent();
        alternative.setId("alternative");

        TextContent plainText = new TextContent("我爱北京敏感词", "text/plain");
        plainText.setId("plainText");

        TextContent htmlText = new TextContent("<爱北京敏感词>", "text/html");
        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);
            {
                alternative.addContent(plainText);
                alternative.addContent(htmlText);
            }

            attachable.addContent(plainTextTemplate);
            attachable.addContent(textAttachment);
            attachable.addContent(htmlTemplate);
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.mail.builder.content.MultipartContent

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.