Greenmail problems

classic Classic list List threaded Threaded
7 messages Options
Jet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Greenmail problems

Jet
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()
    }
}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Greenmail problems

Mike Hugo-2
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:

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', [hidden email]',
[hidden email]', 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()
   }
}
--
View this message in context: http://grails.1312388.n4.nabble.com/Greenmail-problems-tp3037671p3037671.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
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!
Jet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Greenmail problems

Jet
Hi Mike,

Thanks for the quick reply.

Yes, I had the same smtp port config you mentioned in my Config.groovy.

Thanks

jet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Greenmail problems

Mike Hugo-2
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:

Hi Mike,

Thanks for the quick reply.

Yes, I had the same smtp port config you mentioned in my Config.groovy.

Thanks

jet
--
View this message in context: http://grails.1312388.n4.nabble.com/Greenmail-problems-tp3037671p3037789.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
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!
Jet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Greenmail problems

Jet
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Greenmail problems

Mike Hugo-2
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:

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
--
View this message in context: http://grails.1312388.n4.nabble.com/Greenmail-problems-tp3037671p3037930.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
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!
Jet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Greenmail problems

Jet
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
Loading...