Skip to content

Commit 274da08

Browse files
author
Yegor Bugayenko
committed
#16 bug reproduced
1 parent 9ca7457 commit 274da08

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/java/com/jcabi/email/EnvelopeTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@
2929
*/
3030
package com.jcabi.email;
3131

32+
import com.jcabi.email.enclosure.EnPlain;
3233
import com.jcabi.email.stamp.StRecipient;
3334
import com.jcabi.email.stamp.StSender;
35+
import java.io.ByteArrayOutputStream;
3436
import java.util.Properties;
3537
import javax.mail.Message;
38+
import javax.mail.Multipart;
3639
import javax.mail.Session;
3740
import javax.mail.internet.MimeMessage;
3841
import 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
}

0 commit comments

Comments
 (0)