Announcement Announcement Module
Collapse
No announcement yet.
Can a Spring Bean programmatically replaced in an loaded SpringContext? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can a Spring Bean programmatically replaced in an loaded SpringContext?

    hi

    i want write an integration test but with one minor restriction. i got a TimeSourceBean that i want to mock out. this TimeSourceBean is used several times deep in the application. (no way to do this with reflection)

    everything is done by autowire.

    i think i could load in my test an aditional xml (with a test application context) with an implementation of the TimeSourceBean that is doing what i want.

    but really nice would be when i can create my mock TimeSourceBean in the test itself and register it (replace the original bean) to the context

    => so before i start the test, i create the mock and register my bean like this:

    context.registerBean(timeSourceBeanMockVersion);

    any ideas if this is possible?

    thanks for your help! :-)
Working...
X