Quantcast

How to set property values during testing for CamelSpringTestSupport based tests

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

How to set property values during testing for CamelSpringTestSupport based tests

Brimstedt
Hello,

In my beans.xml, I use property-placeholders to read configurations from
property files. This works great when deploying my bundles in servicemix.

However, for my unit tests, i have to create a test-beans.xml which
overrides the normal beans.xml with hard coded values.
This means duplicated bean definitions, differences between production and
test beans, and other things I'd like to avoid.

My tests are based on CamelSpringTestSupport, since I mostly use camel
based routes.

I've read up on PropertyComponent in Camel in Action, but I cannot get this
to work neither with spring-properties ${} or camel properties {{}}.

Is there an example somewhere on how to supply my beans with property
values in unit tests? (Preferably spring properties, but I could change to
camel properties if required)
Or anyone's got some hints for me?

This question is also posted on StackOverflow, if you have some input, feel
free to answer here or there, Ill make sure to post any relevant info (and
hopefully solution :) where its not posted..
http://stackoverflow.com/questions/9992492/how-to-set-property-values-during-testing-for-camelspringtestsupport-based-tests

br
/linus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to set property values during testing for CamelSpringTestSupport based tests

Brimstedt
Someone on stackoverflow was kind enough to provide me with an answer :)

By separating the beans xml file properly and in my test-beans.xml file
import the property files from classpath it works perfectly.
For more details, see stackoverflow

best regards

/Linus

On Wed, Apr 4, 2012 at 10:42 AM, Linus Brimstedt <[hidden email]> wrote:

> Hello,
>
> In my beans.xml, I use property-placeholders to read configurations from
> property files. This works great when deploying my bundles in servicemix.
>
> However, for my unit tests, i have to create a test-beans.xml which
> overrides the normal beans.xml with hard coded values.
> This means duplicated bean definitions, differences between production and
> test beans, and other things I'd like to avoid.
>
> My tests are based on CamelSpringTestSupport, since I mostly use camel
> based routes.
>
> I've read up on PropertyComponent in Camel in Action, but I cannot get
> this to work neither with spring-properties ${} or camel properties {{}}.
>
> Is there an example somewhere on how to supply my beans with property
> values in unit tests? (Preferably spring properties, but I could change to
> camel properties if required)
> Or anyone's got some hints for me?
>
> This question is also posted on StackOverflow, if you have some input,
> feel free to answer here or there, Ill make sure to post any relevant info
> (and hopefully solution :) where its not posted..
>
> http://stackoverflow.com/questions/9992492/how-to-set-property-values-during-testing-for-camelspringtestsupport-based-tests
>
> br
> /linus
>
Loading...