Abstract

This chapter extends the final iteration of the application developed in a previous chapter so that the library, its borrowers, and publications (the domain model) persist in a database. Earlier in the book, an Action object was uses to implement a MVC (model-view-controller) architecture and, as a consequence, keep the domain model separate from the user interaction code. In this case study, this chapter introduces a data access object (DAO) to keep the domain model separate from database persistence code. It is implemented with the Spring framework and the Cloudscape DBMS. The Publication, Book, and Journal classes are unchanged and only a minor change is required in the Borrower class. However, there are significant changes made to the Library class and the main Groovy script that runs the application. Both rely on the construction of a DAO using the Spring framework. In the first iteration, the required changes are detailed. The second iteration considers the impact of persistence on unit testing. Happily, it is found that all of the earlier unit tests can be run without too much trouble. It is also found that it is surprisingly easy to introduce new unit tests aimed at testing our implementation of persistence. Finally, the chapter reflects on the role of automated unit testing and Groovy.

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.