You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by jo...@exceter.com on 2011/08/23 00:05:31 UTC

iPojo Conundrum

I am looking into using Pax-Exam to run unit tests against iPojo bundles.
However, as a Pax-Exam powered unit test is itself packaged into a bundle
prior to being run I would like to be able to have iPojo inject services
directly into the fields of my JUnit tests. However, I'm not really sure
how this can be done with annotations unless it's already supported by the
ipojo maven plugin because none of the iPojo annotations(by design) have a
runtime retention policy so ipojo components cannot be detected
reflectively. I know I can do it with pure xml configuration but I'd
really prefer to use annotations if at all possible.

My simplest use case is this: I want to be able to annotate fields in my
JUnit tests with @Requires and have iPojo inject dependent services.

Does this functionality already exist or would I have to implement it?

Cheers!
-John



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: iPojo Conundrum

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,


On 23.08.2011, at 00:05, john.dunlap@exceter.com wrote:

> I am looking into using Pax-Exam to run unit tests against iPojo bundles.
> However, as a Pax-Exam powered unit test is itself packaged into a bundle
> prior to being run I would like to be able to have iPojo inject services
> directly into the fields of my JUnit tests. However, I'm not really sure
> how this can be done with annotations unless it's already supported by the
> ipojo maven plugin because none of the iPojo annotations(by design) have a
> runtime retention policy so ipojo components cannot be detected
> reflectively. I know I can do it with pure xml configuration but I'd
> really prefer to use annotations if at all possible.
> 
> My simplest use case is this: I want to be able to annotate fields in my
> JUnit tests with @Requires and have iPojo inject dependent services.
> 
> Does this functionality already exist or would I have to implement it?

I'm not sure it is possible using pure iPOJO. Maybe pax exam contains such annotation, but pax exam tests cannot be iPOJO components (at least not easily).
I generally use http://wiki.chameleon.ow2.org/xwiki/bin/view/Main.Testing/OSGi_Helpers to get my services from my tests.

Regards,

Clement

> 
> Cheers!
> -John
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>