开发者

Testing SMTP errors in my Java app

My Java application encountered an issue in production where the SMTP server is rejecting mails sent to more than x destinations at once. I would like to test the behavior of the application in that situati开发者_运维问答on.

I found Dumbster Fake SMTP Server that is very nice but does not seem to offer a way to reject messages in some tests.

Do you have any suggestions on how I could test this specific scenario ?


I do not know Dumbster, but SubEthaSMTP does have this capability. Maybe the simplest solution is to extend the Wiser class (which implements a simple SMTP server specifically for testing) by overriding its accept method, returning false after the x. recipient.


An alternative I can suggest is through writing a Junit test with EasyMock/ Mockito and simulating the exception that you see on production. You can focus on the part of code that you suspect and issue with and drill down on and fix the root cause. Obviously, if the above suggested SMTP services give you the capability to simulate the error, they may give you better confidence.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜