SidneyShaw / simple-java-mail

Automatically exported from code.google.com/p/simple-java-mail
0 stars 0 forks source link

Would be nice to add mock junit testing support #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to add a feature that performs all sorts of validations on the 
email, but stops short from actually delivering the email over the network.  
For unit testing purposes, etc.

Original issue reported on code.google.com by trentj...@gmail.com on 12 Jul 2012 at 1:50

GoogleCodeExporter commented 9 years ago
Any suggestions? Adding a flag 'test mode' is easy enough so that it won't 
actually send emails.

How would you like to perform the validations?

Original comment by b.bottema on 1 Aug 2012 at 10:38

GoogleCodeExporter commented 9 years ago
Consider this:

    // SmtpReceiver is a simple interface definition from simple-java-mail.
    // The interface looks similar to interface used to talk to the remove server, but perhaps at a higher level of abstraction.
    // In another words, I would like to see SmtpReceiver get the "to", "from", "headers", etc., but not actually see the "helo" handshaking, etc.
    // I'd also like to make sure that simple-java-mail still performs all of the other stuff it does like validation.
    // The SmtpReceiver is the last part of the chain.
    // Oh, I'd also like to be able to have SmtpReceiver throw IOExceptions to similate network/server failures, etc.
    SmtpReceiver aSmtpFakeReceiver = <my mock or fake smtpreceiver>

    Mailer mailer = new Mailer(... aSmtpFakeReceiver ...);

Thoughts?

Original comment by trentj...@gmail.com on 1 Aug 2012 at 12:06

GoogleCodeExporter commented 9 years ago

Original comment by b.bottema on 25 Oct 2013 at 8:32