I am not sure you can get the property that away. From my understanding
using useOverridePropertiesWithPropertiesComponent is usually for when you
have properties set in a blueprint or spring bean and you want to override
them in your tests. You may want to inject test properties rather than the
normal ones. I usually use @PropertyInject annotation, I am not sure those
properties are available at the context level. Perhaps some of the Camel
developers can explain better.

On Tue, Nov 15, 2016 at 11:59 PM, shuston [via Camel] <
ml-node+s465427n5790156...@n5.nabble.com> wrote:

> I am struggling to understand something I fear is very basic, but I just
> don't see it. Hoping someone can help me understand this.
>
> Properties... I can use them in route definitions, but I don't seem to be
> able to obtain their values in regular Java code.
>
> Example (using Camel 2.16.3):
>
> I have a route builder:
>
> public class MyRouteBuilder extends RouteBuilder {
>     public void configure() {
>         from("file:{{dataFile}}?noop=true")
>          .to("file:target/messages/others");
>     }
> }
>
> And a unit test:
>
> @RunWith(JUnit4.class)
> public class UnitTest extends CamelTestSupport {
>
>         private String fileName;
>
>             @Override
>             protected RouteBuilder createRouteBuilder() {
>             return new MyRouteBuilder();
>             }
>
>             @Override
>             public Boolean ignoreMissingLocationWithPropertiesComponent()
> {
>             return true;
>             }
>
>             @Override
>             protected Properties 
> useOverridePropertiesWithPropertiesComponent()
> {
>                     Properties override = new Properties();
>                     override.put("dataFile", "overridden-file");
>                     return override;
>             }
>
>             @Test
>                 public void testPropertyGetting() throws Exception {
>             fileName = context().getProperty("dataFile");
>             assert(fileName != null);
>             }
> }
>
> When I run this test, the output includes:
>
> INFO  Route: route1 started and consuming from: 
> Endpoint[file://overridden-file?noop=true]
>
>
> So the override property set above did get filled into the route
> definition.
> However, when I try to get the property in the testPropertyGetting()
> method, the value is null
>
> Why???
>
> -Steve
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/Seeking-to-understand-
> properties-tp5790156.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428...@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: 
http://camel.465427.n5.nabble.com/Seeking-to-understand-properties-tp5790156p5790162.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to