Although the way to mock jdbc in your application, of course, depends on how you implemented your actual jdbc transactions.
If you use jdbc as it is, I would suggest that you write yourself a utility class to perform some tasks in the DBUtils.getMetadataFor(String tablename) row. This will mean that you will need to create a layout for this class, and that may be all you need. This would be a fairly simple solution for you, as you probably already have a series of mock objects related to jdbc. Please note that I assume that your jdbc code is not torn around the application - if so, refactoring !!!
If you use some kind of infrastructure to process the database (for example, Spring Framework JDBC Template classes), you can and should make fun of the interface class using EasyMock or another equivalent. Thus, you can have all the power in the world necessary to easily mock a compound.
And finally, if nothing works, you can do what others have already said and use DBUnit and / or derby.
P Arrayah Nov 08 '08 at 14:09 2008-11-08 14:09
source share