NullPointerException - getCurrentViewID
mausbull Mar 4, 2011 5:18 AMHi,
I'm currently trying to include JSFUnit into my JEE6, Seam3, Richfaces, Arquillian project.
I was able to run the getting stated example described at http://community.jboss.org/wiki/JSFUnit200GettingStartedExample.
However, when I include this test into my project I get a NullPointerException
testInitialPage(at.icbi.seqbench.jsfunit.HelloJSFTest) Time elapsed: 2,664.141 sec <<< ERROR! java.lang.NullPointerException at org.jboss.jsfunit.jsfsession.JSFServerSession.getCurrentViewID(JSFServerSession.java:79) at at.icbi.seqbench.jsfunit.HelloJSFTest.testInitialPage(HelloJSFTest.java:56) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
Specifically, the attributes clientIDs and currentFacesContext are null in JSFServerSession server.
Test class looks as follows:
@RunWith(Arquillian.class) public class HelloJSFTest { @Deployment public static WebArchive createDeployment() { Class clazz = org.jboss.jsfunit.cdi.InitialPage.class; WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war") .setWebXML(new File("src/test/resources/jsf/web.xml")) .addPackage(Package.getPackage("at.icbi.seqbench.jsfunit")) // my test package .addResource(new File("src/test/resources/jsf", "index.xhtml")).addWebResource(EmptyAsset.INSTANCE, "beans.xml") .addWebResource(new File("src/test/resources/jsf/faces-config.xml"), "faces-config.xml") .addManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml")); return war; } @Test @InitialPage("/index.faces") public void testInitialPage(JSFServerSession server, JSFClientSession client) throws IOException { // Test navigation to initial viewID Assert.assertEquals("/index.xhtml", server.getCurrentViewID()); // Set the param and submit client.setValue("name", "MyName"); client.click("submit_button"); // Assert that the greeting component is in the component tree and rendered UIComponent greeting = server.findComponent("greeting"); Assert.assertTrue(greeting.isRendered()); // Test a managed bean using EL. We cheat and use the request object. Assert.assertEquals("MyName", server.getManagedBeanValue("#{request.getParameter('form1:name')}")); } }
Does anybody have a hint for my problem?
Thanks,
Stephan