Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configurable mail server mock for JUnit tests?

I'm looking for a mail server mock that can be configured like a Mockito mock object. Currently we are using GreenMail as mail server mock, but I would like to do something like this in my unit tests:

  • if mail with subject xyz arrives, accept.
  • if mail with subject zz1 arrives, send temporarily failure
  • if mail with subject fh2 arrives, send bounce (unknown recipient).
  • .....

As I can see, GreenMail is not capable of this. Does anyone knows a library which can do something like this?

like image 392
martin Avatar asked Nov 13 '22 15:11

martin


1 Answers

So, finally i extended greenmail with the functionallity to close smtp server after x mails or skip acceptance of smtp connection after x mails and to slow down the smtp handling for a specific mail. Thanks for the answers. Its possible that i'm allowed to push my changes back to greenmail trunk. We'll see.

like image 121
martin Avatar answered Dec 26 '22 05:12

martin