Regarding your question:
> What happens if you have a application.yml file and put the property in there?
Well the my-property is set like:
myProperty: someValue
in the application.yml as well as the application-test.yml

Trying to access the property like:
@Value(„${myProperty}")
private String myProperty;
Works.
But in the test-case I try to create my route-builder like:
@Override
public RouteBuilder createRouteBuilder() {
    LOG.info(„MyProperty: #" + myProperty);
    return new MyRouteBuilder();
}

Whereas MyRoute Builder is implemented as follows:

@Component
public class MyRouteBuilder extends RouteBuilder {

   private static final Logger LOGGER = Logger.getLogger(MyRouteBuilder.class);

   @Override
   public void configure() throws Exception {
      // REGISTER ROUTE TO IMPORT CSV
      from("file:{{myProperty}}/?noop=true") // FILE PATH FROM PROPERTIES
         .log(LoggingLevel.INFO, "PROCESSING FILE ${file:name}...")

And in this freshly instantiated class the property does not seem to be 
available any more in case the instantiation happens in the Unit test.

A different value (used to connect to a message queue) could be read without 
problems from a @Bean annotated configuration class.

> Am 26.03.2016 um 16:59 schrieb Claus Ibsen <claus.ib...@gmail.com>:
> 
> What happens if you have a application.yml file and put the property in there?
> 
> camel-spring-boot uses spring's property resolver so its a bit strange
> if spring can find it and not camel. What if you use that key in a
> spring @Bean is spring able to find it ?
> 
> On Sat, Mar 26, 2016 at 3:26 PM, geoHeil <e1225...@student.tuwien.ac.at> 
> wrote:
>> Hi,
>> 
>> my Camel properties work fine during normal execution of the software.
>> However, when I execute it via JUnit the properties cannot be read anymore.
>> As this is a spring boot application I stored the properties in the
>> application.yml properties file.
>> 
>> This is the error-message:
>> Property with key [myProperty] not found in properties from text:
>> file:{{myProperty}}/?noop=true
>> 
>> The following annotations are used for the test class:
>> @RunWith(SpringJUnit4ClassRunner.class)
>> @SpringApplicationConfiguration(classes = MyClass.class)
>> @ActiveProfiles("test")
>> and the properties are defined in src/main/resources/application-test.yml
>> 
>> 
>> 
>> --
>> View this message in context: 
>> http://camel.465427.n5.nabble.com/Camel-Properties-Spring-Boot-Unit-test-not-found-tp5779765.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to