Announcement Announcement Module
No announcement yet.
Elegant way of overriding properties for tests Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Elegant way of overriding properties for tests

    I'm using property placeholder to define app properties and injecting via @Value("${someproperty}"). Is there an elegant way of overriding the injected property without using something like Mockito or using a different @ContextConfiguration?

    For now, I've resorted to adding a setter on the bean in question and using that to override the property before running the test.


  • #2
    Not sure if I understand your problem correctly... we've created a environment dependent factory bean which itself creates the Properties (for dev, test, qual, prod, etc.)... which one is dependent on a system property (-D parameter) you can set... and this factory bean is configured as the property placeholder...


    • #3
      Are you referring to profiles in Spring 3.1? If so, that solution doesn't fit since we're still running with 3.x. I'd be interested in an example or more details of your proposed solution either way.


      • #4
        No... this is not Spring 3.1... we use Spring since version 0.89 so we needed this functionality years before Spring 3.1... :-)
        Please find the complete example in the attached zip...