#81 VerifyActionMessages( ..) doesn't check session scope

open
nobody
None
5
2005-12-30
2005-12-30
Anonymous
No

VerifyActionMessages( ..) doesn't check for messages
in session scope. The fix is pretty simple. I fixed it
myself yet StrutsTestCase doesn't do this.

Same thing for verifyActionErrors(..) I think.

Scenarios for checking for action/error messages
in session scope:

When a forward use redirect, in order to for
messages to survive redirect, messages
explicitly put into session scope in action classes.

Thanks

j2ee_dodo@orcon.net.nz

Discussion

  • Matt Raible
    Matt Raible
    2006-04-06

    Logged In: YES
    user_id=226669

    Here's a patch to fix this:

    Index: src/servletunit/struts/Common.java

    ====================
    RCS file: /cvsroot/strutstestcase/strutstestcase/src/servletunit/struts/
    Common.java,v
    retrieving revision 1.41
    diff -b -u -r1.41 Common.java
    --- src/servletunit/struts/Common.java 11 Jun 2004 15:55:15 -0000
    1.41
    +++ src/servletunit/struts/Common.java 6 Apr 2006 20:54:38 -0000
    @@ -53,7 +53,10 @@
    protected static void verifyNoActionMessages(HttpServletRequest request,
    String key, String messageLabel) {
    if (logger.isTraceEnabled())
    logger.trace("Entering - request = " + request + ", key = " + key + ",
    messageLabel = " + messageLabel);
    - ActionMessages messages = (ActionMessages) request.getAttribute
    (key);
    + ActionMessages messages = (ActionMessages) request.getAttribute
    (key);// check in session too
    + if (messages == null) {
    + messages = (ActionMessages) request.getSession().getAttribute
    (key);
    + }
    if (logger.isDebugEnabled()) {
    logger.debug("retrieved ActionMessages = " + messages);
    }
    @@ -80,7 +83,10 @@
    if (logger.isTraceEnabled())
    logger.trace("Entering - request = " + request + ", messageNames =
    " + messageNames + ", key = " + key + ", messageLabel = " +
    messageLabel);

    - ActionMessages messages = (ActionMessages) request.getAttribute
    (key);
    + ActionMessages messages = (ActionMessages) request.getAttribute
    (key);// check in session too
    + if (messages == null) {
    + messages = (ActionMessages) request.getSession().getAttribute
    (key);
    + }
    if (logger.isDebugEnabled()) {
    logger.debug("retrieved ActionMessages = " + messages);
    }