Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Testing with Spring

 
Charles McGuire
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Croarkin
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic