This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Testing and the fly likes Spring3 MVC junit testing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Testing
Bookmark "Spring3 MVC junit testing" Watch "Spring3 MVC junit testing" New topic
Author

Spring3 MVC junit testing

Amitosh Mishra
Ranch Hand

Joined: Feb 11, 2010
Posts: 49
Hi All,

I am trying to learn junit testing for spring controller.

find below the test Class i have written



in newUsewr2 method I'm trying to access the request parametre like


but i'm getting Null Pointer exception while accesing Request object.

please provide help to access request object in this scenario

i don't want to pass request object in newUser2 method.

thanks..
Praveen Kumar M K
Ranch Hand

Joined: Jul 03, 2011
Posts: 256
I don't see any variable named request being defined in newUser2(). You will have to have a static reference variable of request then.
Amitosh Mishra
Ranch Hand

Joined: Feb 11, 2010
Posts: 49
i want to access servletrequest object in non dispatcher servlet environment.
is there any way to this except passing request object as parameter??
Amitosh Mishra
Ranch Hand

Joined: Feb 11, 2010
Posts: 49
Hi ,
I resolved this by setting


in my test method
and accessing request as


in controller class method.
 
GeeCON Prague 2014
 
subject: Spring3 MVC junit testing