We are trying to simplify some of our unit testing. One of the problems we are running into is that Maven, which we just recently switched too, wants to run these unit tests each and everytime, which isn't a bad thing, but can get messy when the data gets fouled up, which happens a lot when you have several developers all making changes to the same code base accessing the same shared DB2 development databases.
One of the solutions I thought of was to use Hypersonic as an in-memory DB just for the tests. In this way, we could populate the in-memory tables with clean, fresh data, do our tests, and not have to worry that the underlying data is corrupt if one test fails, since it will be rebuilt everytime the test runs. And since its in-memory, it runs way faster than trying to connect to a remote DB over JDBC. This works absolutely great with our MySQL database, but with DB2 we have ran into a "snafu".
The problem is that DB2, unlike many other DB servers out there, uses an "Owner" tacked on to the from of the table name. So, its not "SELECT * FROM MY_TABLE", its "SELECT * FROM OWNR.MY_TABLE". Hypersonic doesn't support this "owner" idea, from what I can. It also doesn't support tables with a '.' in them, so I can't even fake it out. I even tried naming the database itself to my owner name, but that failed as well. And since the table name is hard-coded into the Value Object classes (using Annotations, mind you), the table in DB2 must match the table in Hypersonic.
My question(s)...has anyone ran into this problem? Is there a work-around to it? Are there any other solutions to provide an in-memory DB such that the unit testing can run, but not be tied to some physical DB instance? How are others handling testing from multiple sources in a co-existing test DB?
|