For my unit tests I would like to load the application context in its original form, with just one exception: the datasource bean needs to target a different database. So I'm looking for a way to create a child context with just this one (overriding) bean configuration, with all other bean configurations taken from the parent context.
I have not yet found a way to do this. I can of course create a second datasource bean with id "dataSourceTest", but that would require me to replace the bean references from my Hibernate session factory to "dataSource" with bean references to "dataSourceTest". This in turn would require me to replace references to that session factory etc etc. I would end up copying the complete applicationContext.xml, while it's just one bean that I'd like to replace.
I think I'm overlooking something, as this must be a very common situation. Any clues?
Thanks a lot,
Emiel.


Reply With Quote