6 Replies Latest reply on Oct 28, 2010 2:12 AM by baz

    experiencing Timing problems



      i do have some problems with my JSFunit script. Here is the snippet:


      -1-     client1.click("1:contractEdit");
      -2-     assertEquals("/fong/contract/contract_edit.xhtml", server1.getCurrentViewID());
      -3-     ContractTO c = (ContractTO) server.getManagedBeanValue("#{seamconversation.contractSearchBean.selectedContractTO}");
      -4-     String contractNumber = (String)   server.getManagedBeanValue("#{seamconversation.contractSearchBean.selectedContractTO.contract.contractNumber}");;


        -5-    assertEquals("vw-ag-test", contractNumber);



      When i run my script it is a 50:50 chance it comes up with success.

      When it fails it fails on the line marked with -5- because contractNumber is null.

      I have tested it, when contractNumber is null, than c is also null.


      What could lead to such behaviour?



        • 1. Re: experiencing Timing problems

          Sorry, i have not figured out how to quote code fragments correctly:-(

          But the above fragment seems readable to me.

          • 2. Re: experiencing Timing problems

            Hi Carsten,


            It looks like maybe you have more than one active JSFSession?  You can only have one JSFSession active at a time.  If you want to have multiple clients then you need to have one JSFSession and then use plain HtmlUnit for the other clients.



            • 3. Re: experiencing Timing problems

              Hi Stan,

              thanks for the fast answer.

              I do not want intentionally more than one JSF-Session.

              Can AJAX take place here?

              This is the code for the link i am trying to click:


              <h:commandLink id="contractEdit" action="#{contractSearchBean.contractEdit}" onmouseup="Richfaces.showModalPanel('processingModal')">                      

                   <h:graphicImage value="/img/icons/fongstyle/bearbeiten.gif" alt="#{messages.global_edit}" styleClass="imageButtons"/> 

                   <f:setPropertyActionListener value="#{contractTO}" target="#{contractSearchBean.selectedContractTO}" />

                   <s:conversationPropagation type="nest" />

                   <a4j:support event="oncomplete" oncomplete="Richfaces.hideModalPanel('processingModal')" />



              • 4. Re: experiencing Timing problems

                You had "server" and "server1" in your code.  So that made me think you were using more than one JSFSession.


                All ajax should work and react to your clicks.  If you think there is a timing issue you can put some sleep statements in your code and see what happens.  If sleeping fixes your problem then that may point to a bug in HtmlUnit.



                • 5. Re: experiencing Timing problems

                  Hi Stan,

                  yes i am at the beginning of the learning curve to jsfUnit. I had thougt that i have to get a new server whenever the view has changed. But now i know that this is not the fact. One server Instance is enough.

                  no, adding a sleep statement between -1- and -2- does nothave any effect. Sometimes the test succeds sometimes it fails:-(


                  So, iff it is really a timing problem it occurs directly in the call (-1-) toclient.click

                  • 6. Re: experiencing Timing problems

                    Hi ,

                    another example:



                          assertEquals("/fong/start.xhtml", server.getCurrentViewID());

                          int count = 0;
                          boolean tryAgain = true;
                          while (tryAgain && count < 100) {

                              try {


                                  System.out.println("######### Current Page server: " + server.getCurrentViewID());

                                  tryAgain = false;

                              } catch (Exception e) {

                                  System.out.print("######### counter: " + count++);

                                  System.out.println(" ## Click Exception !!!!!!! " + e.toString());

                          assertEquals("/fong/person/person_search.xhtml", server.getCurrentViewID());


                    What it does:

                    1. navigate to startpage
                    2. try to navigate to User Search page


                    I have a seen a count of minimal 2 and maximal 43 :-(