Re: Cookies ???????

2005-09-14 Thread Kazuhito SUGURI
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]



Re: Cookies ???????

2005-09-14 Thread Nicolas Chalumeau
I don't sample here but the beginXXX(...) is the good place for this

Nicolas,

2005/9/14, Sharma, Harsh <[EMAIL PROTECTED]>:
> Hi All,
> 
> Situation : I have a Custom Tag which based on previously set Cookie
> Value generates some tables Dynamically. I need to come up with a Unit
> test for this Custom Tag.
> 
> Problem : Since I don't have a actual session going Cookie are not set
> to Values which are required to generate these tables, so how do I set
> values for cookies to generate these tables.
> 
> Any help would be welcome...though a sample code would be more than
> welcome
> 
> Thanks in advance
> 
> Harsh Sharma
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]