Java Code Examples for org.apache.james.mime4j.message.BodyPart#setHeader()
The following examples show how to use
org.apache.james.mime4j.message.BodyPart#setHeader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageContentExtractorTest.java From james-project with Apache License 2.0 | 6 votes |
@Test void extractShouldRetrieveHtmlBodyWithOneInlinedHTMLAttachmentWithoutCid() throws IOException { //Given BodyPart inlinedHTMLPart = BodyPartBuilder.create() .setBody(HTML_CONTENT, "html", StandardCharsets.UTF_8) .build(); HeaderImpl inlinedHeader = new HeaderImpl(); inlinedHeader.addField(Fields.contentDisposition(MimeMessage.INLINE)); inlinedHeader.addField(Fields.contentType("text/html; charset=utf-8")); inlinedHTMLPart.setHeader(inlinedHeader); Multipart multipartAlternative = MultipartBuilder.create("alternative") .addBodyPart(inlinedHTMLPart) .build(); Message message = Message.Builder.of() .setBody(multipartAlternative) .build(); //When MessageContent actual = testee.extract(message); //Then assertThat(actual.getHtmlBody()).contains(HTML_CONTENT); }
Example 2
Source File: MessageContentExtractorTest.java From james-project with Apache License 2.0 | 6 votes |
@Test void extractShouldNotRetrieveHtmlBodyWithOneInlinedHTMLAttachmentWithCid() throws IOException { //Given BodyPart inlinedHTMLPart = BodyPartBuilder.create() .setBody(HTML_CONTENT, "html", StandardCharsets.UTF_8) .build(); HeaderImpl inlinedHeader = new HeaderImpl(); inlinedHeader.addField(Fields.contentDisposition(MimeMessage.INLINE)); inlinedHeader.addField(Fields.contentType("text/html; charset=utf-8")); inlinedHeader.addField(CONTENT_ID_FIELD); inlinedHTMLPart.setHeader(inlinedHeader); Multipart multipartAlternative = MultipartBuilder.create("alternative") .addBodyPart(inlinedHTMLPart) .build(); Message message = Message.Builder.of() .setBody(multipartAlternative) .build(); //When MessageContent actual = testee.extract(message); //Then assertThat(actual.getHtmlBody()).isEmpty(); }
Example 3
Source File: MessageContentExtractorTest.java From james-project with Apache License 2.0 | 6 votes |
@Test void extractShouldRetrieveTextBodyWithOneInlinedTextAttachmentWithoutCid() throws IOException { //Given BodyPart inlinedTextPart = BodyPartBuilder.create() .setBody(TEXT_CONTENT, "text", StandardCharsets.UTF_8) .build(); HeaderImpl inlinedHeader = new HeaderImpl(); inlinedHeader.addField(Fields.contentDisposition(MimeMessage.INLINE)); inlinedHeader.addField(Fields.contentType("text/plain; charset=utf-8")); inlinedTextPart.setHeader(inlinedHeader); Multipart multipartAlternative = MultipartBuilder.create("alternative") .addBodyPart(inlinedTextPart) .build(); Message message = Message.Builder.of() .setBody(multipartAlternative) .build(); //When MessageContent actual = testee.extract(message); //Then assertThat(actual.getTextBody()).contains(TEXT_CONTENT); }
Example 4
Source File: MessageContentExtractorTest.java From james-project with Apache License 2.0 | 6 votes |
@Test void extractShouldNotRetrieveTextBodyWithOneInlinedTextAttachmentWithCid() throws IOException { //Given BodyPart inlinedTextPart = BodyPartBuilder.create() .setBody(TEXT_CONTENT, "text", StandardCharsets.UTF_8) .build(); HeaderImpl inlinedHeader = new HeaderImpl(); inlinedHeader.addField(Fields.contentDisposition(MimeMessage.INLINE)); inlinedHeader.addField(Fields.contentType("text/plain; charset=utf-8")); inlinedHeader.addField(CONTENT_ID_FIELD); inlinedTextPart.setHeader(inlinedHeader); Multipart multipartAlternative = MultipartBuilder.create("alternative") .addBodyPart(inlinedTextPart) .build(); Message message = Message.Builder.of() .setBody(multipartAlternative) .build(); //When MessageContent actual = testee.extract(message); //Then assertThat(actual.getTextBody()).isEmpty(); }