jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Don Trollinger <f526...@webmail.c2d.fedex.com>
Subject Using cookies set in Cactus within Webmacro
Date Tue, 26 Feb 2002 15:35:57 GMT
In Cactus I am setting a cookie in the beginXXX method and WebMacro
never
finds it in the context.

public class BasicUpdateTest extends ServletTestCase
{
  public void beginGetUsersGroup(WebRequest request)
    {
        request.setURL(URL_SERVER_PORT,
              "", SERVLET_PATH_NAME, "", "");
        s_gremsLog.debug("URL_SERVER_PORT::" + URL_SERVER_PORT);
        request.addCookie( "usersGroup", "contract_admin" );
    }

    public void testGetUsersGroup() throws Exception
    {
        m_context =  m_wm.getWebContext(request,response);
        m_servlet = new BasicUpdate();
        m_servlet.init(config);
        assertEquals(URL_SERVER_PORT, request.getServerName());
        String usersGroup m_servlet.getUsersGroup(context);
       assertEquals( usersGroup, "contract_admin" );
    }
}

The handle method checks the value of the cookie and it is always null.
What is missing here? Has anybody used cookies with Cactus and Webmacro?

    /**
     * Returnsthe current group selected by the user from a set cookie.
     *
     * @param context org.webmacro.servlet.WebContext
     * @return String The current group selected
     * @throws NullPointerException  If usersGroup cookie not found
     */
    protected String getUsersGroup( WebContext context )
    throws NullPointerException
    {
        Cookie cookie = context.getCookie( "usersGroup" );
        if ( null == cookie )
        {
            String msg = "cookie is null: " + cookie.toString();
            gremsLog.error( msg );
            throw new NullPointerException( msg );
        }
        else
        {
            return cookie.getValue();
        }
    }




--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message