Hi,
In article <[EMAIL PROTECTED]>,
Wed, 14 Sep 2005 10:47:22 +0530,
"Sharma, Harsh" <[EMAIL PROTECTED]> wrote:
harshs> Situation : I have a Custom Tag which based on previously set Cookie
harshs> Value generates some tables Dynamically. I need to come up with a Unit
harshs> test for this Custom Tag.
harshs>
harshs> Problem : Since I don't have a actual session going Cookie are not set
harshs> to Values which are required to generate these tables, so how do I set
harshs> values for cookies to generate these tables.
You can add cookies at beginXXX method:
public void beginXXX(WebRequest theRequest)
{
theRequest.addCookie("name1", "value1");
...
}
Then, you can refer cookie(s) at the corresponding testXXX method:
public void testXXX()
{
Cookie[] cookies = request.getCookies();
...
}
If you have to set-up an object as a session attribute
for your custom tag, you can do so:
public void testXXX()
{
...
String cookieValue = getCookieValueByName("name1");
session.setAttribute(cookieValue,
someObjectAssociatedWithCookieName1);
...
// instantiate and test the target class.
}
private String getCookieValueByName(String theName)
{
...
}
Hope this helps,
Kazuhito SUGURI
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]