Merge pull request #2986 from philipwhiuk/testBodyStructure

Add test for IMAP FETCH BODYSTRUCTURE
This commit is contained in:
cketti 2017-12-29 06:01:37 +01:00 committed by GitHub
commit d50319053a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -834,6 +834,23 @@ public class ImapFolderTest {
verify(imapConnection).sendCommand("UID FETCH 1 (UID BODYSTRUCTURE)", false);
}
@Test
public void fetch_withStructureFetchProfile_shouldSetContentType() throws Exception {
ImapFolder folder = createFolder("Folder");
prepareImapFolderForOpen(OPEN_MODE_RO);
folder.open(OPEN_MODE_RO);
String bodyStructure = "(\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") NIL NIL \"7BIT\" 2279 48)";
when(imapConnection.readResponse(any(ImapResponseCallback.class)))
.thenReturn(createImapResponse("* 1 FETCH (BODYSTRUCTURE "+bodyStructure+" UID 1)"))
.thenReturn(createImapResponse("x OK"));
List<ImapMessage> messages = createImapMessages("1");
FetchProfile fetchProfile = createFetchProfile(Item.STRUCTURE);
folder.fetch(messages, fetchProfile, null);
verify(messages.get(0)).setHeader(MimeHeader.HEADER_CONTENT_TYPE, "text/plain;\r\n CHARSET=\"US-ASCII\"");
}
@Test
public void fetch_withBodySaneFetchProfile_shouldIssueRespectiveCommand() throws Exception {
ImapFolder folder = createFolder("Folder");