File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes Testing with Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Testing with Spring" Watch "Testing with Spring" New topic
Author

Testing with Spring

Charles McGuire
Ranch Hand

Joined: Jan 18, 2005
Posts: 99
Hi!

I was just on the Manning web site to review the info about the book and I saw this:
How to test Java EE components´┐ŻServlets, JSPs, and Spring Controllers

I understand from a Spring enthusiast that Spring 2.5 contains wonderful new things to assist in Testing. Have you looked into this, and if so, do you anticipate any changes to the approaches in your book where Spring is concerned? Just curious...

Note: Spring 2.5 is not yet GA and is available only has a milestone build form.


There's no place like 127.0.0.1
Paul Croarkin
Ranch Hand

Joined: Sep 30, 2004
Posts: 106
Spring leverages dependency injection to help with separating concerns which will help you in testing. For instance, if you have a user account management page where you want to test that the password conforms to certain policies (at least eight characters, etc), but the account management page is hard-wired to an LDAP service that you do not want to hit during testing, you are going to have a hard time.

However, if you make the LDAP service an injectable dependency, you can use Spring or some other dependency injection strategy, to inject a mock LDAP service during testing and the real one at runtime.


Thanks,<br /> <br />Paul Croarkin<br />SCEA 5, SCWCD, SCJP
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
The book doesn't really talk about the features of Spring (instead I talk about the fundamental concept of dependency injection). The Spring stuff is about showing how we can test drive the controller objects implemented with the Spring MVC framework.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Testing with Spring