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

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


    @Test
    public void mail_textContent() throws Exception {
        // no text
        getAndAssertMail("textContent_empty", "GBK", null);

        TextContent content = (TextContent) builder.getContent();
        assertEquals("text/plain", content.getContentType());
        assertEquals("", content.getText());

        String eml = getMessageAsText();

        assertThat(eml, containsRegex("Subject: " + REGEX_EOL));
        assertThat(eml, containsRegex("Content-Type: text/plain; charset=GBK" + REGEX_EOL));
        assertThat(eml, containsRegex("Content-Transfer-Encoding: 8bit" + REGEX_EOL));
        assertThat(eml, containsRegex(REGEX_EOL + REGEX_EOL + "$"));

        // with text
        getAndAssertMail("textContent_withText", "GBK", null);

        content = (TextContent) builder.getContent();
        assertEquals("text/html", content.getContentType());
        assertEquals("hello, �й�", content.getText());

        eml = getMessageAsText();

        assertThat(eml, containsRegex("Subject: " + REGEX_EOL));
        assertThat(eml, containsRegex("Content-Type: text/html; charset=GBK" + REGEX_EOL));
View Full Code Here


    private MultipartContent multipart;
    private String multipartContentType;

    @Before
    public void init() throws Exception {
        content1 = new TextContent("content1");
        content2 = new TextContent("content2", "text/html");

        multipart = (MultipartContent) multipartClass.newInstance();
        multipart.addContent(content1);
        multipart.addContent(content2);
View Full Code Here

        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");
View Full Code Here

    protected MailBuilder createMailBuilder(String subject, String addr) {
        MailBuilder builder = new MailBuilder();

        builder.setSubject(subject);
        builder.setContent(new TextContent());
        builder.setAddress(MailAddressType.TO, addr);

        return builder;
    }
View Full Code Here

public class TextContentTests extends AbstractMailBuilderTests {
    private TextContent content;

    @Test
    public void empty_content() throws Exception {
        initContent(new TextContent());

        assertEquals("text/plain", content.getContentType()); // default content type

        assertThat(getMessageAsText(), containsAllRegex( //
                "Content-Type: text/plain; charset=UTF-8" + REGEX_EOL, //
View Full Code Here

                REGEX_EOL + REGEX_EOL + "$"));
    }

    @Test
    public void with_content() throws Exception {
        initContent(new TextContent("hello, world"));

        assertEquals("text/plain", content.getContentType()); // default content type

        assertThat(getMessageAsText(), containsAllRegex( //
                "Content-Type: text/plain; charset=UTF-8" + REGEX_EOL, //
View Full Code Here

                "hello, world$"));
    }

    @Test
    public void with_content_and_type() throws Exception {
        initContent(new TextContent("hello, world", "text/html"));

        assertEquals("text/html", content.getContentType());

        assertThat(getMessageAsText(), containsAllRegex( //
                "Content-Type: text/html; charset=UTF-8" + REGEX_EOL, //
View Full Code Here

                "hello, world$"));
    }

    @Test
    public void toString_defaultContentType() {
        initContent(new TextContent("hello, world"));

        String result = "";

        result += "TextContent {\n";
        result += "  contentType = text/plain\n";
View Full Code Here

        assertEquals(result, content.toString());
    }

    @Test
    public void toString_specifiedContentType() {
        initContent(new TextContent("hello, world", "text/html"));

        String result = "";

        result += "TextContent {\n";
        result += "  contentType = text/html\n";
View Full Code Here

public class TextContentTests extends AbstractMailBuilderTests {
    private TextContent content;

    @Test
    public void empty_content() throws Exception {
        initContent(new TextContent());

        assertEquals("text/plain", content.getContentType()); // default content type

        assertThat(getMessageAsText(), containsAllRegex( //
                                                         "Content-Type: text/plain; charset=UTF-8" + REGEX_EOL, //
View Full Code Here

TOP

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

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.