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 spring testing framework simplejdbc template Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "spring testing framework simplejdbc template " Watch "spring testing framework simplejdbc template " New topic
Author

spring testing framework simplejdbc template

bill simons
Greenhorn

Joined: Jul 16, 2012
Posts: 5
I am trying to figure out spring context testing uses simplejdbc template for stored procedure
when you are using an embedded database like hsqldb.

However, I have seen so many ways on how to accomplish like

simplejdbc exten jdbc etc

What is the best way to handle unit testing using embedded databases in spring??
can you use stored procedures???
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1666
    
    7

Well it really depends what kind of test you are doing. If it just a unit test I will typically mock the repository and return whatever value I want for my test case. In this case the database is never actually called. Now if you are looking for more of an integration test case and you want to actually execute your procedures, you would have to use an embedded database. Derby seems to have support for functions and stored procedures.

http://wiki.apache.org/db-derby/DerbySQLroutines

Note that when you do something like this your goal should not be to test the stored procedure, as there is no guarantee its going to behave the same on your test case with the embedded DB as it does in your production DB. This would be more a use case for functional testing.


[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: spring testing framework simplejdbc template