1 Reply Latest reply on Jun 10, 2013 11:21 PM by Martin Varga

    JSFUnit + TestNG + Arquillian on JBoss 7, Could not inject method parameters

    Martin Varga Newbie

      I am using Arquillian for some time now. Successfuly migrated EJB, MBeans and some Seam integration tests. I am having problems with JSF tests though. I am looking for the FacesRequest (from SeamTest) replacement. I have tried JSFUnit, but without success. The only thing I really need is to get JSFSession, which I am not getting due to HttpSession being null. That results in:


      Caused by: java.lang.NullPointerException
          at org.jboss.jsfunit.arquillian.container.JSFUnitSessionFactory.findJSFSession(JSFUnitSessionFactory.java:85)
          at org.jboss.jsfunit.arquillian.container.JSFUnitSessionFactory.getJSFServerSession(JSFUnitSessionFactory.java:70)
          at org.jboss.jsfunit.arquillian.container.JSFUnitTestEnricher.resolve(JSFUnitTestEnricher.java:84)
          ... 85 more


      And that of course ends with test result like this:


      Could not inject method parameters


      Here are the relevant parts of my code:




          <defaultProtocol type="Servlet 3.0"></defaultProtocol>    <container qualifier="jboss7" default="true">
      ...        </configuration>


      MyTest class

      public class MyTest extends Arquillian {
          public static EnterpriseArchive createDeployment() {
              EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "myear.ear");
              final WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
              return ear;
          @Test(dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER)
          public void testOne(JSFServerSession server, JSFClientSession client)
                  throws IOException {
              System.out.println("inside JSFUNIT unit one");


      I have tried to set @InitialPage value to


      /test/index.faces, /test/index.xhtml, /index.faces, /index.xhtml, / and ""


      None of these work.


      web.xml, faces-config.xml, jboss-deployment-structure.xml

      web.xml is pretty standard sample-jsf web.xml (mapping the servlet to *.faces), faces-config.xml has empty <faces-config> tag just with version and jboss descriptor simply adds jsf dependencies



      Attached is my complete project stripped down to a bare minimum. I had to play a bit with the dependencies, because I am using Arquillian 1.0.3.Final, which doesn't play very well with JSFUnit 2.0.0.Beta2. Don't mind the project name, there is no seam (anymore).


      Any help with my setup will be appreaciated. Also  any other way how to simply replace FacesRequest testing is welcome. Thanks.

        • 1. Re: JSFUnit + TestNG + Arquillian on JBoss 7, Could not inject method parameters
          Martin Varga Newbie

          I have finally found a solution to this problem. JSFUnit expects certain filters to be running. Using `Servet 3.0` protocol, these should be added automatically. But they are not. That's why I am not getting injected anything.


          I have downloaded JSFUnit Arquillian integration sources and found what needs to be added:




          Added it manually to your `web.xml` and everything worked as expected. Here is the relevant part: