@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));