aspose file tools*
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


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring3 MVC junit testing