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

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


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

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

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

        // DS: text, no name
        DataSource dataSource = new ResourceDataSource(factory.getResource("testfile.txt"), null, "text/plain") {
            @Override
            public String getName() {
                return null;
            }
        };

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

        try {
            getMessageAsText();
            fail();
        } catch (MailBuilderException e) {
            assertThat(e, exception("No fileName was specified with "
                                    + "DataSource[Resource[testfile.txt, loaded by ResourceLoadingService]]"));
        }

        // DS: text, no name, name specified
        content = new AttachmentContent(dataSource, "testfile.txt");
        builder.setContent(content);

        assert_TextPlain_testfile_QuotedPrintable();

        // DS: text, default name
        dataSource = new ResourceDataSource(factory.getResource("testfile.txt"), null, "text/plain");

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

        assert_TextPlain_testfile_QuotedPrintable();

        // DS: gif image, name specfied
        dataSource = new ResourceDataSource(factory.getResource("java.gif"), null, "image/gif");

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

        assert_ImageGif_javagif_我的图片_base64();

        // toString
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

TOP

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

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.