Re: Test-Control injects in test class object only
hi dirk, with my latest commit you can use (basic) injection in @Before and @After callbacks (but you can't use @TestControl there). regards, gerhard 2014/1/6 Dirk Weil > I digged into my problem a bit further: It is not the case – as I though > earlier -, that only some injections are resolved. But: > > > > Within @Before methods all injections are still null. When entering the > tests itself, the injected field are filled. > > My test class is no cdi bean (src/test/META-INF/beans.xml declares > bean-discovery-mode="annotated"), but if I make it a cdi bean, there is no > difference. > > > > Regards > > Dirk > > > > > > > > > > *Von:* Gerhard Petracek [mailto:gerhard.petra...@gmail.com] > *Gesendet:* Freitag, 3. Januar 2014 12:00 > *An:* dev@deltaspike.apache.org > *Betreff:* Re: Test-Control injects in test class object only > > > > short addition: > > > > i've added a test for it and it looks fine here (see [1]). > > > > fyi - basically there are two "modes": > > #1 the test-class is a cdi-bean as well > (src/test/resources/META-INF/beans.xml is needed) > > #2 the test-class isn't a cdi-bean (due to a missing beans.xml or @Typed() > or @Exclude,...) -> BeanProvider#injectFields is used as fallback > > > > regards, > > gerhard > > > > [1] > https://git-wip-us.apache.org/repos/asf?p=deltaspike.git;a=commit;h=4939550ed208c4e6be98ee12e6019ebe7d271afd > > > > > > > > 2014/1/3 Gerhard Petracek > > hi dirk, > > > > deltaspike just delegates the injection to the cdi-container. > > > > regards, > > gerhard > > > > > > > > 2014/1/3 Dirk Weil > > Hi! > > > > I've just come around Test-Control - great module, simplifies in-container > testing a lot. But I discovered one thing and I'm not sure if it's intended > or a bug: > > > > @Inject is resolved for fields of the test class object itself only, not > for > fields of base classes. As a workaround I use > BeanProvider.injectFields(this), but I would expect injections to be > resolved automatically for the test class object as a whole, not just for > the derived class part. > > > > Regards, Dirk > > > > >
Re: Test-Control injects in test class object only
Right, injection through arquillian happens after all the @Before and @BeforeClass hooks. On Mon, Jan 6, 2014 at 2:50 PM, Dirk Weil wrote: > I digged into my problem a bit further: It is not the case – as I though > earlier -, that only some injections are resolved. But: > > > > Within @Before methods all injections are still null. When entering the > tests itself, the injected field are filled. > > My test class is no cdi bean (src/test/META-INF/beans.xml declares > bean-discovery-mode="annotated"), but if I make it a cdi bean, there is no > difference. > > > > Regards > > Dirk > > > > > > > > > > *Von:* Gerhard Petracek [mailto:gerhard.petra...@gmail.com] > *Gesendet:* Freitag, 3. Januar 2014 12:00 > *An:* dev@deltaspike.apache.org > *Betreff:* Re: Test-Control injects in test class object only > > > > short addition: > > > > i've added a test for it and it looks fine here (see [1]). > > > > fyi - basically there are two "modes": > > #1 the test-class is a cdi-bean as well > (src/test/resources/META-INF/beans.xml is needed) > > #2 the test-class isn't a cdi-bean (due to a missing beans.xml or @Typed() > or @Exclude,...) -> BeanProvider#injectFields is used as fallback > > > > regards, > > gerhard > > > > [1] > https://git-wip-us.apache.org/repos/asf?p=deltaspike.git;a=commit;h=4939550ed208c4e6be98ee12e6019ebe7d271afd > > > > > > > > 2014/1/3 Gerhard Petracek > > hi dirk, > > > > deltaspike just delegates the injection to the cdi-container. > > > > regards, > > gerhard > > > > > > > > 2014/1/3 Dirk Weil > > Hi! > > > > I've just come around Test-Control - great module, simplifies in-container > testing a lot. But I discovered one thing and I'm not sure if it's intended > or a bug: > > > > @Inject is resolved for fields of the test class object itself only, not > for > fields of base classes. As a workaround I use > BeanProvider.injectFields(this), but I would expect injections to be > resolved automatically for the test class object as a whole, not just for > the derived class part. > > > > Regards, Dirk > > > > > -- Jason Porter http://en.gravatar.com/lightguardjp
AW: Test-Control injects in test class object only
I digged into my problem a bit further: It is not the case - as I though earlier -, that only some injections are resolved. But: Within @Before methods all injections are still null. When entering the tests itself, the injected field are filled. My test class is no cdi bean (src/test/META-INF/beans.xml declares bean-discovery-mode="annotated"), but if I make it a cdi bean, there is no difference. Regards Dirk Von: Gerhard Petracek [mailto:gerhard.petra...@gmail.com] Gesendet: Freitag, 3. Januar 2014 12:00 An: dev@deltaspike.apache.org Betreff: Re: Test-Control injects in test class object only short addition: i've added a test for it and it looks fine here (see [1]). fyi - basically there are two "modes": #1 the test-class is a cdi-bean as well (src/test/resources/META-INF/beans.xml is needed) #2 the test-class isn't a cdi-bean (due to a missing beans.xml or @Typed() or @Exclude,...) -> BeanProvider#injectFields is used as fallback regards, gerhard [1] https://git-wip-us.apache.org/repos/asf?p=deltaspike.git;a=commit;h=4939550e d208c4e6be98ee12e6019ebe7d271afd 2014/1/3 Gerhard Petracek hi dirk, deltaspike just delegates the injection to the cdi-container. regards, gerhard 2014/1/3 Dirk Weil Hi! I've just come around Test-Control - great module, simplifies in-container testing a lot. But I discovered one thing and I'm not sure if it's intended or a bug: @Inject is resolved for fields of the test class object itself only, not for fields of base classes. As a workaround I use BeanProvider.injectFields(this), but I would expect injections to be resolved automatically for the test class object as a whole, not just for the derived class part. Regards, Dirk http://xmlns.jcp.org/xml/ns/javaee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"; bean-discovery-mode="annotated" version="1.1">
Re: Test-Control injects in test class object only
short addition: i've added a test for it and it looks fine here (see [1]). fyi - basically there are two "modes": #1 the test-class is a cdi-bean as well (src/test/resources/META-INF/beans.xml is needed) #2 the test-class isn't a cdi-bean (due to a missing beans.xml or @Typed() or @Exclude,...) -> BeanProvider#injectFields is used as fallback regards, gerhard [1] https://git-wip-us.apache.org/repos/asf?p=deltaspike.git;a=commit;h=4939550ed208c4e6be98ee12e6019ebe7d271afd 2014/1/3 Gerhard Petracek > hi dirk, > > deltaspike just delegates the injection to the cdi-container. > > regards, > gerhard > > > > 2014/1/3 Dirk Weil > >> Hi! >> >> >> >> I've just come around Test-Control - great module, simplifies in-container >> testing a lot. But I discovered one thing and I'm not sure if it's >> intended >> or a bug: >> >> >> >> @Inject is resolved for fields of the test class object itself only, not >> for >> fields of base classes. As a workaround I use >> BeanProvider.injectFields(this), but I would expect injections to be >> resolved automatically for the test class object as a whole, not just for >> the derived class part. >> >> >> >> Regards, Dirk >> >> >
Re: Test-Control injects in test class object only
hi dirk, deltaspike just delegates the injection to the cdi-container. regards, gerhard 2014/1/3 Dirk Weil > Hi! > > > > I've just come around Test-Control - great module, simplifies in-container > testing a lot. But I discovered one thing and I'm not sure if it's intended > or a bug: > > > > @Inject is resolved for fields of the test class object itself only, not > for > fields of base classes. As a workaround I use > BeanProvider.injectFields(this), but I would expect injections to be > resolved automatically for the test class object as a whole, not just for > the derived class part. > > > > Regards, Dirk > >
Test-Control injects in test class object only
Hi! I've just come around Test-Control - great module, simplifies in-container testing a lot. But I discovered one thing and I'm not sure if it's intended or a bug: @Inject is resolved for fields of the test class object itself only, not for fields of base classes. As a workaround I use BeanProvider.injectFields(this), but I would expect injections to be resolved automatically for the test class object as a whole, not just for the derived class part. Regards, Dirk