Quantcast

DGG 2nd: Service Injection in TagLib Integration test fails (1.2-SNAPSHOT)

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

DGG 2nd: Service Injection in TagLib Integration test fails (1.2-SNAPSHOT)

A_Grails_User
Hi there,

I'm referring to "The Definitive Guide to Grails Second Edition" chapter 8, p191 et seq
File: test/integration/com/g2one/gtunes/AlbumArtTagLibTests.groovy

The injection of the AlbumArtService into the AlbumArtTagLib via a property that
matches the bean naming conventions for the AlbumArtService does not work:

class AlbumArtTagLibTests extends GroovyPagesTestCase {

    def albumArtService

    void testAlbumArtServiceIsNotNull() {
        assertNotNull "AlbumArtService Instance is null!", albumArtService
    }
   
    ...
}

The albumArtService instance is null, the integration test will fail.

Does anyone else having problems with injecting a service into an integration test?

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

Re: DGG 2nd: Service Injection in TagLib Integration test fails (1.2-SNAPSHOT)

Glenn Saqui-3
Tests don't have services injected into them.  If you are integration testing a tag lib and the tag lib has a service it will be injected in.  If you are unit testing a tag lib, which I suggest is the better option, then the service is not injected into it either.

Cheers,
Glenn

On Fri, Mar 5, 2010 at 6:16 AM, A_Grails_User <[hidden email]> wrote:

Hi there,

I'm referring to "The Definitive Guide to Grails Second Edition" chapter 8,
p191 et seq
File: test/integration/com/g2one/gtunes/AlbumArtTagLibTests.groovy

The injection of the AlbumArtService into the AlbumArtTagLib via a property
that
matches the bean naming conventions for the AlbumArtService does not work:

class AlbumArtTagLibTests extends GroovyPagesTestCase {

   def albumArtService

   void testAlbumArtServiceIsNotNull() {
       assertNotNull "AlbumArtService Instance is null!", albumArtService
   }

   ...
}

The albumArtService instance is null, the integration test will fail.

Does anyone else having problems with injecting a service into an
integration test?

Cheers
--
View this message in context: http://n4.nabble.com/DGG-2nd-Service-Injection-in-TagLib-Integration-test-fails-1-2-SNAPSHOT-tp1579250p1579250.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



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

Re: DGG 2nd: Service Injection in TagLib Integration test fails (1.2-SNAPSHOT)

Robert Fletcher
On Friday, March 5, 2010, Glenn Saqui <[hidden email]> wrote:
> Tests don't have services injected into them.

Integration and functional tests do.

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

    http://xircles.codehaus.org/manage_email


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

Re: DGG 2nd: Service Injection in TagLib Integration test fails (1.2-SNAPSHOT)

A_Grails_User
Does this mean it is a bug?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: DGG 2nd: Service Injection in TagLib Integration test fails (1.2-SNAPSHOT)

A_Grails_User
It's not a bug. I ran the test inside Idea as unit test. This is obviously a bad idea because it is an integration test. When I run my test in grails everything works as expected. Sorry, my bad.
Loading...