pushed with a small bonus: @Scopes to do it on methods

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le jeu. 20 sept. 2018 à 13:41, Waldemar Reusch
<waldemar.reu...@googlemail.com.invalid> a écrit :

> I'm cool with you fixing it straight. Otherwise I'd have to see if I can
> get the whole development environment going and I'm not too keep to
> reinstall svn to be honest =D
> best,
> Waldemar
>
> On Mon, Sep 17, 2018 at 2:12 PM Romain Manni-Bucau <rmannibu...@gmail.com>
> wrote:
>
> > PS: until it is fixed you can use org.apache.meecrowave.junit.ScopeRule
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <https://rmannibucau.metawerx.net/> | Old Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> > <
> >
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> > >
> >
> >
> > Le lun. 17 sept. 2018 à 14:11, Romain Manni-Bucau <rmannibu...@gmail.com
> >
> > a
> > écrit :
> >
> > > Hi Waldemar,
> > >
> > > this is right, do you want to submit a PR to fix it or do you prefer we
> > > fix it straight?
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <https://rmannibucau.metawerx.net/> | Old Blog
> > > <http://rmannibucau.wordpress.com> | Github
> > > <https://github.com/rmannibucau> | LinkedIn
> > > <https://www.linkedin.com/in/rmannibucau> | Book
> > > <
> >
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> > >
> > >
> > >
> > > Le lun. 17 sept. 2018 à 14:03, Waldemar Reusch
> > > <waldemar.reu...@googlemail.com.invalid> a écrit :
> > >
> > >> Hey guys,
> > >>
> > >> first time on a mailing list, please bear with me.
> > >>
> > >> I was trying to test request scoped beans using meecrowave-junit, and
> > the
> > >> test kept crashing with the following exception:
> > >>
> > >> javax.enterprise.context.ContextNotActiveException: WebBeans context
> > with
> > >> scope type annotation @RequestScoped does not exist within current
> > thread
> > >> at
> > >>
> > >>
> >
> org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:329)
> > >> at
> > >>
> > >>
> >
> org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:89)
> > >> at
> > >>
> > >>
> >
> org.apache.webbeans.intercept.RequestScopedBeanInterceptorHandler.getContextualInstance(RequestScopedBeanInterceptorHandler.java:76)
> > >> at
> > >>
> > >>
> >
> org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:71)
> > >> ...
> > >>
> > >> While digging, I came across MeecrowaveExtension:getScopes, and while
> > >> stepping through I'm realizing that the returned optional will always
> > >> contain null, because
> > >> - this method is only called in beforeEach, afterEach, therefore
> > >> context.getElement() will always return a method instance
> > >> - method instances will never have a MeecrowaveConfig annotation,
> since
> > >> that annotation is only allowed for types (MeecrowaveConfig:L35)
> > >>
> > >> Overriding the MeecrowaveConfig annotation with a local copy which has
> > the
> > >> annotation targets {TYPE, METHOD} (instead of TYPE only) allows me to
> > >> annotate the tested method with @MeecrowaveConfig(scopes =
> > >> RequestScoped.class), which seems to be the intended behavior.
> > >>
> > >> Is this a known bug? Or am I missing something else?
> > >>
> > >> best,
> > >> Waldemar
> > >>
> > >
> >
>

Reply via email to