You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Gerald Preissler <gp...@talend.com> on 2012/06/25 17:38:31 UTC

Best way to test blueprint-based applications with Karaf?

Hi there,

I've started to work on a blueprint-based application, and basically the subject already says what I'm looking for :-) I googled around a little bit and found the following two blogposts that seem interesting:

http://iocanel.blogspot.de/2012/01/advanced-integration-testing-with-pax.html

http://gnodet.blogspot.de/2012/01/unit-testing-camel-blueprint-routes.html

The library provided by Guillaume looks like a possible solution, but I'd like to ask if there is anything that I overlooked in my search and that might be helpful when testing blueprint contexts

Any other suggestions or hints regarding the topic are highly welcome as well.

Best regards

    Jerry

Re: Best way to test blueprint-based applications with Karaf?

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi Gerald,

that's exactly what I did, though I didn't find the reason why it
works in Karaf
but not with pax exam standalone :)
It looks more to be some tricky thing about bootloader and declaration of system
loaders. Since in Karaf the javax.persistence packages are configured to be
system packages (and AFAIRC bootloaded). I'm quite unhappy about this right now
since it still requires three potential sources for javax.persistence
aries-jpa, geronimo-jpa spec and the jre as system package.

Regards, Achim

2012/6/26 Gerald Preissler <gp...@talend.com>:
> Hi Achim,
>
> thanks for the insight. Guess I'll go down the route you suggested, at
> least until I find some time at my hand to do some more experimentation.
>
> Regards
>     Jerry
>
> p.s. The classloading issue you describe below could stem from the fact
> that one bundle gets passed an object that implements an interface from
> one bundle, but resolves the interface definition from another bundle,
> maybe even itself. Maybe you could try setting a breakpoint at the code
> location and compare the classloaders?
>
> On 06/25/2012 05:52 PM, Achim Nierbeck wrote:
>> Hi Gerald,
>>
>> I suggest sticking to testing with pax-exam or even better using paxexam-karaf.
>> I have the following reasons for this :)
>>
>> If you want to use blueprint jpa or something like this, I experienced
>> trouble with pojoSR not being capable of providing some needed
>> functionality for the jpa part of blueprint.
>> It uses some internal OSGi method which resolves to a null-pointer
>> exception. So this is not really capable for doing intense tests right
>> now.
>> (if I find some time I might add some patches :) )
>> But it's good enough to test some basic blueprint wiring stuff.
>>
>> pax-exam is far better in usage since it really starts a container
>> though this might increase the timing on the test.
>> Though this can be some troublesome to get all required bundles
>> working together this way. It needs some trial and error
>> to have the right set of bundles available :)
>> Though right now I also face an issue with this setup and
>> blueprint:jpa. A rather strange Classcast excpetion.
>> Somehow the javax.persistence Classes used by blueprint-jpa while
>> instanciating the Entity objects is not the same when
>> trying to find the corresponding meta-data. Somehow the Entity class
>> used in both cases are not the same (classloader issue :( )
>>
>> Now finally if you use paxexam-karaf you have all the required bundles
>> at hand and if you use jpa
>> it magically seems to work right away (no idea what the difference is
>> right now, still investigating :) )
>> And of course if you are gonna use specialties in setup etc. this
>> test-framework gives you just
>> the right amount of power to get along :)
>>
>> Hope this helps some :)
>>
>> regards, Achim
>>
>> 2012/6/25 Gerald Preissler <gp...@talend.com>:
>>



-- 

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
Committer & Project Lead
OPS4J Pax for Vaadin
<http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & Project
Lead
blog <http://notizblog.nierbeck.de/>

Re: Best way to test blueprint-based applications with Karaf?

Posted by Gerald Preissler <gp...@talend.com>.
Hi Achim,

thanks for the insight. Guess I'll go down the route you suggested, at 
least until I find some time at my hand to do some more experimentation.

Regards
     Jerry

p.s. The classloading issue you describe below could stem from the fact 
that one bundle gets passed an object that implements an interface from 
one bundle, but resolves the interface definition from another bundle, 
maybe even itself. Maybe you could try setting a breakpoint at the code 
location and compare the classloaders?

On 06/25/2012 05:52 PM, Achim Nierbeck wrote:
> Hi Gerald,
>
> I suggest sticking to testing with pax-exam or even better using paxexam-karaf.
> I have the following reasons for this :)
>
> If you want to use blueprint jpa or something like this, I experienced
> trouble with pojoSR not being capable of providing some needed
> functionality for the jpa part of blueprint.
> It uses some internal OSGi method which resolves to a null-pointer
> exception. So this is not really capable for doing intense tests right
> now.
> (if I find some time I might add some patches :) )
> But it's good enough to test some basic blueprint wiring stuff.
>
> pax-exam is far better in usage since it really starts a container
> though this might increase the timing on the test.
> Though this can be some troublesome to get all required bundles
> working together this way. It needs some trial and error
> to have the right set of bundles available :)
> Though right now I also face an issue with this setup and
> blueprint:jpa. A rather strange Classcast excpetion.
> Somehow the javax.persistence Classes used by blueprint-jpa while
> instanciating the Entity objects is not the same when
> trying to find the corresponding meta-data. Somehow the Entity class
> used in both cases are not the same (classloader issue :( )
>
> Now finally if you use paxexam-karaf you have all the required bundles
> at hand and if you use jpa
> it magically seems to work right away (no idea what the difference is
> right now, still investigating :) )
> And of course if you are gonna use specialties in setup etc. this
> test-framework gives you just
> the right amount of power to get along :)
>
> Hope this helps some :)
>
> regards, Achim
>
> 2012/6/25 Gerald Preissler <gp...@talend.com>:
>

Re: Best way to test blueprint-based applications with Karaf?

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi Gerald,

I suggest sticking to testing with pax-exam or even better using paxexam-karaf.
I have the following reasons for this :)

If you want to use blueprint jpa or something like this, I experienced
trouble with pojoSR not being capable of providing some needed
functionality for the jpa part of blueprint.
It uses some internal OSGi method which resolves to a null-pointer
exception. So this is not really capable for doing intense tests right
now.
(if I find some time I might add some patches :) )
But it's good enough to test some basic blueprint wiring stuff.

pax-exam is far better in usage since it really starts a container
though this might increase the timing on the test.
Though this can be some troublesome to get all required bundles
working together this way. It needs some trial and error
to have the right set of bundles available :)
Though right now I also face an issue with this setup and
blueprint:jpa. A rather strange Classcast excpetion.
Somehow the javax.persistence Classes used by blueprint-jpa while
instanciating the Entity objects is not the same when
trying to find the corresponding meta-data. Somehow the Entity class
used in both cases are not the same (classloader issue :( )

Now finally if you use paxexam-karaf you have all the required bundles
at hand and if you use jpa
it magically seems to work right away (no idea what the difference is
right now, still investigating :) )
And of course if you are gonna use specialties in setup etc. this
test-framework gives you just
the right amount of power to get along :)

Hope this helps some :)

regards, Achim

2012/6/25 Gerald Preissler <gp...@talend.com>:
> Hi there,
>
> I've started to work on a blueprint-based application, and basically the
> subject already says what I'm looking for :-) I googled around a little bit
> and found the following two blogposts that seem interesting:
>
> http://iocanel.blogspot.de/2012/01/advanced-integration-testing-with-pax.html
>
> http://gnodet.blogspot.de/2012/01/unit-testing-camel-blueprint-routes.html
>
> The library provided by Guillaume looks like a possible solution, but I'd
> like to ask if there is anything that I overlooked in my search and that
> might be helpful when testing blueprint contexts
>
> Any other suggestions or hints regarding the topic are highly welcome as
> well.
>
> Best regards
>
>     Jerry



-- 

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
Committer & Project Lead
OPS4J Pax for Vaadin
<http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & Project
Lead
blog <http://notizblog.nierbeck.de/>