Overwrite blueprint properties in camel blueprint tests

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Overwrite blueprint properties in camel blueprint tests

Michael Süess
I have the following camel blueprint xml route and want to set/overwrite
in my CamelBlueprintTest the blueprint properties data.in and data.out
to test directories:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
 
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
     <cm:property-placeholder persistent-id="foo">
         <cm:default-properties>
             <cm:property name="data.in" value="data/in" />
             <cm:property name="data.out" value="data/out" />
         </cm:default-properties>
     </cm:property-placeholder>

     <camelContext id="root"
xmlns="http://camel.apache.org/schema/blueprint">
         <route id="root1">
             <from uri="file:{{data.in}}?noop=true"/>
             <to uri="file:{{data.out}}"/>
         </route>
     </camelContext>
</blueprint>


Any ideas?
Reply | Threaded
Open this post in threaded view
|

Re: Overwrite blueprint properties in camel blueprint tests

Willem.Jiang
Administrator
Here is the example[1] that you can take a look.

[1]http://camel.apache.org/properties.html#Properties-UsingBlueprintpropertyplaceholderwithCamelroutes

On Wed May 16 23:33:58 2012, Michael Süess wrote:

> I have the following camel blueprint xml route and want to
> set/overwrite in my CamelBlueprintTest the blueprint properties
> data.in and data.out to test directories:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>
> xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
> <cm:property-placeholder persistent-id="foo">
> <cm:default-properties>
> <cm:property name="data.in" value="data/in" />
> <cm:property name="data.out" value="data/out" />
> </cm:default-properties>
> </cm:property-placeholder>
>
> <camelContext id="root" xmlns="http://camel.apache.org/schema/blueprint">
> <route id="root1">
> <from uri="file:{{data.in}}?noop=true"/>
> <to uri="file:{{data.out}}"/>
> </route>
> </camelContext>
> </blueprint>
>
>
> Any ideas?
>



--
Willem
----------------------------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

Reply | Threaded
Open this post in threaded view
|

Re: Overwrite blueprint properties in camel blueprint tests

Christian Mueller
Administrator
I assume Michael would like to refer to a (test) properties file where he
can configure some other endpoint uri than in his real deployment. Like the
Spring properties-placeholder mechanism.
I didn't get it working with blueprint (loading a properties file from the
properties-placeholders). I can only share working examples with Spring...
:-(

Best,
Christian

On Thu, May 17, 2012 at 3:40 AM, Willem Jiang <[hidden email]>wrote:

> Here is the example[1] that you can take a look.
>
> [1]http://camel.apache.org/**properties.html#Properties-**
> UsingBlueprintpropertyplacehol**derwithCamelroutes<http://camel.apache.org/properties.html#Properties-UsingBlueprintpropertyplaceholderwithCamelroutes>
>
>
> On Wed May 16 23:33:58 2012, Michael Süess wrote:
>
>> I have the following camel blueprint xml route and want to
>> set/overwrite in my CamelBlueprintTest the blueprint properties
>> data.in and data.out to test directories:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <blueprint xmlns="http://www.osgi.org/**xmlns/blueprint/v1.0.0<http://www.osgi.org/xmlns/blueprint/v1.0.0>
>> "
>>
>> xmlns:cm="http://aries.apache.**org/blueprint/xmlns/blueprint-**cm/v1.0.0<http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0>
>> ">
>> <cm:property-placeholder persistent-id="foo">
>> <cm:default-properties>
>> <cm:property name="data.in" value="data/in" />
>> <cm:property name="data.out" value="data/out" />
>> </cm:default-properties>
>> </cm:property-placeholder>
>>
>> <camelContext id="root" xmlns="http://camel.apache.**org/schema/blueprint<http://camel.apache.org/schema/blueprint>
>> ">
>> <route id="root1">
>> <from uri="file:{{data.in}}?noop=**true"/>
>> <to uri="file:{{data.out}}"/>
>> </route>
>> </camelContext>
>> </blueprint>
>>
>>
>> Any ideas?
>>
>>
>
>
> --
> Willem
> ------------------------------**----
> CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
> FuseSource
> Web: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.**com<http://willemjiang.blogspot.com>(English)
>        http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang
> Weibo: willemjiang
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Overwrite blueprint properties in camel blueprint tests

Michael Süess
Hi

true

it works with spring but i can't get it working with blueprint...

On 17.05.2012 19:07, Christian Müller wrote:

> I assume Michael would like to refer to a (test) properties file where he
> can configure some other endpoint uri than in his real deployment. Like the
> Spring properties-placeholder mechanism.
> I didn't get it working with blueprint (loading a properties file from the
> properties-placeholders). I can only share working examples with Spring...
> :-(
>
> Best,
> Christian
>
> On Thu, May 17, 2012 at 3:40 AM, Willem Jiang<[hidden email]>wrote:
>
>> Here is the example[1] that you can take a look.
>>
>> [1]http://camel.apache.org/**properties.html#Properties-**
>> UsingBlueprintpropertyplacehol**derwithCamelroutes<http://camel.apache.org/properties.html#Properties-UsingBlueprintpropertyplaceholderwithCamelroutes>
>>
>>
>> On Wed May 16 23:33:58 2012, Michael Süess wrote:
>>
>>> I have the following camel blueprint xml route and want to
>>> set/overwrite in my CamelBlueprintTest the blueprint properties
>>> data.in and data.out to test directories:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <blueprint xmlns="http://www.osgi.org/**xmlns/blueprint/v1.0.0<http://www.osgi.org/xmlns/blueprint/v1.0.0>
>>> "
>>>
>>> xmlns:cm="http://aries.apache.**org/blueprint/xmlns/blueprint-**cm/v1.0.0<http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0>
>>> ">
>>> <cm:property-placeholder persistent-id="foo">
>>> <cm:default-properties>
>>> <cm:property name="data.in" value="data/in" />
>>> <cm:property name="data.out" value="data/out" />
>>> </cm:default-properties>
>>> </cm:property-placeholder>
>>>
>>> <camelContext id="root" xmlns="http://camel.apache.**org/schema/blueprint<http://camel.apache.org/schema/blueprint>
>>> ">
>>> <route id="root1">
>>> <from uri="file:{{data.in}}?noop=**true"/>
>>> <to uri="file:{{data.out}}"/>
>>> </route>
>>> </camelContext>
>>> </blueprint>
>>>
>>>
>>> Any ideas?
>>>
>>>
>>
>>
>> --
>> Willem
>> ------------------------------**----
>> CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
>> FuseSource
>> Web: http://www.fusesource.com
>> Blog:    http://willemjiang.blogspot.**com<http://willemjiang.blogspot.com>(English)
>>         http://jnn.javaeye.com (Chinese)
>> Twitter: willemjiang
>> Weibo: willemjiang
>>
>>
>


--
Michael Sueess                           Senior Software Engineer

basis06 AG, Birkenweg 61, CH-3013 Bern - Fon +41 31 311 32 22
http://www.basis06.ch - source of smart business

Keine News verpassen? http://www.basis06.ch/newsletter-registration.html
Schon gebloggt? http://blog.basis06.ch
Reply | Threaded
Open this post in threaded view
|

Re: Overwrite blueprint properties in camel blueprint tests

Claus Ibsen-2
Hi

If you guys have ideas for a way we can improve camel-test-blueprint,
then we may be able to let users to specify in a java method, or some
other way, to load properties from a file / java code etc. and have
those "shadow" any existing properties from the blueprint xml
configuration.

Or any other ways?


On Mon, May 21, 2012 at 7:40 AM, Michael Süess
<[hidden email]> wrote:

> Hi
>
> true
>
> it works with spring but i can't get it working with blueprint...
>
>
> On 17.05.2012 19:07, Christian Müller wrote:
>>
>> I assume Michael would like to refer to a (test) properties file where he
>> can configure some other endpoint uri than in his real deployment. Like
>> the
>> Spring properties-placeholder mechanism.
>> I didn't get it working with blueprint (loading a properties file from the
>> properties-placeholders). I can only share working examples with Spring...
>> :-(
>>
>> Best,
>> Christian
>>
>> On Thu, May 17, 2012 at 3:40 AM, Willem
>> Jiang<[hidden email]>wrote:
>>
>>> Here is the example[1] that you can take a look.
>>>
>>> [1]http://camel.apache.org/**properties.html#Properties-**
>>>
>>> UsingBlueprintpropertyplacehol**derwithCamelroutes<http://camel.apache.org/properties.html#Properties-UsingBlueprintpropertyplaceholderwithCamelroutes>
>>>
>>>
>>> On Wed May 16 23:33:58 2012, Michael Süess wrote:
>>>
>>>> I have the following camel blueprint xml route and want to
>>>> set/overwrite in my CamelBlueprintTest the blueprint properties
>>>> data.in and data.out to test directories:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <blueprint
>>>> xmlns="http://www.osgi.org/**xmlns/blueprint/v1.0.0<http://www.osgi.org/xmlns/blueprint/v1.0.0>
>>>> "
>>>>
>>>>
>>>> xmlns:cm="http://aries.apache.**org/blueprint/xmlns/blueprint-**cm/v1.0.0<http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0>
>>>> ">
>>>> <cm:property-placeholder persistent-id="foo">
>>>> <cm:default-properties>
>>>> <cm:property name="data.in" value="data/in" />
>>>> <cm:property name="data.out" value="data/out" />
>>>> </cm:default-properties>
>>>> </cm:property-placeholder>
>>>>
>>>> <camelContext id="root"
>>>> xmlns="http://camel.apache.**org/schema/blueprint<http://camel.apache.org/schema/blueprint>
>>>> ">
>>>> <route id="root1">
>>>> <from uri="file:{{data.in}}?noop=**true"/>
>>>> <to uri="file:{{data.out}}"/>
>>>> </route>
>>>> </camelContext>
>>>> </blueprint>
>>>>
>>>>
>>>> Any ideas?
>>>>
>>>>
>>>
>>>
>>> --
>>> Willem
>>> ------------------------------**----
>>> CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
>>> FuseSource
>>> Web: http://www.fusesource.com
>>> Blog:
>>>  http://willemjiang.blogspot.**com<http://willemjiang.blogspot.com>(English)
>>>        http://jnn.javaeye.com (Chinese)
>>> Twitter: willemjiang
>>> Weibo: willemjiang
>>>
>>>
>>
>
>
> --
> Michael Sueess                           Senior Software Engineer
>
> basis06 AG, Birkenweg 61, CH-3013 Bern - Fon +41 31 311 32 22
> http://www.basis06.ch - source of smart business
>
> Keine News verpassen? http://www.basis06.ch/newsletter-registration.html
> Schon gebloggt? http://blog.basis06.ch



--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Reply | Threaded
Open this post in threaded view
|

Re: Overwrite blueprint properties in camel blueprint tests

alexey-s
In reply to this post by Michael Süess
Hi

Change cm namespace form
  xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
to
  xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
and change lile from
<cm:property-placeholder persistent-id="foo">
to
<cm:property-placeholder persistent-id="foo" update-strategy="reload">

After change config file $KARAF_HOME/etc/foo.cfg, blueprint restart all camel route in this bundle.


Aleksey
Reply | Threaded
Open this post in threaded view
|

Re: Overwrite blueprint properties in camel blueprint tests

Michael Süess
Hi


Yes, this solves the problem of restarting the route after a config
change in karaf/servicemix.

But my problem is how to set the properties in a junit test using
CamelBlueprintTestSupport.

- where to put my config file?
- or can i set the properties programmatically in the junit test class?


On 25.05.2012 05:20, alexey-s wrote:

> Hi
>
> Change cm namespace form
>    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
> to
>    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
> and change lile from
> <cm:property-placeholder persistent-id="foo">
> to
> <cm:property-placeholder persistent-id="foo" update-strategy="reload">
>
> After change config file $KARAF_HOME/etc/foo.cfg, blueprint restart all
> camel route in this bundle.
>
>
> Aleksey
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Overwrite-blueprint-properties-in-camel-blueprint-tests-tp5710948p5713531.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


--
Michael Sueess                           Senior Software Engineer

basis06 AG, Birkenweg 61, CH-3013 Bern - Fon +41 31 311 32 22
http://www.basis06.ch - source of smart business

Keine News verpassen? http://www.basis06.ch/newsletter-registration.html
Schon gebloggt? http://blog.basis06.ch
Reply | Threaded
Open this post in threaded view
|

Re: Overwrite blueprint properties in camel blueprint tests

Claus Ibsen-2
Hi

I logged a ticket to make this easier
https://issues.apache.org/jira/browse/CAMEL-5349


On Fri, May 25, 2012 at 9:22 AM, Michael Süess <[hidden email]>wrote:

> Hi
>
>
> Yes, this solves the problem of restarting the route after a config change
> in karaf/servicemix.
>
> But my problem is how to set the properties in a junit test using
> CamelBlueprintTestSupport.
>
> - where to put my config file?
> - or can i set the properties programmatically in the junit test class?
>
>
>
> On 25.05.2012 05:20, alexey-s wrote:
>
>> Hi
>>
>> Change cm namespace form
>>   xmlns:cm="http://aries.apache.**org/blueprint/xmlns/blueprint-**
>> cm/v1.0.0 <http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0>"
>> to
>>   xmlns:cm="http://aries.apache.**org/blueprint/xmlns/blueprint-**
>> cm/v1.1.0 <http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0>"
>> and change lile from
>> <cm:property-placeholder persistent-id="foo">
>> to
>> <cm:property-placeholder persistent-id="foo" update-strategy="reload">
>>
>> After change config file $KARAF_HOME/etc/foo.cfg, blueprint restart all
>> camel route in this bundle.
>>
>>
>> Aleksey
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.**
>> com/Overwrite-blueprint-**properties-in-camel-blueprint-**
>> tests-tp5710948p5713531.html<http://camel.465427.n5.nabble.com/Overwrite-blueprint-properties-in-camel-blueprint-tests-tp5710948p5713531.html>
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>>
>
> --
> Michael Sueess                           Senior Software Engineer
>
> basis06 AG, Birkenweg 61, CH-3013 Bern - Fon +41 31 311 32 22
> http://www.basis06.ch - source of smart business
>
> Keine News verpassen? http://www.basis06.ch/**newsletter-registration.html<http://www.basis06.ch/newsletter-registration.html>
> Schon gebloggt? http://blog.basis06.ch
>



--
Claus Ibsen
-----------------
FuseSource
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Reply | Threaded
Open this post in threaded view
|

Re: Overwrite blueprint properties in camel blueprint tests

Michael Süess
Hi


i am a little bit confused...


I looked at the jira feature (which is resolved)

CAMEL-5349: Make it easy to provider override properties from unit tests

with the comment

Updated docs. See the using property placeholder docs for details.


i found the new section in the docu
http://camel.apache.org/using-propertyplaceholder.html:

"Available as of Camel 2.10
When Testing with Camel and using the Properties component, you may want
to be able to provide the properties to be used from directly within the
unit test source code.
This is now possible from Camel 2.10 onwards, as the Camel test kits, eg
CamelTestSupport class offers the following methods
useOverridePropertiesWithPropertiesComponent
ignoreMissingLocationWithPropertiesComponent
So for example in your unit test classes, you can override the
useOverridePropertiesWithPropertiesComponent method and return a
java.util.Properties that contains the properties which should be
preferred to be used.
Providing properties from within unit test source
// override this method to provide our custom properties we use in this
unit test
@Override
protected Properties useOverridePropertiesWithPropertiesComponent() {
     Properties extra = new Properties();
     extra.put("destination", "mock:extra");
     extra.put("greeting", "Bye");
     return extra;
}
This can be done from any of the Camel Test kits, such as camel-test,
camel-test-spring, and camel-test-blueprint.
The ignoreMissingLocationWithPropertiesComponent can be used to instruct
Camel to ignore any locations which was not discoverable, for example if
you run the unit test, in an environment that does not have access to
the location of the properties."


but i couldn't find the mentioned method in the camel maven
2.10-SNAPSHOT (be the way, i tried to download the 2.10 windows and
source distros, both links
[http://www.apache.org/dyn/closer.cgi/camel/apache-camel/2.10.0/apache-camel-2.10.0.zip 
and
http://www.apache.org/dyn/closer.cgi/camel/apache-camel/2.10.0/apache-camel-2.10.0-src.zip]
are broken!)

Thx for any help...


On 09.06.2012 14:45, Claus Ibsen wrote:

> Hi
>
> I logged a ticket to make this easier
> https://issues.apache.org/jira/browse/CAMEL-5349
>
>
> On Fri, May 25, 2012 at 9:22 AM, Michael Süess<[hidden email]>wrote:
>
>> Hi
>>
>>
>> Yes, this solves the problem of restarting the route after a config change
>> in karaf/servicemix.
>>
>> But my problem is how to set the properties in a junit test using
>> CamelBlueprintTestSupport.
>>
>> - where to put my config file?
>> - or can i set the properties programmatically in the junit test class?
>>
>>
>>
>> On 25.05.2012 05:20, alexey-s wrote:
>>
>>> Hi
>>>
>>> Change cm namespace form
>>>    xmlns:cm="http://aries.apache.**org/blueprint/xmlns/blueprint-**
>>> cm/v1.0.0<http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0>"
>>> to
>>>    xmlns:cm="http://aries.apache.**org/blueprint/xmlns/blueprint-**
>>> cm/v1.1.0<http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0>"
>>> and change lile from
>>> <cm:property-placeholder persistent-id="foo">
>>> to
>>> <cm:property-placeholder persistent-id="foo" update-strategy="reload">
>>>
>>> After change config file $KARAF_HOME/etc/foo.cfg, blueprint restart all
>>> camel route in this bundle.
>>>
>>>
>>> Aleksey
>>>
>>> --
>>> View this message in context: http://camel.465427.n5.nabble.**
>>> com/Overwrite-blueprint-**properties-in-camel-blueprint-**
>>> tests-tp5710948p5713531.html<http://camel.465427.n5.nabble.com/Overwrite-blueprint-properties-in-camel-blueprint-tests-tp5710948p5713531.html>
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>>
>>
>> --
>> Michael Sueess                           Senior Software Engineer
>>
>> basis06 AG, Birkenweg 61, CH-3013 Bern - Fon +41 31 311 32 22
>> http://www.basis06.ch - source of smart business
>>
>> Keine News verpassen? http://www.basis06.ch/**newsletter-registration.html<http://www.basis06.ch/newsletter-registration.html>
>> Schon gebloggt? http://blog.basis06.ch
>>
>
>
>