camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From idioma <corda.ila...@gmail.com>
Subject How to get hold of the content of log:message
Date Fri, 11 Nov 2016 17:17:20 GMT
Hi, 
I have a route like this: 

       <camelContext xmlns="http://camel.apache.org/schema/spring">
		<route>
			<from uri="activemq:topic:inbox" />
			<log message="From: ${in.header.EmailAddress}" />
			<to uri="mock:result" />
		</route>
	</camelContext>

My initial test looks like this:

@RunWith(CamelSpringJUnit4ClassRunner.class)
@BootstrapWith(CamelTestContextBootstrapper.class)
@ContextConfiguration(locations="file:src/main/resources/META-INF/spring/camel-context-activemq-embedded.xml")
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
@MockEndpoints("log:*")
@DisableJmx(false)

public class MySpringXMLEmbeddedActiveMQTest{

	private Logger LOG =
LogManager.getLogger(MySpringXMLEmbeddedActiveMQTest.class.getName());

	protected LogRecipientsProcessor processor = new LogRecipientsProcessor();
	protected Exchange exchange;

	@Produce(uri="activemq:topic:inbox")
	protected ProducerTemplate template;
	
	@EndpointInject(uri="mock:result")
	protected MockEndpoint resultEndpoint;

	@Test
	public void testMockEndpoint() throws Exception {
		EmailAddress recipients = new EmailAddress("recipient@example.com");
		String header = "This is my header";
		template.sendBodyAndHeader("activemq:topic:inbox", recipients.toString(),
header); 
		assertNotNull(exchange.getIn().getBody());
		resultEndpoint.assertIsSatisfied();
	}
}

I am using a mock as endpoint and sending the body and the header. (The body
is my email address). I fail to see how I can test the logged message in
<log message="From: ${in.header.EmailAddress}" />. Do I have to read the
header from the exchange? Do I need to set the content of the log message
beforehand? Any available example would be most welcomed. 

Thank you,

I. 



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-get-hold-of-the-content-of-log-message-tp5790064.html
Sent from the Camel Development mailing list archive at Nabble.com.

Mime
View raw message