Re: Jsession Test Question

2015-12-10 Thread Richard W. Adams
The short answer is no. The session ID is not part of the URL.

The long answer is, you can test for the session ID if you have access to 
the HTTP request object.




From:   Lois GreeneHernandez 
To: "users@wicket.apache.org" 
Date:   12/10/2015 01:50 PM
Subject:Jsession Test Question



This email originated from outside of the company.  Please use discretion 
if opening attachments or clicking on links.

Hi All,

Is it possible to write a unit test or a pojo that tests an request url 
for the presence of a jsessionid?  My application Is java/wicket.  Our 
test system is testNG and wicket tester.

Thanks

Lois



**

This email and any attachments may contain information that is confidential 
and/or privileged for the sole use of the intended recipient.  Any use, review, 
disclosure, copying, distribution or reliance by others, and any forwarding of 
this email or its contents, without the express permission of the sender is 
strictly prohibited by law.  If you are not the intended recipient, please 
contact the sender immediately, delete the e-mail and destroy all copies.
**


RE: Jsession Test Question

2015-12-10 Thread Ephraim Rosenfeld
I would have to do further research, but some ideas:
*   This example shows how to simulate putting a URL in browser, which is 
helpful for mounted pages: 
https://ci.apache.org/projects/wicket/guide/6.x/guide/testing.html#testing_1
*   The 
WicketTester
 class has some useful methods, like getHttpSession, getLastRequest, 
getLastResponse. These may allow you to find some information regarding the URL

I would try the latter first, just printing out what the request and response 
data have.

- Ephraim

-Original Message-
From: Lois GreeneHernandez [mailto:lgreenehernan...@knoa.com]
Sent: Thursday, December 10, 2015 2:51 PM
To: users@wicket.apache.org
Subject: Jsession Test Question

Hi All,

Is it possible to write a unit test or a pojo that tests an request url for the 
presence of a jsessionid?  My application Is java/wicket.  Our test system is 
testNG and wicket tester.

Thanks

Lois



Re: Jsession Test Question

2015-12-10 Thread Martin Grigorov
Hi,

WicketTester *simulates* a browser and a web server.
In a normal setup the web server (like Tomcat) generates and encodes the
jsessionid in the url.
WicketTester creates a Wicket Session for the test(s) and there is no need
of transferring jsessionid in the url/cookie.
You can use tester.executeUrl(";jsessionid=123456") and assert for it
in your server code by using getWebRequest().getUrl().toString() but this
is very artificial.

In your application code you can use
http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getRequestedSessionId()
and
http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#isRequestedSessionIdFromURL()
Maybe WicketTester should add support for those.
Currently the code in MockHttpServletRequest looks like:


/**
 * Check whether session id is from a cookie. Always returns true.
 *
 * @return Always true
 */
@Override
public boolean isRequestedSessionIdFromCookie()
{
   return true;
}

/**
 * Check whether session id is from a url rewrite. Always returns false.
 *
 * @return Always false
 */
@Override
public boolean isRequestedSessionIdFromUrl()
{
   return false;
}



Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Dec 10, 2015 at 8:50 PM, Lois GreeneHernandez <
lgreenehernan...@knoa.com> wrote:

> Hi All,
>
> Is it possible to write a unit test or a pojo that tests an request url
> for the presence of a jsessionid?  My application Is java/wicket.  Our test
> system is testNG and wicket tester.
>
> Thanks
>
> Lois
>