I have the following in a unit test for a Camel route:
RouteUnitTest.java
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {RouteUnitTestConfig.class})
public class RouteUnitTest extends CamelTestSupport {
@Autowired
MQProperties mqProps;
@Autowired
Route route;
@Produce(uri="...")
ProducerTempalte template;
@Test
//rest of test class
}
The MQProperties object pulls properties from property files, and for unit tests it reads the application-unit-test.properties file, which uses SEDA endpoints for unit testing. I can't seem to get the expression correct in the @Produce tag; I want to set the ProducerTemplates uri to mqProps.getReceiveQueue(), but out of the formats I've tried, I get an exception regarding setting a default endpoint for the producer. I know that it's not an issue with the value that should be passed in, calling template.send(mqProps.getReceiveQueue(), exchange); for example works just fine. I have tried the following formats:
@Produce(uri="#{@mqProps.getReceiveQueue}")
@Produce(uri="{{mqProps.getReceiveQueue}}")
@Produce(uri="#{mqProps.getReceiveQueue}")
These have thrown the exception mentioned. Am I getting the EL format wrong, or is it an issue with the autowiring?i.e. Maybe the object isn't populated by the time the producer uri stuff is all hooked up? I can't find much else on this, Camel resources talk more around Bean injction etc, but any resources I've seen thus far on the @Produce annotation usually use a hardcoded string, or read from a property file directly