Announcement Announcement Module
No announcement yet.
Testing autowire datasource Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Testing autowire datasource

    8.3.3. Transaction management

    AbstractTransactionalSpringContextTests depends on a PlatformTransactionManager bean being defined in the application context. The name doesn't matter, due to the use of autowire by type.
    My application uses Websphere data source in production and BasicDataSource in unit testing. So my bean configuration have two different data source types. When I tried to run the unit test case by extending AbstractTransactionalDataSourceSpringContextTests, it failed to autowire the datasource by type because I have two data sources.

    Is it possible for me to auto-wire by name? Or any other approaches?

  • #2
    You can set the autowireMode programmatically. The alternative is to split your configuration and extract out the changable elements. You can then include the unit test file in one environment and the websphere one in the other.
    Last edited by karldmoore; Aug 27th, 2007, 03:43 PM.