@Test public void loadMessageThrowsMailStoreExceptionWhenError() { String batchId = UUID.randomUUID().toString(); String messageId = "ar1vm0Wca42E/dDn3dsH8ogs3/s="; Session session = Session.getInstance(new Properties()); Throwable exception = assertThrows(MailStoreException.class, () -> { this.store.load(session, batchId, messageId); }); assertTrue(exception.getMessage().startsWith( "Failed to load message (id [" + messageId + "], batch id [" + batchId + "]) from file")); }
@Override public ExtendedMimeMessage load(Session session, String batchId, String uniqueMessageId) throws MailStoreException { File messageFile = null; try { messageFile = getMessageFile(batchId, uniqueMessageId); InputStream is = new FileInputStream(messageFile); return new ExtendedMimeMessage(session, is); } catch (Exception e) { throw new MailStoreException(String.format( "Failed to load message (id [%s], batch id [%s]) from file [%s]", uniqueMessageId, batchId, messageFile), e); } }
FileSystemMailContentStore implements MailContentStore, Initializable { @Override public ExtendedMimeMessage load(Session session, String batchId, String uniqueMessageId) throws MailStoreException { File messageFile = null; try { messageFile = getMessageFile(batchId, uniqueMessageId); InputStream is = new FileInputStream(messageFile); return new ExtendedMimeMessage(session, is); } catch (Exception e) { throw new MailStoreException(String.format( "Failed to load message (id [%s], batch id [%s]) from file [%s]", uniqueMessageId, batchId, messageFile), e); } } }
FileSystemMailContentStore implements MailContentStore, Initializable { @Override public ExtendedMimeMessage load(Session session, String batchId, String uniqueMessageId) throws MailStoreException { File messageFile = null; try { messageFile = getMessageFile(batchId, uniqueMessageId); InputStream is = new FileInputStream(messageFile); return new ExtendedMimeMessage(session, is); } catch (Exception e) { throw new MailStoreException(String.format( "Failed to load message (id [%s], batch id [%s]) from file [%s]", uniqueMessageId, batchId, messageFile), e); } }  }
FileSystemMailContentStore implements MailContentStore, Initializable { @Override public ExtendedMimeMessage load(Session session, String batchId, String uniqueMessageId) throws MailStoreException { File messageFile = null; try { messageFile = getMessageFile(batchId, uniqueMessageId); InputStream is = new FileInputStream(messageFile); return new ExtendedMimeMessage(session, is); } catch (Exception e) { throw new MailStoreException(String.format( "Failed to load message (id [%s], batch id [%s]) from file [%s]", uniqueMessageId, batchId, messageFile), e); } }  @Override void initialize(); @Override void save(String batchId, ExtendedMimeMessage message); @Override ExtendedMimeMessage load(Session session, String batchId, String uniqueMessageId); @Override void delete(String batchId, String uniqueMessageId); }
FileSystemMailContentStore implements MailContentStore, Initializable { @Override public ExtendedMimeMessage load(Session session, String batchId, String uniqueMessageId) throws MailStoreException { File messageFile = null; try { messageFile = getMessageFile(batchId, uniqueMessageId); InputStream is = new FileInputStream(messageFile); return new ExtendedMimeMessage(session, is); } catch (Exception e) { throw new MailStoreException(String.format( "Failed to load message (id [%s], batch id [%s]) from file [%s]", uniqueMessageId, batchId, messageFile), e); } }  @Override void initialize(); @Override void save(String batchId, ExtendedMimeMessage message); @Override ExtendedMimeMessage load(Session session, String batchId, String uniqueMessageId); @Override void delete(String batchId, String uniqueMessageId); static final String ROOT_DIRECTORY; }