|
Hi All,
I followed the greenmail tutorial at http://www.grails.org/plugin/greenmail but the integration test turns out junit.framework.AssertionFailedError: expected:<1> but was:<0> junit.framework.AssertionFailedError: junit.framework.AssertionFailedError: expected:<1> but was:<0> at GreenmailTests.testSendMail(GreenmailTests.groovy:16) Has anybody come across the same problem? I am using Grails 1.3.5, mail 0.9, greenmail 1.2.1 The code is as below import com.icegreen.greenmail.util.* class GreenmailTests extends GroovyTestCase { def mailService def greenMail void testSendMail() { Map mail = [message:'hello world', from:'from@piragua.com', to:'to@piragua.com', subject:'subject'] mailService.sendMail { to mail.to from mail.from subject mail.subject body mail.message } assertEquals(1, greenMail.getReceivedMessages().length) def message = greenMail.getReceivedMessages()[0] assertEquals(mail.message, GreenMailUtil.getBody(message)) assertEquals(mail.from, GreenMailUtil.getAddressList(message.from)) assertEquals(mail.subject, message.subject) } void tearDown() { greenMail.deleteAllMessages() } } |
|
How do you have your mail server configured in Config.groovy? e.g. do you have this defined for your test environment?
grails.mail.port = com.icegreen.greenmail.util.ServerSetupTest.SMTP.port Mike On Thu, Nov 11, 2010 at 5:35 AM, Jet <[hidden email]> wrote:
-- Mike Hugo Piragua Consulting http://www.piragua.com/about Try http://WhenWorksForYou.com the next time you need to coordinate schedules with friends or colleagues! |
|
Hi Mike,
Thanks for the quick reply. Yes, I had the same smtp port config you mentioned in my Config.groovy. Thanks jet |
|
My guess is that you're somehow connecting to a real server (in fact, I received a message this morning delivered to the [hidden email] email address from the [hidden email] email address with the body and subject in your test - no worries, it's happened before!). Try adding
grails.mail.host = 'localhost' to your config in the test environment where you have the port defined. Mike
On Thu, Nov 11, 2010 at 7:08 AM, Jet <[hidden email]> wrote:
-- Mike Hugo Piragua Consulting http://www.piragua.com/about Try http://WhenWorksForYou.com the next time you need to coordinate schedules with friends or colleagues! |
|
Hi Mike,
I followed your advice to add the grails.mail.host="localhost". But still: junit.framework.AssertionFailedError: expected:<1> but was:<0> by the way, when using greenmail plugin, will it send emails. As I keep receiving emails (me is the receipt) when running integration test using greenmail. many thanks for looking into it. jet |
|
Any chance you can create a sample project that replicates the problem and do
grails bug-report and send the resulting zip file? Mike
On Thu, Nov 11, 2010 at 8:38 AM, Jet <[hidden email]> wrote:
-- Mike Hugo Piragua Consulting http://www.piragua.com/about Try http://WhenWorksForYou.com the next time you need to coordinate schedules with friends or colleagues! |
|
Hi Mike,
Sort it. I was refactoring some else' code. Though there is no real server setting in Config.groovy, but there are some mail related setting in the resource.xml which cause the problem I commented the content out in the resource.xml, and the integration test runs fine. Many thanks Jet |
| Powered by Nabble | See how NAML generates this page |
