1

I'm using joinfaces v3 from some time. But I'm experiencing problems regarding tests about the viewScoped beans.

In the documentation I saw that the equivalent spring scope of ViewScoped annotation is configured automatically by Jsf Spring Boot Starter

But when I try to test a @Component with one of the following annotations @Scope("view") @ViewScoped

I always get a nullPointer on the class org.joinfaces.autoconfigure.integration.ViewScope in the following line

FacesContext.getCurrentInstance().getViewRoot().getViewMap()

because FacesContext.getCurrentInstance is null

Do we have an example on how to test this kind of beans with joinfaces? Thank you

Gavi
  • 1,300
  • 1
  • 19
  • 39
  • So you can test something like this when not using joinfaces? – Kukeltje Feb 15 '18 at 09:08
  • Yes. I'm switching from a java maven project to spring boot in order to use some features that comes easily with spring boot. And I've a lot of tests that involve classes with the Scope "view". – Gavi Feb 15 '18 at 18:31
  • FYI: spring boot is Java too. And SpringBoot and Maven serve two different purposes. Adding SpringBoot as a tag and making more clear what and how you test is the best way forward – Kukeltje Feb 15 '18 at 18:47

2 Answers2

0

On The Joinfaces documentation there's an example on how to test some jsf bean. Maybe is useful for someone

Gavi
  • 1,300
  • 1
  • 19
  • 39
0

JoinFaces Bean Test library is probably what you are looking for. See discussion here.

Another possibility is using joinfaces test mock classes.