1 Reply Latest reply on Jul 25, 2008 10:22 AM by Stan Silvert

    First ever JSFUnit test

    Mark Beavis Newbie

      Hi there - I'm just trying to get JSFUnit up and running....

      I'm getting a very curious error however - this is the stack trace:

      javax.xml.transform.TransformerException: org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.

      java.lang.RuntimeException: javax.xml.transform.TransformerException: org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
      at org.jboss.jsfunit.facade.JSFClientSession.updateInternalState(JSFClientSession.java:219)
      at org.jboss.jsfunit.facade.JSFClientSession.doWebRequest(JSFClientSession.java:201)
      at org.jboss.jsfunit.facade.JSFClientSession.doInitialRequest(JSFClientSession.java:131)
      at org.jboss.jsfunit.facade.JSFClientSession.(JSFClientSession.java:82)
      at test.LoginPageTest.setUp(LoginPageTest.java:23)
      at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
      at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
      at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)
      at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:217)
      at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
      at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
      at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:217)
      at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
      at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
      at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:217)
      at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:122)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: javax.xml.transform.TransformerException: org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
      at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:348)
      at org.jboss.jsfunit.facade.DOMUtil.convertToDomLevel2(DOMUtil.java:143)
      at org.jboss.jsfunit.facade.JSFClientSession.updateInternalState(JSFClientSession.java:215)
      ... 33 more
      Caused by: org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
      at org.apache.xml.utils.DOMBuilder.startElement(DOMBuilder.java:322)
      at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1020)
      at org.apache.xml.utils.TreeWalker.startNode(TreeWalker.java:347)
      at org.apache.xml.utils.TreeWalker.traverse(TreeWalker.java:159)
      at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:337)
      ... 35 more

      My page is trivial EG:

      <!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"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
      <f:view>
      Test page


      <h:form id="form1">

      <h:outputText value="Enter your name:" rendered="#{empty foo.text}" id="prompt"/>
      <h:outputText value="Hello #{foo.text}" rendered="#{!empty foo.text}" id="greeting"/>

      <h:inputText value="#{foo.text}" id="input_foo_text"/>
      <h:message for="input_foo_text" styleClass="errorMessage"/>

      <h:commandButton value="Submit" action="/index.jsp" id="submit_button"/>
      <h:commandButton value="Goodbye" action="/finalgreeting.jsp" id="goodbye_button"/>

      </h:form>


      </f:view>


      Likewise my test:

      public class LoginPageTest extends ServletTestCase {
      public void setUp() throws IOException, SAXException {
      this.client = new JSFClientSession("/test.jsf");
      }
      }

      The page test.jsf renders fine in my browser - and is valid XHTML (I am using facelets).

      Can anyone help me with what is wrong - I think I've followed the examples closely... Hopefully I'm not missing anything silly....

      Thanks -

        • 1. Re: First ever JSFUnit test
          Stan Silvert Master

          Hi,

          We've been seeing these kinds of problems a good bit. It boils down to the fact that we use HttpUnit, which is an old tool based on DOM level 1 and we have to convert to level 2. So you run into problems with xalan compatibility and other XML issues.

          To fix this, we are dumping HttpUnit and changing over to HtmlUnit, which fixes this problem and also gives us javascript support and consequently better Ajax testing capability.

          So that's a long way of saying you should try out the latest JSFUnit code from SVN. We'll be doing a release of this new code as soon as we can, but I'd hate to see you start out with the old stuff and need to convert your tests later on.

          So to get started:
          Get the latest source: http://www.jboss.org/jsfunit/source-repository.html
          Build it: http://www.jboss.org/jsfunit/building-jsfunit.html

          Use the org.jboss.jsfunit.jsfsession package instead of org.jboss.jsfunit.facade.

          Starting out, your code will look something like this:

          JSFSession jsfSession = new JSFSession("/test.jsf");
          JSFClientSession client = jsfSession.getJSFClientSession();
          JSFServersession server = jsfSession.getJSFServerSession();


          Regards,

          Stan