It's not a secret anymore!
The moose likes Spring and the fly likes Spring security with JUnit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring security with JUnit " Watch "Spring security with JUnit " New topic

Spring security with JUnit

Mohan rvscas
Ranch Hand

Joined: Jul 03, 2010
Posts: 39
Hi friends ,

i am new to spring security.

i have created a login form with username and password.

(mapping also done with authority in applicationContext.xml file).

i am getting username and password from the data base.

By using spring security the user name and password is checked properly.

after running the form its executing properly and iam getting correct page.


i need to test the methods using junit test cases.

in spring security we are using jar file to login and providing access through the <interceptor-url> tags.

here no need to write the code.

so i do not know how to test the login form using junit test cases.

please give me the solution.

if you have any references please give me.

Thanks in advance

Mark Secrist
Ranch Hand

Joined: Jul 01, 2003
Posts: 89
What methods are you wanting to test? What you are suggesting sounds more like an integration test than a unit test. If you are wanting to test the security mechisms or your configuration of them via the spring config files, you might want to use a browser based test tool like CubicTest/Selenium. This would allow you to test loging in with proper user, invalid user, etc.

Without more information, it's hard to make a better recommendation.
I agree. Here's the link:
subject: Spring security with JUnit
jQuery in Action, 3rd edition