0 Replies Latest reply: Mar 30, 2012 4:48 AM by Silvestre Losada RSS

Error running jsfunit test.

Silvestre Losada Newbie

Hi all I'm trying to run a jsfunit test using arquillian, I'm geting next exception. The problem is while it is parsing some css file, but is no enough information about the file and the error

 

Caused by: com.gargoylesoftware.htmlunit.ScriptException: Index: 0, Size: 0
          at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:601)
          at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537)
          at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538)
          at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:499)
          at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:970)
          at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:363)
          at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:235)
          at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:245)
          at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:578)
          at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
          at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:536)
          at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1136)
          at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1038)
          at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206)
          at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:329)
          at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:2999)
          at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:1991)
          at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:895)
          at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499)
          at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452)
          at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
          at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:765)
          at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:211)
          at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:165)
          at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:225)
          at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:108)
          at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:429)
          at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:307)
          at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:369)
          at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:354)
          at org.jboss.jsfunit.framework.SimpleInitialRequestStrategy.doInitialRequest(SimpleInitialRequestStrategy.java:48)
          at org.jboss.jsfunit.framework.WebClientSpec.doInitialRequest(WebClientSpec.java:259)
          at org.jboss.jsfunit.jsfsession.JSFSession.<init>(JSFSession.java:81)
          at org.jboss.jsfunit.arquillian.container.JSFUnitSessionFactory.createJSFSession(JSFUnitSessionFactory.java:107)
          at org.jboss.jsfunit.arquillian.container.JSFUnitSessionFactory.findJSFSession(JSFUnitSessionFactory.java:92)
          at org.jboss.jsfunit.arquillian.container.JSFUnitSessionFactory.getJSFServerSession(JSFUnitSessionFactory.java:70)
          at org.jboss.jsfunit.arquillian.container.JSFUnitTestEnricher.resolve(JSFUnitTestEnricher.java:84)
          ... 134 more
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
          at java.util.ArrayList.RangeCheck(ArrayList.java:547)
          at java.util.ArrayList.get(ArrayList.java:322)
          at com.steadystate.css.dom.CSSRuleListImpl.item(CSSRuleListImpl.java:73)
          at com.gargoylesoftware.htmlunit.javascript.host.css.CSSRuleList.get(CSSRuleList.java:130)
          at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.getProperty(ScriptableObject.java:1991)
          at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getObjectIndex(ScriptRuntime.java:1565)
          at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getObjectIndex(ScriptRuntime.java:1550)

Here is my code

 

 

  @Deployment
   public static WebArchive createDeployment() {
             ZipFile existingZipFile;
          try {
                    existingZipFile = new ZipFile("target/newmedia.war");
                       WebArchive war = ShrinkWrap.create(ZipImporter.class, "newmedia.war")
                   .importFrom(existingZipFile)
                   .as(WebArchive.class);

                       System.out.println(war.toString(true)); // for debugging
                          return war;
          } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
          }



      return null;
   }


   @Test
   @InitialPage("/sections/explore/index.jsf")
   @BrowserVersion(Browser.FIREFOX_3_6)
   public void testInitialPage(JSFServerSession server, JSFClientSession client) throws IOException
   {
       client.getContentPage().getEnclosingWindow().getWebClient().setJavaScriptEnabled(false);
       client.setValue("filters:text_anno", "spiderman");
       Element el =client.getElement("filters:searchButton");
       client.click("filters:searchButton");



       System.out.println(server.getManagedBeanValue("#{searchResults.numFound}"));

      Assert.assertFalse("", (Long)server.getManagedBeanValue("#{searchResults.numFound}")>0);
   }