You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Don Trollinger <f5...@webmail.c2d.fedex.com> on 2002/02/26 16:35:57 UTC
Using cookies set in Cactus within Webmacro
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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>