Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e6625dd authored by Philip Whitehouse's avatar Philip Whitehouse
Browse files

Rename exception and update test

parent d220b29a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ public class MessageExtractor {
            } else {
                throw new MessagingException("Provided invalid part: " + part);
            }
        } catch (UnsupportedEncodingException e) {
        } catch (UnsupportedContentTransferEncodingException e) {
            Log.e(LOG_TAG, "Unable to getTextFromPart", e);
        } catch (IOException e) {
            Log.e(LOG_TAG, "Unable to getTextFromPart", e);
@@ -70,7 +70,7 @@ public class MessageExtractor {
    }

    private static String getTextFromTextPart(Part part, Body body, String mimeType, long textSizeLimit)
            throws IOException, MessagingException, UnsupportedEncodingException {
            throws IOException, MessagingException, UnsupportedContentTransferEncodingException {
        /*
         * We've got a text part, so let's see if it needs to be processed further.
         */
+2 −2
Original line number Diff line number Diff line
@@ -1018,7 +1018,7 @@ public class MimeUtility {
     * The ultimate goal is to get to a point where all classes retain the original data and {@code RawDataBody} can be
     * merged into {@link Body}.
     */
    public static InputStream decodeBody(Body body) throws MessagingException, UnsupportedEncodingException {
    public static InputStream decodeBody(Body body) throws MessagingException, UnsupportedContentTransferEncodingException {
        InputStream inputStream;
        if (body instanceof RawDataBody) {
            RawDataBody rawDataBody = (RawDataBody) body;
@@ -1044,7 +1044,7 @@ public class MimeUtility {
                    }
                };
            } else {
                throw new UnsupportedEncodingException(encoding);
                throw new UnsupportedContentTransferEncodingException(encoding);
            }
        } else {
            inputStream = body.getInputStream();
+7 −0
Original line number Diff line number Diff line
package com.fsck.k9.mail.internet;

public class UnsupportedEncodingException extends Exception {
    public UnsupportedEncodingException(String encoding) {
public class UnsupportedContentTransferEncodingException extends Exception {
    public UnsupportedContentTransferEncodingException(String encoding) {
        super("Unsupported encoding: "+encoding);
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -72,13 +72,13 @@ public class MessageExtractorTest {
        assertNull(result);
    }

    @Test(expected = UnsupportedOperationException.class)
    public void getTextFromPart_withUnknownEncoding_shouldThrowRuntimeException() throws Exception {
    @Test
    public void getTextFromPart_withUnknownEncoding_shouldReturnNull() throws Exception {
        part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, "text/plain");
        BinaryMemoryBody body = new BinaryMemoryBody("Sample text body".getBytes(), "unknown encoding");
        part.setBody(body);

        MessageExtractor.getTextFromPart(part);
        assertNull(MessageExtractor.getTextFromPart(part));
    }

    @Test
+1 −1
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ public class MimeMessageParseTest {
                        "");
    }

    @Test(expected = UnsupportedEncodingException.class)
    @Test(expected = UnsupportedContentTransferEncodingException.class)
    public void testSinglePartUnknownEncoding_throwsUnsupportedEncodingException() throws Exception {
        MimeMessage msg = parseWithoutRecurse(toStream(
                "From: <adam@example.org>\r\n" +
Loading