camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonin Stefanutti <anto...@stefanutti.fr>
Subject Re: Camel delta-spike: How to share properties between conexts ?
Date Tue, 31 May 2016 10:14:08 GMT
Hi Nicolas,

In your unit tests, you should use Camel CDI test runner instead of extending CamelTestSupport.
This is used in the example that illustrates CDI and DeltaSpike configuration properties so
that you can have a look at the accompanying test class. See [2] for more information.

[1]: https://github.com/apache/camel/tree/master/examples/camel-example-cdi-properties
[2]: http://camel.apache.org/cdi-testing.html#CDITesting-CamelCDITest

Antonin

> On 31 May 2016, at 12:01, nicolasduminil <nicolas.duminil@simplex-software.fr>
wrote:
> 
> Hello,
> 
> I'm using delta-spike to manage camel routes as I've seen in the provided
> CDI samples. I have the following route builder:
> 
> public class MyRouteBuilder extends RouteBuilder
> {
>  @Override
>  @ContextName("...")
>  public void configure()
>  {
>    from("ftp:{{ftp.path}}").log("Uploading file
> ${file:name}").to("file:{{file.path}}").log("Uploaded file ${file:name}
> complete.");
>  }
> 
>  @Produces
>  @Named("properties")
>  public PropertiesComponent properties(PropertiesParser parser)
>  {
>    PropertiesComponent component = new PropertiesComponent();
>    component.setPropertiesParser(parser);
>    return component;
>  }
> }
> 
> and I have the following class:
> 
> public class DeltaSpikeParser extends DefaultPropertiesParser {
>  @Override
>  public String parseProperty(String key, String value, Properties
> properties) {
>    return ConfigResolver.getPropertyValue(key);
>  }
> }
> 
> The {{...}} get injected from the apache-deltaspike.properties file.
> 
> In my unit tests I need to use the same property file, for example:
> 
> public class UnitTests extends CamelTestSupport
> {
>  @Override
>  protected RouteBuilder createRouteBuilder()
>  {
>    return new RouteBuilder()
>    {
>      public void configure()
>      {
>        from("direct:start").to("ftp:{{ftp.path}}");
>      }
>    };
>  }
> 
> But here {{ftp.path}} is not defined any more. How could i do this ?
> 
> Many thanks in advance,
> 
> Nicolas
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-delta-spike-How-to-share-properties-between-conexts-tp5783288.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message