File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
src/test/java/com/jcabi/email Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 2929 */
3030package com .jcabi .email ;
3131
32+ import com .jcabi .email .enclosure .EnPlain ;
3233import com .jcabi .email .stamp .StRecipient ;
3334import com .jcabi .email .stamp .StSender ;
35+ import java .io .ByteArrayOutputStream ;
3436import java .util .Properties ;
3537import javax .mail .Message ;
38+ import javax .mail .Multipart ;
3639import javax .mail .Session ;
3740import javax .mail .internet .MimeMessage ;
3841import org .hamcrest .MatcherAssert ;
@@ -87,4 +90,27 @@ public void wrapsAnotherEnvelope() throws Exception {
8790 );
8891 }
8992
93+ /**
94+ * Envelope.MIME can wrap another envelope with enclosures.
95+ * @throws Exception If fails
96+ */
97+ @ Test
98+ public void wrapsAnotherEnvelopeWithEnclosures () throws Exception {
99+ final Envelope origin = new Envelope .MIME ().with (
100+ new EnPlain ("first enclosure" )
101+ );
102+ final Message message = new Envelope .MIME (origin ).with (
103+ new EnPlain ("second enclosure" )
104+ ).unwrap ();
105+ final ByteArrayOutputStream baos = new ByteArrayOutputStream ();
106+ Multipart .class .cast (message .getContent ()).writeTo (baos );
107+ MatcherAssert .assertThat (
108+ baos .toString (),
109+ Matchers .allOf (
110+ Matchers .containsString ("first" ),
111+ Matchers .containsString ("second" )
112+ )
113+ );
114+ }
115+
90116}
You can’t perform that action at this time.
0 commit comments