/** * Write the specified <code>Entity</code> to the specified * <code>OutputStream</code>. * * @param entity * the <code>Entity</code> to write. * @param out * the OutputStream to write to. * @throws IOException * if an I/O error occurs. */ public void writeEntity(Entity entity, OutputStream out) throws IOException { final Header header = entity.getHeader(); if (header == null) throw new IllegalArgumentException("Missing header"); writeHeader(header, out); final Body body = entity.getBody(); if (body == null) throw new IllegalArgumentException("Missing body"); boolean binaryBody = body instanceof BinaryBody; OutputStream encOut = encodeStream(out, entity .getContentTransferEncoding(), binaryBody); writeBody(body, encOut); // close if wrapped (base64 or quoted-printable) if (encOut != out) encOut.close(); }
assertThat(attachmentPart.getMimeType()).isEqualTo(expectedMimeType); assertThat(attachmentPart.getHeader().getField("Content-ID").getBody()).isEqualTo(expectedCID); assertThat(attachmentPart.getContentTransferEncoding()).isEqualTo("base64");