Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-2181

SessionAware documentation is misleading about unit testing

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.9
    • 2.0.11
    • Documentation
    • None

    Description

      The SessionAware JavaDocs state:

      "Note that using this interface makes the Action tied to a servlet environment, so it should be avoided if possible since things like unit testing will become more difficult."

      Unit testing with SessionAware is actually quite simple, compared to accessing the session through ActionContext, and SessionAware makes the Action less bound to a servlet environment than ServletRequestAware, another possible means of accessing the session.

      It could be argued that using sessions at all makes ties an Action to a servlet environment, but this statement instead implies that users should find a different means of getting at the session to improve unit testability. I believe that's misleading.

      Attachments

        1. SessionAware.java.patch
          0.8 kB
          Wes Wannemacher

        Activity

          People

            jholmes James Holmes
            jimothy Jim Cushing
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: