I have a problem with the property-mechanism in JUnit-Tests. In my
application I just have to annotade my config-class to use property
placeholders.
@Configuration
@PropertySource("classpath:my.properties")
public class MyServiceConfigurator extends WsConfigurerAdapter {
...
}
Afterwards I can use properties this way: "{{someProperty}}", pretty cool
and simple.
I tried the same in my Junit-Test-Class.
@RunWith(CamelSpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {MyServiceConfigurator.class,
MyServiceTests.TestConfig.class}, loader =
CamelSpringDelegatingTestContextLoader.class)
@MockEndpointsAndSkip(value = "spring-ws:*")
@PropertySource("classpath:my.properties")
public class MyServiceTests {
...
}
But this annotation hasn't any effects there. So I end up doing this:
//static class within the Junits-test-class
@Configuration
@TestPropertySource("classpath:my.properties")
public static class TestConfig extends SingleRouteCamelConfiguration {
@Bean
@Override
public RouteBuilder route() {
return new MyServiceRoutes();
}
@Bean
public static PropertySourcesPlaceholderConfigurer configurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
Now I can use my properties but not with the known syntax: "{{myProperty}}"
but with "${myProperty}". Consequently I must change the code everytime I
want to use the JunitTests.
Has someone a simple explanation how to use properties within a Camel,
Spring-Boot, Webservice-Project, especially within the JunitTest-classes.
My project setup:
Camel 2.16.0
Spring-Boot 1.2.7
Thanks in advance
best regards
--
View this message in context:
http://camel.465427.n5.nabble.com/How-to-get-properties-working-in-camelTest-and-spring-tp5774102.html
Sent from the Camel - Users mailing list archive at Nabble.com.