From fae501783247de7a4296f43636041e8d86ce4e0a Mon Sep 17 00:00:00 2001 From: Philip Whitehouse Date: Sun, 24 Dec 2017 18:50:47 +0000 Subject: [PATCH] Add test for IMAP FETCH BODYSTRUCTURE --- .../fsck/k9/mail/store/imap/ImapFolderTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapFolderTest.java b/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapFolderTest.java index 9b78a2b2a..0add60dbb 100644 --- a/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapFolderTest.java +++ b/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapFolderTest.java @@ -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 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");