1 Reply Latest reply on Jul 6, 2011 4:34 PM by Wolfgang Knauf

    Getting example to work (JSFUnit2.0Beta1/Jetty7/Arquillian1.0.0.Alpha4)

    Anton Su Newbie

      Hi, all!

      I have been struggling with JSFUnit this week and actually have no appropriate results. I would appreciate if you can help me.

       

      Right now I`m getting error:

      Jul 1, 2011 12:14:22 PM org.jboss.arquillian.impl.XmlConfigurationBuilder loadArquillianConfiguration
      INFO: building configuration from XML file: arquillian.xml
      Jul 1, 2011 12:14:22 PM org.jboss.arquillian.impl.XmlConfigurationBuilder matchContainerConfiguration
      WARNING: No container configuration found for URI: java:urn:org.jboss.arquillian.container.jetty.embedded_7
      
      java.lang.NullPointerException
          at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:88)
          at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:77)
          at org.jboss.arquillian.junit.Arquillian.<init>(Arquillian.java:85)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
          at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
          at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
          at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
          at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
          at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
          at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32)
          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      

      Here is example webapp which I`m trying to test.

       

      Test:

      @RunWith(Arquillian.class)
      public class RegisterTest {
          @Deployment
             public static WebArchive createDeployment() {
                WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
                      .setWebXML(new File("src/resources/test/web/WEB-INF/web-test.xml"))
                      .addPackage(Package.getPackage("com/gl/sa/karmacounter/jsfcontroller"))
                      .addAsWebResource(new File("src/resources/production/web/WEB-INF/register.jsf"))
                      .addAsWebInfResource(new File("src/resources/production/web/WEB-INF/applicationContext.xml"), "beans.xml")//Spring beans definitions
                      .addAsWebInfResource(new File("src/resources/production/web/WEB-INF/faces-config.xml"), "faces-config.xml");
      
                System.out.println(war.toString(true));
                return war;
             }
      
          @Test
          @InitialPage("/register.faces")
          public void testItShouldAcceptValidAccount(JSFServerSession serverSession, JSFClientSession clientSession) throws Exception {
              clientSession.setValue("name", "Anton Su");
              clientSession.click("submit");
      
              assertEquals(serverSession.getManagedBeanValue("#{registrationController.user.name}"),"Anton Su");
          }
      }
      

       

      arquillian.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <arquillian xmlns="http://jboss.com/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:jboss="urn:arq:org.jboss.arquillian.container.jetty.embedded_7">
      
          <jboss:container qualifier="jetty" default="true">
              <configuration>
                  <property name="bindHttpPort">33333</property>
              </configuration>
          </jboss:container>
      </arquillian>
      

       

      web-test.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      
          <filter>
            <filter-name>JSFUnitCleanupTestTreadFilter</filter-name>
            <filter-class>org.jboss.jsfunit.arquillian.container.JSFUnitCleanupTestTreadFilter</filter-class>
          </filter>
      
          <filter>
            <filter-name>JSFUnitFilter</filter-name>
            <filter-class>org.jboss.jsfunit.framework.JSFUnitFilter</filter-class>
          </filter>
      
          <filter-mapping>
            <filter-name>JSFUnitCleanupTestTreadFilter</filter-name>
            <url-pattern>/ArquillianServletRunner</url-pattern>
          </filter-mapping>    
      
          <filter-mapping>
            <filter-name>JSFUnitFilter</filter-name>
            <url-pattern>/ArquillianServletRunner</url-pattern>
          </filter-mapping>
      
          <context-param>
              <param-name>contextConfigLocation</param-name>
              <param-value>WEB-INF/applicationContext.xml</param-value>
          </context-param>
      
          <listener>
              <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
          </listener>
      
          <listener>
              <listener-class>
                  org.springframework.web.context.request.RequestContextListener</listener-class>
          </listener>
      
          <!-- Listener, to allow Jetty serving MyFaces apps -->
          <listener>
              <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
          </listener>
      
          <servlet>
              <servlet-name>Faces Servlet</servlet-name>
              <!-- <servlet-class>org.apache.myfaces.webapp.MyFacesServlet</servlet-class> -->
              <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
              <load-on-startup>1</load-on-startup>
          </servlet>
      
          <servlet-mapping>
              <servlet-name>Faces Servlet</servlet-name>
              <url-pattern>*.faces</url-pattern>
          </servlet-mapping>
      </web-app>
      

       

      Libs

      myfaces-api-1.2.10.jar
      myfaces-impl-1.2.10.jar
      servlet-api-2.5.jar
      arquillian-api-1.0.0.Alpha4.jar
      arquillian-impl-base-1.0.0.Alpha4.jar
      arquillian-jetty-embedded-7-1.0.0-20110426.081900-79.jar
      arquillian-junit-1.0.0.Alpha4.jar
      arquillian-spi-1.0.0.Alpha4.jar
      cdi-api-1.0-SP1.jar
      jboss-jsfunit-core-2.0.0.Beta1.jar
      jsfunit-arquillian-2.0.0.Beta1.jar
      jsr250-api-1.0.jar
      shrinkwrap-api-1.0.0-alpha-12.jar
      shrinkwrap-descriptors-api-0.1.4.jar
      junit-4.8.2.jar
      jetty-*-7.4.2.v20110526.jars
      ...
      

       

      As I understand it is missing some jetty config file am I right? If yes what file & where I should locate it.

      Thanks in advance.