JSFUnit + TestNG + Arquillian on JBoss 7, Could not inject method parameters
sm4 Jun 10, 2013 6:09 AMI 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:
arquillian.xml
<defaultProtocol type="Servlet 3.0"></defaultProtocol> <container qualifier="jboss7" default="true"> <configuration> ... </configuration>
MyTest class
public class MyTest extends Arquillian { @Deployment public static EnterpriseArchive createDeployment() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "myear.ear"); ear.addAsManifestResource("jboss-deployment-structure.xml"); final WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war") .addAsWebInfResource("WEB-INF/faces-config.xml") .addAsWebInfResource("WEB-INF/web.xml") .addClass(MyTest.class) .addAsWebResource("index.xhtml"); ear.addAsModule(Testable.archiveToTest(war)); return ear; } @Test(dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER) @InitialPage("/test/index.faces") 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.
-
jsfunit-seam-test.zip 5.9 KB