Quantcast

Troubles with Grails + Maven integration testing

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

Troubles with Grails + Maven integration testing

Stefan-2
Hi all,

I'm using grails 2.0.3 with the grails-maven-plugin. I have a starter
project (generated from an archetype), which packages and runs fine.

However, I'm troubled with the integration tests. As I understand what
is written here - http://grails.org/doc/latest/guide/spring.html, one
can define his own applicationContext and it can be extended via
resources.xml/resources.groovy, but only the beans defined in
resources.xml/resources.groovy will be autowired in the integration
tests (which makes sense). The problem is that the applicationContext
does not seem to be initialized at all and I cannot reference any beans
defined there in my resources.xml.

Is that the correct behavior or am I doing something wrong? Any help is
much appreciated!

Thanks,
Stefan

--
Stefan Enev<[hidden email]>
Software Engineer
Ontotext AD


---------------------------------------------------------------------
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: Troubles with Grails + Maven integration testing

Graeme Rocher-4
Administrator
What do you mean by "define your own applicationContext.xml"

That is not something Grails supports necessarily. You can define
additional beans in resources.xml but you shouldn't be modifying
applicationContext.xml

Cheers

On Fri, Apr 20, 2012 at 2:07 PM, Stefan <[hidden email]> wrote:

> Hi all,
>
> I'm using grails 2.0.3 with the grails-maven-plugin. I have a starter
> project (generated from an archetype), which packages and runs fine.
>
> However, I'm troubled with the integration tests. As I understand what is
> written here - http://grails.org/doc/latest/guide/spring.html, one can
> define his own applicationContext and it can be extended via
> resources.xml/resources.groovy, but only the beans defined in
> resources.xml/resources.groovy will be autowired in the integration tests
> (which makes sense). The problem is that the applicationContext does not
> seem to be initialized at all and I cannot reference any beans defined there
> in my resources.xml.
>
> Is that the correct behavior or am I doing something wrong? Any help is much
> appreciated!
>
> Thanks,
> Stefan
>
> --
> Stefan Enev<[hidden email]>
> Software Engineer
> Ontotext AD
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>



--
Graeme Rocher
Grails Project Lead
SpringSource - A Division of VMware
http://www.springsource.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: Troubles with Grails + Maven integration testing

Stefan-2
Hi Graeme,

Thanks for your response!

Why is that? As I've used Spring before Grails there are some cases when you have an applicationContext which holds the "application context" and you also have a DispatcherServlet context, where you do the URL mapping and define the necessary beans. So I think it is natural to have the most common or let's say fundamental resources defined in the applicationContext and just override/extend it via resources.xml. And as the documentation says "You can easily register new (or override existing) beans by configuring them in grails-app/conf/spring/resources.groovy", there should be some beans defined by me in the applicationContext, right? That's what I mean by my own applicationContext.xml.

I'm trying to use GATE embedded into my Grails app, you can see http://gate.ac.uk/sale/tao/splitch7.html#x11-1750007.15 if you're interested.
We've used it in many Spring applications, but it just seems that the applicationContext isn't loaded at all in the integration-test phase and the resources.xml cannot reference beans defined in the applicationContext.

Cheers,
Stefan

On 20.4.2012 г. 18:32 ч., Graeme Rocher wrote:
What do you mean by "define your own applicationContext.xml"

That is not something Grails supports necessarily. You can define
additional beans in resources.xml but you shouldn't be modifying
applicationContext.xml

Cheers

On Fri, Apr 20, 2012 at 2:07 PM, Stefan [hidden email] wrote:
Hi all,

I'm using grails 2.0.3 with the grails-maven-plugin. I have a starter
project (generated from an archetype), which packages and runs fine.

However, I'm troubled with the integration tests. As I understand what is
written here - http://grails.org/doc/latest/guide/spring.html, one can
define his own applicationContext and it can be extended via
resources.xml/resources.groovy, but only the beans defined in
resources.xml/resources.groovy will be autowired in the integration tests
(which makes sense). The problem is that the applicationContext does not
seem to be initialized at all and I cannot reference any beans defined there
in my resources.xml.

Is that the correct behavior or am I doing something wrong? Any help is much
appreciated!

Thanks,
Stefan

--
Stefan Enev[hidden email]
Software Engineer
Ontotext AD


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

  http://xircles.codehaus.org/manage_email






-- 
Stefan Enev [hidden email]
Software Engineer
Ontotext AD
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Troubles with Grails + Maven integration testing

Ian Roberts
On 20/04/2012 17:55, Stefan wrote:

> Why is that? As I've used Spring before Grails there are some cases when
> you have an applicationContext which holds the "application context" and
> you also have a DispatcherServlet context, where you do the URL mapping
> and define the necessary beans. So I think it is natural to have the
> most common or let's say fundamental resources defined in the
> applicationContext and just override/extend it via resources.xml. And as
> the documentation says "/You can easily register new (or override
> existing) beans by configuring them in
> |grails-app/conf/spring/resources.groovy|/", there should be some beans
> defined by me in the applicationContext, right? That's what I mean by my
> own applicationContext.xml.

The root application context (WEB-INF/applicationContext.xml) in Grails
is very minimal, it defines the GrailsApplication and one or two other
supporting objects but everything else goes into the GrailsApplication's
"mainContext" - not only things you define in resources.xml/groovy but
also the beans defined by Grails core and plugins, such as services,
controllers, domain classes etc.  This context is certainly supposed to
be created for integration tests, that's what distinguishes them from
unit tests...

> I'm trying to use GATE embedded into my Grails app, you can see
> http://gate.ac.uk/sale/tao/splitch7.html#x11-1750007.15 if you're
> interested.
> We've used it in many Spring applications, but it just seems that the
> applicationContext isn't loaded at all in the integration-test phase and
> the resources.xml cannot reference beans defined in the applicationContext.

You can put the <gate:init> and friends into resources.xml (or the
equivalent DSL into resources.groovy or a plugin), it doesn't have to go
into the parent applicationContext.xml.  This is how Mímir works and
it's how I've done it in several other (non-open-source) Grails apps.

[Full disclosure - I'm one of the GATE core developers, and the one who
wrote its Spring support in the first place]

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
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: Troubles with Grails + Maven integration testing

Stefan-2
Thanks for the clarifications Ian!

I was puzzled because the app was working properly when deployed to a
webapp container, but just didn't seem into place when running the
integration tests in the Maven build.

By the way I've already tried putting <gate:init> and friends into the
resources.xml only but then it wouldn't run - something was trying to
set gate.home and the other properties twice, which resulted in
IllegalStateExceptions. But maybe I'm doing something wrong.

Thanks anyway,
Stefan

On 20.4.2012 г. 20:16 ч., Ian Roberts wrote:

> On 20/04/2012 17:55, Stefan wrote:
>> Why is that? As I've used Spring before Grails there are some cases when
>> you have an applicationContext which holds the "application context" and
>> you also have a DispatcherServlet context, where you do the URL mapping
>> and define the necessary beans. So I think it is natural to have the
>> most common or let's say fundamental resources defined in the
>> applicationContext and just override/extend it via resources.xml. And as
>> the documentation says "/You can easily register new (or override
>> existing) beans by configuring them in
>> |grails-app/conf/spring/resources.groovy|/", there should be some beans
>> defined by me in the applicationContext, right? That's what I mean by my
>> own applicationContext.xml.
> The root application context (WEB-INF/applicationContext.xml) in Grails
> is very minimal, it defines the GrailsApplication and one or two other
> supporting objects but everything else goes into the GrailsApplication's
> "mainContext" - not only things you define in resources.xml/groovy but
> also the beans defined by Grails core and plugins, such as services,
> controllers, domain classes etc.  This context is certainly supposed to
> be created for integration tests, that's what distinguishes them from
> unit tests...
>
>> I'm trying to use GATE embedded into my Grails app, you can see
>> http://gate.ac.uk/sale/tao/splitch7.html#x11-1750007.15 if you're
>> interested.
>> We've used it in many Spring applications, but it just seems that the
>> applicationContext isn't loaded at all in the integration-test phase and
>> the resources.xml cannot reference beans defined in the applicationContext.
> You can put the<gate:init>  and friends into resources.xml (or the
> equivalent DSL into resources.groovy or a plugin), it doesn't have to go
> into the parent applicationContext.xml.  This is how Mímir works and
> it's how I've done it in several other (non-open-source) Grails apps.
>
> [Full disclosure - I'm one of the GATE core developers, and the one who
> wrote its Spring support in the first place]
>
> Ian
>


--
Stefan Enev<[hidden email]>
Software Engineer
Ontotext AD


---------------------------------------------------------------------
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: Troubles with Grails + Maven integration testing

Stefan-2
Hi Ian,

I still can't make GATE and Grails like each other.

Can you take a look at the applicationContext.xml and resources.xml
which are attached? The relevant part of the Maven log is also attached.

I can't figure out what could possibly try to initialize GATE twice.

Thanks in advance,
Stefan

> On 20.4.2012 г. 20:54 ч., Stefan wrote:
>> Thanks for the clarifications Ian!
>>
>> I was puzzled because the app was working properly when deployed to a
>> webapp container, but just didn't seem into place when running the
>> integration tests in the Maven build.
>>
>> By the way I've already tried putting <gate:init> and friends into
>> the resources.xml only but then it wouldn't run - something was
>> trying to set gate.home and the other properties twice, which
>> resulted in IllegalStateExceptions. But maybe I'm doing something wrong.
>>
>> Thanks anyway,
>> Stefan
>>
>> On 20.4.2012 г. 20:16 ч., Ian Roberts wrote:
>>> On 20/04/2012 17:55, Stefan wrote:
>>>> Why is that? As I've used Spring before Grails there are some cases
>>>> when
>>>> you have an applicationContext which holds the "application
>>>> context" and
>>>> you also have a DispatcherServlet context, where you do the URL
>>>> mapping
>>>> and define the necessary beans. So I think it is natural to have the
>>>> most common or let's say fundamental resources defined in the
>>>> applicationContext and just override/extend it via resources.xml.
>>>> And as
>>>> the documentation says "/You can easily register new (or override
>>>> existing) beans by configuring them in
>>>> |grails-app/conf/spring/resources.groovy|/", there should be some
>>>> beans
>>>> defined by me in the applicationContext, right? That's what I mean
>>>> by my
>>>> own applicationContext.xml.
>>> The root application context (WEB-INF/applicationContext.xml) in Grails
>>> is very minimal, it defines the GrailsApplication and one or two other
>>> supporting objects but everything else goes into the
>>> GrailsApplication's
>>> "mainContext" - not only things you define in resources.xml/groovy but
>>> also the beans defined by Grails core and plugins, such as services,
>>> controllers, domain classes etc.  This context is certainly supposed to
>>> be created for integration tests, that's what distinguishes them from
>>> unit tests...
>>>
>>>> I'm trying to use GATE embedded into my Grails app, you can see
>>>> http://gate.ac.uk/sale/tao/splitch7.html#x11-1750007.15 if you're
>>>> interested.
>>>> We've used it in many Spring applications, but it just seems that the
>>>> applicationContext isn't loaded at all in the integration-test
>>>> phase and
>>>> the resources.xml cannot reference beans defined in the
>>>> applicationContext.
>>> You can put the<gate:init>  and friends into resources.xml (or the
>>> equivalent DSL into resources.groovy or a plugin), it doesn't have
>>> to go
>>> into the parent applicationContext.xml.  This is how Mímir works and
>>> it's how I've done it in several other (non-open-source) Grails apps.
>>>
>>> [Full disclosure - I'm one of the GATE core developers, and the one who
>>> wrote its Spring support in the first place]
>>>
>>> Ian
>>>
>>
>>
>
>

--
Stefan Enev<[hidden email]>
Software Engineer
Ontotext AD



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

    http://xircles.codehaus.org/manage_email

applicationContext.xml (2K) Download Attachment
resources.xml (2K) Download Attachment
mvn.txt (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Troubles with Grails + Maven integration testing

Ian Roberts
On 24/04/2012 19:02, Stefan wrote:
> Hi Ian,
>
> I still can't make GATE and Grails like each other.
>
> Can you take a look at the applicationContext.xml and resources.xml
> which are attached? The relevant part of the Maven log is also attached.
>
> I can't figure out what could possibly try to initialize GATE twice.

I have replied off list, and I suggest we keep the conversation there as
it's unlikely to be of wider interest.

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

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

    http://xircles.codehaus.org/manage_email


Loading...