MimeEncoder extends MimeEncoderImpl<OutputStream, InputStream> { @Override public void writeMessage(AdaptrisMessage msg, OutputStream target) throws CoreException { try { MultiPartOutput output = new MultiPartOutput(msg.getUniqueId()); output.addPart(payloadAsMimePart(msg), PAYLOAD_CONTENT_ID); output.addPart(getMetadata(msg), getMetadataEncoding(), METADATA_CONTENT_ID); if (msg.getObjectHeaders().containsKey(CoreConstants.OBJ_METADATA_EXCEPTION)) { output.addPart(asMimePart((Exception) msg.getObjectHeaders().get(CoreConstants.OBJ_METADATA_EXCEPTION)), EXCEPTION_CONTENT_ID); } output.writeTo(target); target.flush(); } catch (Exception e) { throw ExceptionHelper.wrapCoreException(e); } } MimeEncoder();  MimeEncoder(Boolean retainUniqueId, String metadataEncoding, String payloadEncoding); @Override void writeMessage(AdaptrisMessage msg, OutputStream target); @Override AdaptrisMessage readMessage(InputStream source); byte[] encode(AdaptrisMessage msg); AdaptrisMessage decode(byte[] bytes);  }
@Test public void testEncode_Exception() { AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(STANDARD_PAYLOAD); msg.addMetadata(METADATA_KEY, METADATA_VALUE); try { mimeEncoder.writeMessage(msg, null); fail(); } catch (CoreException e) { } }