Results 1 to 4 of 4

Thread: Elegant way of overriding properties for tests

  1. #1

    Default 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.

    Thanks,
    Shane

  2. #2
    Join Date
    Dec 2004
    Location
    St. Gallen, Switzerland
    Posts
    69

    Default

    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. #3

    Default

    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. #4
    Join Date
    Dec 2004
    Location
    St. Gallen, Switzerland
    Posts
    69

    Default

    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...
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •