5 Replies Latest reply on Aug 13, 2011 5:24 PM by José Freitas

    Misterious NPE

    José Freitas Newbie

      Hey guys,

      I'm trying to run arquillian-hellojsf after updating jsfunit-arquillian to use arquillian.CR1 spi.

      Everything seems to be working well with the arquillian extension. and most of tests run without error.

       

      but when I click on a submit button, something bad happens while parsing the response.

       

      {code}

          @Test

          @InitialPage("/index.faces")

         //commented everything cookie related to isolate click on submit

          // @Cookies(names = { "cookie1", "cookie2" }, values = { "value1", "value2" })

          public void testCustomCookies(JSFClientSession client, JSFServerSession server) throws IOException {

              // Assert.assertEquals("value1", getCookieValue(server, "cookie1"));

              // Assert.assertEquals("value2", getCookieValue(server, "cookie2"));

       

              // verify that cookies survive for the whole session

              client.click("submit_button");

              // Assert.assertEquals("value1", getCookieValue(server, "cookie1"));

              // Assert.assertEquals("value2", getCookieValue(server, "cookie2"));

          }

      {code}

       

      on method WebClient.loadDownloadedResponses()

      line 2127 it calls loadWebResponseInto(downloadedResponse.response_, win);

      which tries to create a page with PageCreator

      newPage = pageCreator_.createPage(webResponse, webWindow);

       

      the method tries to parseHtml with a page that seems the real deal: HtmlPage(http://127.0.0.1:8080/ebc9902-b38a-4b70-9ba5-d737b8a63fad/index.faces)@24930588

       

      the content extracted from this page it's not null, but I couldn't see the output

      it's kinda short though: count=2096

      InputStream content = webResponse.getContentAsStream();

      XMLInputSource in = new XMLInputSource(null, url.toString(), null, content, charset);

       

      the problem happens when parsing

      domBuilder.parse(in);

       

      the Throwable target is null.

      and this is the exception:

      http://pastebin.com/fsrNkpq3

       

       

      so guys, do you have a clue of what it could be?

      I hope that I provided enough information.

        • 1. Re: Misterious NPE
          José Freitas Newbie

          just saw the inputStream content (extracted from InputStream content = webResponse.getContentAsStream()) as a string

           

          and it seems perfect!

           

          <!--

          JBoss, Home of Professional Open Source

          Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors

          as indicated by the @authors tag. All rights reserved.

          See the copyright.txt in the distribution for a

          full listing of individual contributors.

           

          This copyrighted material is made available to anyone wishing to use,

          modify, copy, or redistribute it subject to the terms and conditions

          of the GNU Lesser General Public License, v. 2.1.

          This program is distributed in the hope that it will be useful, but WITHOUT A

          WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A

          PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.

          You should have received a copy of the GNU Lesser General Public License,

          v.2.1 along with this distribution; if not, write to the Free Software

          Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,

          MA  02110-1301, USA.

          --><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

          <html xmlns="http://www.w3.org/1999/xhtml">

          <form id="form1" name="form1" method="post" action="/abeaa418-2676-412e-a46f-45c2de6e1b3e/index.faces" enctype="application/x-www-form-urlencoded">

          <input type="hidden" name="form1" value="form1" />

          <span id="form1:prompt">Enter your name:</span><br /><input id="form1:input_foo_text" type="text" name="form1:input_foo_text" value="" /><span class="errorMessage">form1:input_foo_text: Erro de validação: o comprimento é menor do que o mínimo permitido de &quot;2&quot;</span>

                <br /><span id="form1:funchecktext">Uncheck this box just for fun  </span><input id="form1:funcheck" type="checkbox" name="form1:funcheck" checked="checked" />

                <br /><br /><input id="form1:submit_button" type="submit" name="form1:submit_button" value="Submit" /><input id="form1:goodbye_button" type="submit" name="form1:goodbye_button" value="Goodbye" /><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="-1920097866547278462:-1646168388579943587" autocomplete="off" />

          </form>

           

          </html

          • 2. Re: Misterious NPE
            José Freitas Newbie

            I followed up with the problem this morning and I found out that the problem is the &quot; on the validation message:

            <span class="errorMessage">form1:input_foo_text: Erro de validação: o comprimento é menor do que o mínimo permitido de &quot;2&quot;</span>

             

            it breaks when trying to:

            int c = HTMLEntities.get(name);

            //name is quot

             

            I could not debug further, eclipse couldn't evaluate the expression.

            But in one of the files that hold entries loaded to Entities, theres an entry for quot:

             

            quot=\u0022

             

            so everything seems fine. Any clues on how to proceed? is this a known bug?

            • 3. Re: Misterious NPE
              José Freitas Newbie

              I found the problem, I wasn't adding those property files on the jar  built with shrinkwrap.

              1 of 1 people found this helpful
              • 4. Re: Misterious NPE
                John Franey Novice

                I had this too.   It took me too long to learn the problem using eclipse debugger.

                 

                 

                Here is shrinkwrap call to add the resources which 2.0.0.Beta1 doesn't, but should (on the ground that jsfunit bundles the classes that uses these into the test archive):

                 

                 

                {code}

                                war.addResource(

                                                "net/sourceforge/htmlunit/corejs/javascript/resources/Messages.properties",

                                                "WEB-INF/classes/net/sourceforge/htmlunit/corejs/javascript/resources/Messages.properties")

                                                .addResource("org/cyberneko/html/res/HTMLlat1.properties",

                                                                "WEB-INF/classes/org/cyberneko/html/res/HTMLlat1.properties")

                                                .addResource("org/cyberneko/html/res/HTMLspecial.properties",

                                                                "WEB-INF/classes/org/cyberneko/html/res/HTMLspecial.properties")

                                                .addResource("org/cyberneko/html/res/HTMLsymbol.properties",

                                                                "WEB-INF/classes/org/cyberneko/html/res/HTMLsymbol.properties")

                                                .addResource("org/cyberneko/html/res/XMLbuiltin.properties",

                                                                "WEB-INF/classes/org/cyberneko/html/res/XMLbuiltin.properties");

                 

                {code}

                 

                • 5. Re: Misterious NPE
                  José Freitas Newbie

                  Hey John, thanks for the post reply, it will help people looking for a solution while a new version is not available, I should had think on that.

                   

                  for the next version those files and a couple of other ones, will be loaded too.