I need some JUnit advice for testing my JdbcDaoSupport sub classes.
My methods inside my classes call the getConnection() method from JdbcDaoSupport. My first thought was to subclass my class and overload the getConnection() method with one that would return a mock connection. This does not work because the getConnection() method is final. My next thought was to provide a mock datasource to
JdbcDaoSupport through the setDataSource() method. The mock datasource would then return a mock connection. This also does not work because the setDataSource() method on JdbcDaoSupport calls many methods on the datasource and I can't implement those on my mock. I then though about subclassing again and overloading setDataSource() but it too is final.
So...How is everyone unit testing their JDBC DAOs in isolation from a DB? Am I missing something obvious?
Thanks


Reply With Quote