Menu

verifyForward in StrutsTest1.6

Anonymous
2002-04-16
2002-12-13
  • Anonymous

    Anonymous - 2002-04-16

    I've been using StrutsTest version 1.6 for a couple of weeks now.  I've been running tests using a CactusStrutsTestCase.

    My question concerns what the expected behavior of verifyForward is in 1.6.  I had believed that my tests were comparing the *logical* Forward names (e.g. "success", "failure"), but in fact, that method actually is comparing the *path* of those Forwards.

    If I wanted to compare paths, wouldn't I use the new verifyForwardPath() method instead?

    I've worked around the problem by making a one-line change to CactusStrutsTestCase, which I can post somewhere if anybody is interested.

    Thanks.

     
    • Bob Armour

      Bob Armour - 2002-12-13

      I too have seen this behaviour in my test cases when running under StrutsTest1.9 and Cactus 1.4.1

      Do you know if there was ever a resolution to this bug. I'm basically struggling because I have 2 forwards that point to the same URL. Incidentally, I can work-around this by adding spoof URL parameter to one of the forward entries, but I'd rather no do this.

      Thanks in advance

      P.S. I don't particulary want to start compiling my own local version of StrutsTest

       
      • Deryl Seale

        Deryl Seale - 2002-12-13

        Let me give a bit of background here.  It is true that the comparison in verifyForward is on the actual path, and this is because the StrutsTestCase library treats the Struts framework like a black box.  In other words, it does not and cannot access the actual logical forward name used, but rather intercepts the forward call to grab the actual path sent to that method.  Likewise, the forward name supplied in verifyForward is used to retrieve the actual path specified struts-config.xml.  Though the actual comparison deals with real paths, your tests can still reference the forwards using the symbolic name.

        I am a little unclear as to why this is a problem, though.  If I may step outside my glass house for a moment, I'd like to know why you would use two forwards that point to the same URL in your Action.
        Wouldn't a single forward suffice?

        -d.

         
        • Bob Armour

          Bob Armour - 2002-12-13

          The 2 forwards ('failure' and 'success') have the same 'path' value temporarily until I get the correct page form the designers. It shouldn't be an issue in future but it did result in a certain amount of head scratching until I found this post. The javadocs for verifyForward method compare the forward names NOT the paths - my opinion anyway - your explanation dispels this misunderstanding. Not sure if it's worth updating the documentation to reflect this as you're not likely to find many people who do what I did)

          Thanks for the swift reply

          Bob

           
          • Deryl Seale

            Deryl Seale - 2002-12-13

            Fair enough -- I'll make some doc changes.

            For your situation, though, I suggest changing the struts-config.xml file to differentiate between the two forwards, even if it's with temporary data (and since they're going to be different, ultimately).  You can then use verifyForward, passing in the symbolic names.  Once the actual URL's are finalized, you can change struts-config.xml, and your tests should still work without changing them at all.  That was kind of the idea behind using verifyForward, as opposed to using verifyForwardPath.

            -d.

             

Log in to post a comment.