Search in sources :

Example 61 with MessagingException

use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.

the class MessagingControllerTest method listFoldersSynchronous_shouldNotNotifyFinishedAfterFailure.

@Test
public void listFoldersSynchronous_shouldNotNotifyFinishedAfterFailure() throws MessagingException {
    when(localStore.getPersonalNamespaces(false)).thenThrow(new MessagingException("Test"));
    controller.listFoldersSynchronous(account, true, listener);
    verify(listener, never()).listFoldersFinished(account);
}
Also used : MessagingException(com.fsck.k9.mail.MessagingException) Test(org.junit.Test)

Example 62 with MessagingException

use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.

the class MessageCryptoHelper method extractClearsignedTextReplacementPart.

private static MimeBodyPart extractClearsignedTextReplacementPart(Part part) {
    try {
        String clearsignedText = MessageExtractor.getTextFromPart(part);
        String replacementText = OpenPgpUtils.extractClearsignedMessage(clearsignedText);
        if (replacementText == null) {
            Timber.e("failed to extract clearsigned text for replacement part");
            return NO_REPLACEMENT_PART;
        }
        return new MimeBodyPart(new TextBody(replacementText), "text/plain");
    } catch (MessagingException e) {
        Timber.e(e, "failed to create clearsigned text replacement part");
        return NO_REPLACEMENT_PART;
    }
}
Also used : TextBody(com.fsck.k9.mail.internet.TextBody) MessagingException(com.fsck.k9.mail.MessagingException) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart)

Example 63 with MessagingException

use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.

the class MessagingControllerTest method clearFolderSynchronous_whenStorageUnavailable_shouldThrowUnavailableAccountException.

@Test(expected = UnavailableAccountException.class)
public void clearFolderSynchronous_whenStorageUnavailable_shouldThrowUnavailableAccountException() throws MessagingException {
    doThrow(new UnavailableStorageException("Test")).when(localFolder).open(Folder.OPEN_MODE_RW);
    controller.clearFolderSynchronous(account, FOLDER_NAME, listener);
}
Also used : UnavailableStorageException(com.fsck.k9.mailstore.UnavailableStorageException) Test(org.junit.Test)

Example 64 with MessagingException

use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.

the class MessagingControllerTest method refreshRemoteSynchronous_shouldCreateFoldersFromRemote.

@Test
public void refreshRemoteSynchronous_shouldCreateFoldersFromRemote() throws MessagingException {
    configureRemoteStoreWithFolder();
    LocalFolder newLocalFolder = mock(LocalFolder.class);
    List<Folder> folders = Collections.singletonList(remoteFolder);
    when(remoteStore.getPersonalNamespaces(false)).thenAnswer(createAnswer(folders));
    when(remoteFolder.getName()).thenReturn("NewFolder");
    when(localStore.getFolder("NewFolder")).thenReturn(newLocalFolder);
    controller.refreshRemoteSynchronous(account, listener);
    verify(localStore).createFolders(eq(Collections.singletonList(newLocalFolder)), anyInt());
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) Folder(com.fsck.k9.mail.Folder) LocalFolder(com.fsck.k9.mailstore.LocalFolder) Test(org.junit.Test)

Example 65 with MessagingException

use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.

the class MessagingControllerTest method refreshRemoteSynchronous_shouldDeleteFoldersNotOnRemote.

@Test
public void refreshRemoteSynchronous_shouldDeleteFoldersNotOnRemote() throws MessagingException {
    configureRemoteStoreWithFolder();
    LocalFolder oldLocalFolder = mock(LocalFolder.class);
    when(oldLocalFolder.getName()).thenReturn("OldLocalFolder");
    when(localStore.getPersonalNamespaces(false)).thenReturn(Collections.singletonList(oldLocalFolder));
    List<Folder> folders = Collections.emptyList();
    when(remoteStore.getPersonalNamespaces(false)).thenAnswer(createAnswer(folders));
    controller.refreshRemoteSynchronous(account, listener);
    verify(oldLocalFolder).delete(false);
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) Folder(com.fsck.k9.mail.Folder) LocalFolder(com.fsck.k9.mailstore.LocalFolder) Test(org.junit.Test)

Aggregations

MessagingException (com.fsck.k9.mail.MessagingException)159 Test (org.junit.Test)73 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)52 LocalFolder (com.fsck.k9.mailstore.LocalFolder)49 LocalStore (com.fsck.k9.mailstore.LocalStore)49 ArrayList (java.util.ArrayList)49 Message (com.fsck.k9.mail.Message)44 LocalMessage (com.fsck.k9.mailstore.LocalMessage)42 IOException (java.io.IOException)42 FetchProfile (com.fsck.k9.mail.FetchProfile)30 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)28 ByteArrayOutputStream (java.io.ByteArrayOutputStream)27 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)26 BodyPart (com.fsck.k9.mail.BodyPart)23 Part (com.fsck.k9.mail.Part)22 Account (com.fsck.k9.Account)21 Body (com.fsck.k9.mail.Body)21 TextBody (com.fsck.k9.mail.internet.TextBody)21 Date (java.util.Date)20 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)18