### Question:
ExtendedMimeMessage extends MimeMessage { public void setType(String mailType) { try { addHeader(XMAIL_TYPE_HEADER, mailType); } catch (MessagingException e) { throw new RuntimeException(String.format("Failed to set Type header to [%s]", mailType), e); } } ExtendedMimeMessage();  ExtendedMimeMessage(Session session, InputStream is);  ExtendedMimeMessage(MimeMessage source); static ExtendedMimeMessage wrap(MimeMessage message); boolean isEmpty(); void setType(String mailType); String getType(); void setMessageId(String messageId); boolean ensureSaved(); @Override void setHeader(String name, String value); String getUniqueMessageId();  }### Answer:
@Test public void setType() throws Exception { ExtendedMimeMessage message = new ExtendedMimeMessage(); message.setType(TEST_XMAIL_TYPE); assertThat(message.getHeader(XMAIL_TYPE_HEADER, null), equalTo(TEST_XMAIL_TYPE)); }
@Test public void setTypeWhenException() { Throwable exception = assertThrows(RuntimeException.class, () -> { ExtendedMimeMessage message = new ThrowingeExtendedMimeMessage(); message.setType(TEST_XMAIL_TYPE); }); assertEquals("Failed to set Type header to [MyType]", exception.getMessage()); assertEquals("MessagingException: error", ExceptionUtils.getRootCauseMessage(exception)); }