MimeMessageWrapper extends MimeMessage implements Disposable { @Override public synchronized int getSize() throws MessagingException { if (source != null) { try { long fullSize = source.getMessageSize(); if (headers == null) { loadHeaders(); } return (int) (fullSize - initialHeaderSize - 2); } catch (IOException e) { throw new MessagingException("Unable to calculate message size"); } } else { if (!messageParsed) { loadMessage(); } return super.getSize(); } } private  MimeMessageWrapper(Session session);  MimeMessageWrapper(Session session, MimeMessageSource source);  MimeMessageWrapper(MimeMessageSource source);  MimeMessageWrapper(MimeMessage original); synchronized String getSourceId(); synchronized void loadMessage(); synchronized boolean isModified(); synchronized boolean isBodyModified(); synchronized boolean isHeaderModified(); @Override void writeTo(OutputStream os); @Override void writeTo(OutputStream os, String[] ignoreList); void writeTo(OutputStream headerOs, OutputStream bodyOs); void writeTo(OutputStream headerOs, OutputStream bodyOs, String[] ignoreList); synchronized void writeTo(OutputStream headerOs, OutputStream bodyOs, String[] ignoreList, boolean preLoad); @Override synchronized int getSize(); @Override int getLineCount(); long getMessageSize(); @Override String[] getHeader(String name); @Override String getHeader(String name, String delimiter); @Override Enumeration<Header> getAllHeaders(); @Override Enumeration<Header> getMatchingHeaders(String[] names); @Override Enumeration<Header> getNonMatchingHeaders(String[] names); @Override Enumeration<String> getAllHeaderLines(); @Override Enumeration<String> getMatchingHeaderLines(String[] names); @Override Enumeration<String> getNonMatchingHeaderLines(String[] names); @Override void setHeader(String name, String value); @Override void addHeader(String name, String value); @Override void removeHeader(String name); @Override void addHeaderLine(String line); @Override synchronized void setDataHandler(DataHandler arg0); @Override void dispose(); @Override synchronized InputStream getRawInputStream(); synchronized InputStream getMessageInputStream(); static final String USE_MEMORY_COPY; }
@Test public void testSize() throws MessagingException { assertThat(mw.getSize()).isEqualTo(body.length()); }
@Test public void testSizeModifiedBodyWithoutSave() throws MessagingException { String newBody = "This is the new body of the message"; mw.setText(newBody); assertThat(mw.getSize()).isEqualTo(body.length()); }
@Test public void testSizeModifiedBodyWithSave() throws MessagingException { String newBody = "This is the new body of the message"; mw.setText(newBody); mw.saveChanges(); assertThat(mw.getSize()).isEqualTo(body.length()); }