CDI unit test

2015-12-03 Thread Felipe Jaekel
Hi, I believe this was already discussed on this list, but I didn't found the topic on google. I'm able to test EJBs using the EJBContainer as mentioned on TomEE examples. But when I try to test a CDI bean I'm getting a UnsatisfiedResolutionException. I tried to add a beans.xml to /src/test/res

Re: CDI unit test

2015-12-03 Thread Romain Manni-Bucau
Hi 2015-12-03 20:43 GMT+01:00 Felipe Jaekel : > Hi, > > I believe this was already discussed on this list, but I didn't found the > topic on google. > > I'm able to test EJBs using the EJBContainer as mentioned on TomEE > examples. > > But when I try to test a CDI bean I'm getting a > Unsatisfied

Re: CDI unit test

2015-12-04 Thread Felipe Jaekel
Adding beans.xml to main/resources/META-INF solved the problem, thanks. Regular CDI scoped beans are working fine, but I would like also to test javax.faces.view.ViewScoped beans. Is it possible? javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @Vi

Re: CDI unit test

2015-12-04 Thread Romain Manni-Bucau
Hi sure, you just need to start/stop the context using WebBeansContext.current().getContextsService() then you have start/stop and you pass ViewScoped.class as scope type. Romain Manni-Bucau @rmannibucau | Blog | Github

Re: CDI unit test

2015-12-04 Thread Felipe Jaekel
Hi, Tried it with tomee-embedded 7.0.0-SNAPSHOT, this was the output: ADVERTÊNCIA - CDI-OpenWebBeans container does not support context scope ViewScoped. Scopes @Dependent, @RequestScoped, @ApplicationScoped and @Singleton are supported scope types INFORMAÇÕES - Stopping network services INFORMAÇ

Re: CDI unit test

2015-12-04 Thread Romain Manni-Bucau
Tempted to copy paste my previous answer without more details. Romain Manni-Bucau @rmannibucau | Blog | Github | LinkedIn | Tomitriber

Re: CDI unit test

2015-12-04 Thread Felipe Jaekel
Sorry but I don't follow what is so obvious that I'm missing... I added the line WebBeansContext.currentInstance().getContextsService().startContext(ViewScoped.class, null); But tomee-embedded 1.7.2 and 7.0.0-SNAPSHOT leads to this message: CDI-OpenWebBeans container does not support context scop

Re: CDI unit test

2015-12-04 Thread Romain Manni-Bucau
did you add it in the request you do - same thread? FacesContext.getCurrentInstance(); needs to be active Romain Manni-Bucau @rmannibucau | Blog | Github | LinkedIn

Re: CDI unit test

2015-12-05 Thread Mark Struberg
ViewScope is _not_ part of the CDI spec. Thus ContextsService wont help you here. This is only for OWB internal Contexts. You need to use the ‚owner‘ of the Context if you like control it’s lifecycle. This depends on whether you have @ManagedBean @ViewScoped (which would be a JSF managed ViewS

Re: CDI unit test

2015-12-05 Thread Romain Manni-Bucau
Isnt it an "AbstractContext" so you can active getting it from bm? Le 5 déc. 2015 20:05, "Mark Struberg" a écrit : > ViewScope is _not_ part of the CDI spec. Thus ContextsService wont help > you here. This is only for OWB internal Contexts. > > You need to use the ‚owner‘ of the Context if you li

Re: CDI unit test

2015-12-07 Thread Felipe Jaekel
To start the FacesContext I added myfaces-test22 dependecy and changed EjbContainerTest to extend AbstractViewControllerTestCase. With *@javax.faces.bean.ManagedBean + @javax.faces.bean.ViewScoped* it works, but with *@javax.inject.Named + @javax.faces.view.ViewScoped* I'm getting a *java.lang.Cla

Re: CDI unit test

2015-12-07 Thread Romain Manni-Bucau
sounds like a conflict between jsf api and impl. If you use both api and impl of myfaces 2.2.8 then you cant get this exception. Romain Manni-Bucau @rmannibucau | Blog | Github | LinkedIn

Re: CDI unit test

2015-12-07 Thread Felipe Jaekel
They are both 2.2.8. I tested with 1.7.2 and 7.0.0-SNAPSHOT. With 1.7.2 I added the dependency with test scope to replace 2.1.17. With 7.0.0-SNAPSHOT I let it pull 2.2.8 automatically. I checked with Eclipse dependency hierarchy tool to see if there was another version. I also tried 1.7.2 + MyFa

Re: CDI unit test

2015-12-07 Thread Romain Manni-Bucau
Myfaces API pick up the proxy map implementation in a hardcoded fashion. I dont see if you have the right classpath how it can fail this way. Can you push to github your project to try to reproduce it there? Romain Manni-Bucau @rmannibucau | Blog

Re: CDI unit test

2015-12-08 Thread Mark Struberg
+1 for a sample please. Then it will be pretty easy to identify your problem. txs and LieGrue, strub > Am 07.12.2015 um 20:37 schrieb Romain Manni-Bucau : > > Myfaces API pick up the proxy map implementation in a hardcoded fashion. I > dont see if you have the right classpath how it can fail thi

Re: CDI unit test

2015-12-08 Thread Felipe Jaekel
Done: https://github.com/fkjaekel/CdiViewScopeTest Thanks for your time 2015-12-08 7:38 GMT-02:00 Mark Struberg : > +1 for a sample please. Then it will be pretty easy to identify your > problem. > > txs and LieGrue, > strub > > > Am 07.12.2015 um 20:37 schrieb Romain Manni-Bucau >: > > > > Myf

Re: CDI unit test

2015-12-08 Thread Romain Manni-Bucau
Sure you use myfaces api? ;) javax.faces javax.faces-api 2.2 provided should be org.apache.myfaces.core myfaces-api 2.2.8 provided JSF is a spec where the API chan't be exchanged between implementations. Romain Manni-Bucau @rmannibucau

Re: CDI unit test

2015-12-08 Thread Felipe Jaekel
Thought that the provided scope wouldn't interfere on tests. My idea with the javax.faces-api was to avoid compilation problems, as in production MyFaces libs are inside TomEE lib folder. Another pitfall is that I thought that Mojarra api dependency would be this: com.sun.faces jsf-api 2.2.12 G