Reputation: 3481
I have a camel-spring-boot application with a couple of routes. I now want to integration test one of the routes.
This is giving me problems. If I in my test initialize the spring boot application, all the routes are automatically loaded. Properties are read properly from my .yml file.
If I bypass the spring boot application and just use a plain unit test framework to avoid loading all the routes the property loading does not work (properties are not initialized at all and I get an error message).
I think the examples on the camel documentation pages and also the code sample leaves a lot to be desired. I am about to ditch camel-spring-boot altogether, I have spent the whole day on trying to get this to work.
How can I create an integration test for one of many routes with working property loading from a .yml file?
Upvotes: 3
Views: 856
Reputation: 3572
I know this is over a year old. But I ran into this question today myself. Currently using Spring boot 1.4.2 and the apache camel starter 2.18.0. I solved it with the help of @ClassRule
and @BeforeClass
so that I can generate a temporary folder and then store that information within the system properties.
@RunWith(SpringRunner.class)
@ActiveProfiles("unittest")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class AceBatchProcessorIntegrationTests
{
@ClassRule
public static final TemporaryFolder folder = new TemporaryFolder();
@BeforeClass
public static void init() throws IOException
{
folder.create();
System.setProperty("ace.batch.from", "file:" + folder.getRoot().getPath() + "?include=.*.tcbatch");
System.setProperty("ace.batch.to", "file:" + folder.getRoot().getPath() + File.pathSeparator + "done");
}
}
Upvotes: 1