Apr 30th, 2012, 08:01 AM
Embedded database for testing non-sping code
I'm trying to solve such problem: I've several legacy non-spring applications I need to write junit test to start refactoring.
I want to write such testing set BEFORE refactoring to be 100% sure my changes won't impact code beheviour (they are all production-live applications)
Such applications connect to database (usually mysql) using URL connection put into a profile file. I cannot access datasource injection without having to significantly change the code.
So my question is: is there a way to create an in-memory database (like spring embedded DB) and provide resulting datasource to some tool like dbunit to expose them as an url my applications can use?
I'd like to initialize all this stuff as a beforeClass junit method so that my application would initialize afterward and I can provide it a jdbc url to use for connecting.
any suggestion or code sample would be extremely useful :-)
thanks in advance